ELXSoftware

ELX-Serial

Documentation

Building it, running it as a service, and understanding what the watchdog is doing.

Building

On the target machine
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.

PlatformSupported
armhf / armv7l — 32-bit single-board machinesYes, the primary target
arm64 / aarch64Yes
x86, amd64Yes
WindowsNo

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.

/etc/systemd/system/elxserial.service
[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
Enable and watch
sudo systemctl enable --now elxserial
journalctl -u elxserial -f
Not as rootA dedicated user in the 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.

Common cases
"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

SymptomWhere to look
Cannot open the devicePermissions — the service user is not in dialout; or another program already holds the port
Clients connect but see nothingWrong baud rate, or A and B reversed on RS-485
Data arrives corruptedraw is missing from the settings string, or the parity is wrong
The port reopens repeatedlyThe watchdog is polling a device that does not speak its protocol — disable polling for such devices
The fifth client is refusedThe client limit; raise it with the corresponding option
Everything stops after days of workCheck 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?
Yes. Point it at /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.
How many clients can it hold?
As many as you allow; four by default. The practical limit is the line, not the process.
Is there a way to have clients that only listen?
Yes — the write-only mode covers the opposite case, and a client that simply never sends is already read-only.

Nearby programs