Socat and serial port over TCP/IP
This week I "discovered" for myself netcat successor socat. This tool gives you numerous possibilities to redirect various kind of traffic over various channels. For myself I used it to create a channel to transfer data from any kind of serial port over TCP/IP network. This is simple and elegant.
Just install a socat package on your distribution. E.g. on Fedora
yum install socat
you can read a comprehensive man page (man socat), but you may get headache from it.
Lets say you want to transfer data to/from your serial port device connected via USB or serial port. Then on the box where the device is connected use this kind of command as root or any user in dialout group:
socat TCP-LISTEN:27644,fork /dev/ttyS0,raw &
That's it. You need of course open the port 27644 for that.
Now if you want to connect to this port from Windows machine, you can use freeware HW VSP 2 - so called virtual serial port or port redirector - to create a virtual serial port on Windows. As a target put the IP of your server and port 27644.
You can connect to the device remotely, from any application running on Windows that wants to access this device on COM port via virtual serial port thru TCP/IP. Just your Windows app is thinking it is using local serial device, but it can be connected on the over side other globe to your Linux machine.
If you want to do the same thing on another Linux box, try this
socat -d -d -d pty,link=./com1,echo=0,crnl tcp:remote-server:27644
(-d is debug, you may remove it and socat remains silent) to fake COM1 port e.g. for Wine in dosdevices directory.
If you want you can do it thru TUN or OPENSSL for safety. This is so powerful and so unixish!
Thanks for sharing, works for me!