Create a virtual serial port connection over TCP Create a virtual serial port connection over TCP linux linux

Create a virtual serial port connection over TCP


Try socat. Possible scenario:

socat  pty,link=/dev/virtualcom0,raw  tcp:192.168.254.254:8080&

socat creates TCP connection to 192.168.254.254:8080, so that everything, that will be written to /dev/virtualcom0 will be forwarded to 192.168.254.254:8080 and vice versa.

Another approach would be to use RFC2217 via ser2net on Linux sever side and RFC2217 driver on Windows side (for example http://www.hw-group.com/products/hw_vsp/index_en.html single port version). You can also try to get http://pyserial.sourceforge.net/ to work with ser2net.


you have socat and ser2net and other programs but my experience is very bad... not working properly. I've done this small python program, can be useful. Update port, baudrate... then use any tcp client. Remove first line if don't want to use is as auto executable script

#!/usr/bin/pythonimport socketimport sysimport serial#open serial portser = serial.Serial('/dev/ttyAMA0', 115200, timeout=0)#create socketsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)#bond to the port. Don't use localhost to accept external connectionsserver_address = ('', 2105)print('starting up on {} port {}'.format(*server_address))sock.bind(server_address)#listensock.listen(1)#loopwhile True:    #waits for a new connection    print('waiting for a connection')    connection, client_address = sock.accept()    try:        print('connection from', client_address)        #continously send from serial port to tcp and viceversa        connection.settimeout(0.1)        while True:            try:                data = connection.recv(16)                if data == '': break                ser.write(data)            except KeyboardInterrupt:                connection.close()                sys.exit()            except Exception as e:                pass            received_data = ser.read(ser.inWaiting())            connection.sendall(received_data)    except Exception as e:        print e    finally:        #clean up connection        connection.close()


The software will help to establish server and client connection over TCP http://www.serial-com-port.com/

I use it for creating virtual serial communications over network, but I have the real RS232 port on the computer. So I just transfer the data over network. If you need to create a virtual COM on the server too, use the Virtual Serial Port Driver.