0
votes

I have a real serial port COM1 on PC, plus some USB serial ports. I would like to send and receive data using TCP/IP/UDP api, but not serial api (such as open the file, or C# serial api).

I plan to create virtual network interface and write some service to divert the communication packets to serial ports. How do I achieve this on Windows, or Linux? Is it a driver? or can it be done in user space? My plan is to set a designated IP address, and use port 0 (or specify one) for configuration, such as listing available serial ports, and open, close, set baud rate... and use other ports to communicate to them.

I know someone will mention PPP, but don't. That requires a TCP/IP stack on the other side. I want to talk to a real serial device on the other side.

1
You will need to find an adapter of some kind that does it, which puts this question off-topic.user207421
@EJP I am looking a pure software implementation, not some adapter hardware. What you implied is that it needs a driver, that is one info.Hai Bi
I did not mean a hardware device and I did not imply anything about a driver. Still off topic.user207421

1 Answers

1
votes

I'm not entirely sure I understood your question correctly, so this might be wrong. But it seems to me that you need a regular user space TCP/IP server on the machine with the COM port.

The server would bind to any IP address you give it (you can create your own virtual interface of it if you want) and give clients access to the COM port using some protocol you'll implement over the socket. You can have the server listen on multiple ports - some for configuration, some for data.

Here's a sketch:

enter image description here