Creating a virtual serial port over TCP

I am developing an application that should be able to write to a virtual serial port and receive data through the same port from remote clients over the network.

The application runs on the linux server. I am new to using serial ports and I have some questions on this topic.

Customers

The client can establish a TCP connection to the server. When we configure the client, we must provide the server IP address, tcp port (usually 8080) and virtual COM port.

Then the client will automatically try to connect to the server.

Server

The server has a virtual COM port, the same one that we installed in the client configuration (for example, COM1). When an application on the server writes data to this port, the data should be sent to all clients connected via tcp. The response from the clients is sent via TCP back to the server, which can read it through the virtual serial port.

Question

In the windows, I used the virtual serial port http://www.eterlogic.com/Products.VSPE.html , which did most of the work. However, I want to solve this problem on Linux machines.

My question is: how can I create a TCP server with a virtual serial port connected and send / receive data through this port through TCP to listen on clients?

+8
linux sockets tcp serial-port virtual-serial-port
source share
2 answers

Try socat . Possible scenario:

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

socat creates a TCP connection with 192.168.254.254:8080, so everything written to / dev / virtualcom 0 will be redirected to 192.168.254.254:8080 and vice versa.

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

+16
source share

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

I use it to create virtual serial communication over a network, but I have a real RS232 port on my computer. So I just transfer the data over the network. If you also need to create a virtual COM on the server, use the virtual serial port driver.

+1
source share

All Articles