Serial ports over TCP/IP with socat

This article illustrates how to realize a lan to serial gateway

Remote unit

On the remote unit install ser2net then add this line in /etc/ser2net.conf configuration file

2000:raw:600:/dev/ttyS1:115200 8DATABITS NONE 1STOPBIT

Launch ser2net:

# ser2net

Local unit

Install the socat utility.

Create a directory called $HOME/dev

Launch socat:

$ socat pty,link=$HOME/dev/ttyV0,waitslave tcp:remoteip:remoteport

Open minicom on /dev/ttyV0 and send chars to your remote port.


Serial port on stdin

socat /dev/ttyUSB0,b115200,raw,echo=0,crnl -

Remote console


socat /dev/ttyS2,b115200,raw,echo=0
socat /dev/ttyS4,b115200,raw,echo=0

Server web

socat TCP-LISTEN:2002 PTY,link=ttyV2,raw,crnl
socat TCP-LISTEN:2004 PTY,link=ttyV2,raw,crnl

Design tips

Using the RoadRunner SOM it is possible to manage up to 10 serial ports over a network link.

Related links

Related products

RoadRunner D2

Info Doc Buy

  • CPU Microchip SAMA5D27
  • Cortex A5 @ 500 MHz
  • Very low power consumption:
    396mW in full speed mode
    198mW at Linux prompt
    17mW in standby mode
    10mW in suspend to RAM mode
  • Armhf architecture
  • DDR3L RAM 256 MB
  • QuadSPI 0/16/64/128MB
  • Size: 40x30 mm
  • Plug-in module
  • 200 pins 0.4 mm pitch
  • TFT parallel interface
  • Boot from internal Quad SPI or external uSD/eMMC
  • Linux Kernel 5.15 LTS
  • Debian, Buildroot and Yocto
  • Open source drivers

Info Doc Buy

Single Board Computer based on RoadRunner Linux SOM (Included)

  • Classic "Credit Card" form factor
  • Two USB Host 2.0 ports (one configurable as USB client on the USB-C connector)
  • One 10/100 Mbit/s Lan port
  • 2 Acme Sensor ports
  • Double placements for 2.54mm pitch 20x2 pinstrips (not soldered) for GPIOS, SPI, I2C, Serial etc ports
  • Credit Card footprint

Info Buy

  • All the circuitries you need to test the RoadRunner SOM
  • USB host, USB device, Ethernet port, MicroSD socket
  • Test points for power consumption measurements
  • All the Roadrunner signals exposed on 2.54mm pitch pins
  • On-board supercap for RTC and backup memory circuit