Samuel Tardieu @


Bridge between serial ports and TCP sockets on Linux

It is often necessary to bridge a serial port and a TCP socket. Every modern language includes an easy way of opening TCP sockets, while they do not all come with advanced facilities to deal with serial ports. See this blog post for reasons to do so.

Common methods to bridge a serial port and a TCP socket include:

  • pyserial: this Python module lets you easily configure and access serial ports;
  • socat: this program lets you build many kind of briges, including serial port to TCP socket ones.

However, those do not let you configure an arbitrary baud rate that works with every kind of serial port. Configuring an arbitrary baud rate may be needed when dealing with some devices, such as an XBee module, whose clock divisor only allows for speeds such as the non-standard 111,111 bps.

serialbridge and setspeed take advantage of ioctl calls introduced in 2009 in the Linux kernel named TCGETS2 and TCSETS2. Those allow to set a serial port at an arbitrary speed, such as 111,111 bps.

Before the introduction of those new ioctl calls, it was possible to use an arbitrary speed by setting the port to 38400 bps and configuring a custom divisor. However, it does not work on all the devices. In particular, the ttyACM driver does not support this way of setting a custom speed and conveying the information to the device over USB.

Getting serialbridge

You can either download a packaged version, or get the latest development version of serialbridge.

Packaged version 0.1

You can download serialbridge 0.1 for Unix, distributed under the GNU General Public License (GPL).

Development version

You can get the current development version of serialbridge using git:
git clone
This will create a serialbridge directory in which you will be able to record your own changes. You can also browse the serialbridge repository on GitHub.

Contributing to serialbridge

Reporting bugs and asking for features

If you find a bug or have an idea for a new feature, you might consider adding a new issue. The more precise you will be in your description, the more useful it will be.

Submitting patches

Patches are gladly accepted from their original author. Along with any patches, please state that the patch is your original work and that you license the work to the serialbridge project under a license compatible with the current one (GNU General Public License (GPL)).

To propose a patch, you may fork the serialbridge repository on GitHub, and issue a pull request. You may also send patches and pull requests by email.