I’m posting this mainly because Google didn’t turn up any help when I queried about using the USR-IOT serial port to ethernet converters (also known as terminal servers) with Linux. They make several low-cost devices that are really handy if you need to talk to serial devices that are far from the host computer. In particular, the USR-TCP232-410S single port converter and USR-N540 four port device are quite inexpensive. Their website has nary a mention of Linux compatibility, and I didn’t find any Google hits indicating that they work with anything other than Windows and maybe Mac.
It turns out that they work just fine under Linux, using standard protocols. You can even change speed as if the port were physically connected to the computer. Leaving the server set at its default settings, all you need to do on the Linux end is install the socat “multipurpose relay” tool (it’s available as a package in Debian-based distributions) and write a simple shell script.
Here’s what I’m using:
# open virtual serial port
socat pty,link=$HOME/vmodem0,waitslave tcp:10.73.1.71:23 &
# run the program
# kill socat afterwards
Customize the socat command line with the name of the port device (here $HOME/vmodem0, but you can name it and place it wherever you want), and the IP address and port of the serial server.
This worked on the first try, suspiciously easily.
It appears that socat destroys the vmodem0 device when the called program finishes running, but does not kill its process. That’s why I stuck the killall command on the last line. There is probably a way to make the device persistent so you would only need to run the socat command once at bootup, but I haven’t dug around for it yet.