wikipedia

Support Wikipedia

Friday, July 8, 2011

Routing Serial data to a socket

You don't need  a hardware device (like Lantronix adapter) to route data from a Serial port to a socket. Thanks to socat, you can relay data from a serial port to another or serial port to a socket or socket to socket and plenty more such combos, all in one line! socat is exhaustive in what it can take as arguments. Check it out.

Here is an example of making available data from serial port /dev/ttyS0 on a linux environment (usually this is COM1 on windows boxes) through a socket (port = 8023).

socat TCP-LISTEN:8023,fork /dev/ttyS0,raw,b9600,echo=0

The baud rate specified here is 9600. fork option lets you make multiple connections to the source of data, which in this case is the serial port.

You can verify the data  from the socket by using a telnet or similar application.


telnet localhost 8023


1 comment: