Forward a serial line over TCP using socat

This command creates a server listening on tcp port 22001 and directing all output from serial port ttyACM0 to a client connecting there.
The given options for the "tcp-listen:"-address configure for listening on port 22001, restrict listen on local interfaces and for a child to handle the incoming connection.
The given options for the "file:"-address configure the serial port to 9600 bps, character size of 8 bits, no parity, the terminal is set to non-blocking mode and a lock file for the serial port is created.

socat tcp-listen:22001,range=,reuseaddr,fork file:/dev/ttyACM0,b9600,cs8,parenb=0,nonblock,waitlock=/var/run/lock/ttyACM0.lock

On the other end the following command connects to the server created above and directs the output of the serial port to stdout.

socat -,escape=0x0f tcp:localhost:22001

The escape option allows for terminating the socat process with character control-O.

See this web page: Some Helpful socat Commands. and the official documentation for more examples of socat use.

linux logo Powered by Apache
This site maintained by:
My public PGP key
last updated: 2018-11-19 Valid CSS! Valid XHTML 1.0 Strict