Building
make all
sudo make install
Nothing beyond a C compiler and libc is required; it has been checked with gcc 12. Root is needed only for installation and for access to the device itself.
| Platform | Supported |
|---|---|
| armhf / armv7l — 32-bit single-board machines | Yes, the primary target |
| arm64 / aarch64 | Yes |
| x86, amd64 | Yes |
| Windows | No |
Running as a service
Under systemd the program does not need to daemonise itself — the daemonise option exists for older init systems and should be left off here.
[Unit]
Description=ELX-Serial bridge on /dev/ttyS1
After=network.target
[Service]
ExecStart=/usr/local/bin/elxserial -m 5 -p 1824 -s "115200 raw" -k 60 /dev/ttyS1
Restart=always
RestartSec=5
User=elxserial
SupplementaryGroups=dialout
[Install]
WantedBy=multi-user.target
sudo systemctl enable --now elxserial
journalctl -u elxserial -f
dialout group is enough to open the port, and a bridge listening on the network is exactly the sort of program that should not be root.Port settings
The settings string is passed in stty style. raw matters more than it looks: without it the terminal layer processes control characters and line endings, and a binary protocol arrives subtly corrupted rather than obviously broken.
"115200 raw" 8N1 at 115200, no processing
"9600 raw parenb -parodd" 9600 8E1
"19200 raw cstopb" 19200 with two stop bits
What belongs in the log
- Clients connecting and disconnecting, with their addresses.
- Watchdog misses, and the port being reopened.
- A controller answering with an error flag — alive, but unhappy.
- Port open failures, with the reason from the system.
Debug level 1 adds the traffic summary; level 2 adds the bytes. Level 2 is for bringing up a new device, not for permanent operation — a busy line fills a disk with it.
When it does not work
| Symptom | Where to look |
|---|---|
| Cannot open the device | Permissions — the service user is not in dialout; or another program already holds the port |
| Clients connect but see nothing | Wrong baud rate, or A and B reversed on RS-485 |
| Data arrives corrupted | raw is missing from the settings string, or the parity is wrong |
| The port reopens repeatedly | The watchdog is polling a device that does not speak its protocol — disable polling for such devices |
| The fifth client is refused | The client limit; raise it with the corresponding option |
| Everything stops after days of work | Check the log for reopen messages: an adapter that locks up regularly is a hardware fault the watchdog is masking |
Frequently asked questions
Can I bridge a pseudo-terminal?
/dev/ptmx and give it a symlink name for the slave side, and a program that insists on a serial port will talk through the network.