Skip to content

Serial Port Forwarding over Ethernet

Carmen edited this page May 11, 2022 · 5 revisions

Serial Port Forwarding over Ethernet

General Outline

Device connected to serial port

  1. sudo apt install socat
  2. socat tcp-listen:<port>,reuseaddr,fork file:/dev/ttyUSB0,nonblock,waitlock=/var/run/tty0.lock,b115200,raw,echo=0
    a. This starts the socat server on on the Raspberry pi b. This is also just an example command. You might have to change the file (device) or the baudrate

On Basestation

  1. sudo apt install socat
  2. socat pty,link=<your file>,waitslave tcp:<ip>:<port>
    a. You can put this command in a while loop if running into connection issues
  3. You can now open up the port you created by opening MINICOM pointed at the file you picked a. For some reason picocom doesn't work, you must use minicom b. Depending on your application you might not need this step, but you should be able to access the serial port via that file

IMPORTANT

With these commands SPACES are super important, the structure of each commmand is
socat <space> <file>,<options separated by comma with NO space> <space> <port>,<options separated by comma with NO space>

References

Source
socat man
basic tutorial
Another option to try if above doesn't work

Clone this wiki locally