Serial to Net utility for the Pi allows one myServer computer to connect via IP to another Pi where a serial device might be connected. Converts serial port to an IP address
Use case: ELK security panel connected to a Pi4 via serial to USB adapter. myServer running the ELK driver located elsewhere. Optionally you can connect the ELK to multiple myServer instances (for testing as example).
1.) First identify the port name of your serial device. This can be done via the following command from a linux command:
dmesg | grep tty
2.) Install Ser2Net:
sudo apt update
sudo apt upgrade
sudo apt-get install ser2net
sudo nano /etc/ser2net.conf
Append to bottom of the file and save:
2101:raw:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT max-connections=3
Note:
2101 is the TCP port. Replace with any value that is not already used between 1024 and 65535.
/dev/ttyUSB0 is the port name. Replace with your specific port name per step #1.
115200 is the baud rate. Replace with the baud rate required for the serial device.
max-connections=3 this is so that multiple clients can connect to TCP server.
Resave the file with the original filename (Ctrl O) and then exit (Ctrl X)
3.) Restart Ser2Net:
sudo /etc/init.d/ser2net restart