It is often necessary to bridge a serial port and a TCP socket. Everymodern language includes an easy way of opening TCP sockets, while theydo not all come with advanced facilities to deal with serial ports.See this blog postfor reasons to do so.
![]()
Launch socat: $ socat pty,link=$HOME/dev/ttyV0,waitslave tcp:remoteip:remoteport. Open minicom on /dev/ttyV0 and send chars to your remote port. How to configure the NetCom for my baudrate? If you just need to exchange data with your serial attached devices and the application doesn't care about modem signals, you can use socat to create a fixed TTY device. Devices you will not be able to change any serial parameter (like speed, parity etc.).
Common methods to bridge a serial port and a TCP socket include:
However, those do not let you configure an arbitrary baud rate that workswith every kind of serial port. Configuring an arbitrary baud rate may beneeded when dealing with some devices, such as an XBee module,whose clock divisor only allows for speeds such as the non-standard111,111 bps.
serialbridge and setspeed take advantage of ioctl calls introducedin 2009 in the Linux kernel named TCGETS2 and TCSETS2 . Those allowto 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 usean arbitrary speed by setting the port to 38400 bps and configuring a customdivisor. However, it does not work on all the devices. In particular, thettyACM driver does not support this way of setting a custom speed andconveying the information to the device over USB.
This software is made available under the GNU General Public License. See thesource files and the
LICENSE file for more information.
![]()
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |