How to use Netcat to pipe serial data over TCP
Procedure for Using Netcat to Pipe Serial Data Over TCP
1) Set up test so that a BB-400 and a suitable ES (Ethernet to Serial) device are connected over a serial cable. Configure the BB-400 serial connection to be either RS232, Full-Duplex RS422 or Half-Duplex RS485.
2) Connect a Raspberry Pi 3 to the BB-400 via an Ethernet network cable as shown in the diagram below. Note this does not have to be a Raspberry Pi but I’ve used it since I can implement the other end of the netcat connection easily.
3) Also connect the ES Device to the network and Telnet into it so as to be able to send and receive data.
4) SSH into the BB-400 and Raspberry Pi 3.
5) In the Raspberry Pi 3, type the command ‘
nc -l xxxx’ where xxxx is a port number of choice.
6) In the BB-400, first setup the tty serial port with an appropriate Baud rate and any additional options. Type the command ‘
stty -F /dev/ttySC0 115200 raw -echo -echoe -echok’ In this case, a baud rate of 115200 baud has been chosen. Note, ensure the ES Device’s baud rate setting is configured identically.
7) In the BB-400, type the command ‘
nc 192.168.0.yy xxxx </dev/ttySC0 >/dev/ttySC0’ where yy represents the last two digits of the RPi 3’s IP address and xxxx is the same port number chosen in step 5). This will pipe the serial data over TCP and vice versa.