I have a scenario where multiple processes on the same box want to communicate with a serial device. Process A needs two-way communications with the serial port, and Process B only needs to be able to write to the serial port. The serial device is continually spewing data, while the two processes periodically write to the port. The environment is Cygwin on Windows (the processes are windows processes), but the serial port could be moved to a *nix virtual machine if anyone has a Linux-only solution.
My "network diagram" is as follows:
/--<->--[Process A]
[serial device]-ttyS0--<->--[socat]-udp-<
\--<<<--[Process B]
My first attempt was to set up a socat instance with udp-recvfrom and the fork option. This works for the first packet - a process forks off from socat, sends the data to the serial device, and starts reading data back from the serial device. However, this forked process now has the serial port open for read-write, so no more forks successfully start.
Can anyone think of any way to get this to work? I can think of the following avenues but I haven't found settings to make any of them work:
- Use socat's udp-recv option to receive from anyone, but find a way to make it send replies to a specific address.
- Use two unidirectional socats, one to write to the port and one to read from the port. I would then need a way to combine these two unidirectional streams into one bidirectional stream, but I don't know how.