Procedure for Using Netcat to Pipe Serial Data Over TCP
- 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.
- 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:
- Also connect the ES Device to the network and Telnet into it so as to be able to send and receive data.
- SSH into the BB-400 and Raspberry Pi 3.
- In the Raspberry Pi 3, type the command: ‘
nc -l xxxx’ where xxxx is a port number of choice.
- 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.
- 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.