ser2net is a service developed by Corey AE5KM that allows a serial port to be accessible through a TCP connection. In addition, it allows multiple connections, so that several TCP/IP accesses can have access to the serial port.
If your raspberry pi (RsPi) does not include this service, installation is simple. Type:
pi@raspberrypi:~$ sudo apt-get install ser2net
As of version 4, the configuration is done through the file ser2net.yaml (YAML extension), which is located in /etc. In previous versions, the file used was ser2net.conf (CONF extension) and it had quite a different syntax.
ser2net.yaml - V4
The ser2net service switched to using the YAML format. The configuration file is located in /etc/ser2net.yaml and an example would be the following:
In this example we see 5 blocks, and each block tells the ser2net service the correspondence between the TCP port and its serial port.
Example, the first block called ars01 listens for connections on tcp port 6001 and associates it with the serial port called /dev/ars01. This port has been defined in the UDEV service as explained in the FAQs Guide – UDEV
In the second case (ars02) it listens on tcp port 6002 and associates it to the serial port that /dev/ars02
ser2net.conf - V3
The previous version of the ser2net service used a configuration file with a different format. The file was in /etc/ser2net.conf and an example of using that configuration is the following:
In this case, as many lines as “tcp port” to “serial port” blocks are needed. Each line corresponds to what in the new version is a block.
Example: the first line indicates that the tcp port to use is 6001 and it is associated with the serial port /dev/ars01
ser2net reload
Once the configuration file has been edited, you can restart the service so that the new configuration is loaded using the command:
pi@raspberrypi:~$ sudo service ser2net restart