rioproxy
Serial- and USB-VISA-to-TCP adapter daemon.
rioproxy is a Rust daemon that exposes serial ports and USBTMC VISA devices as TCP services. It scans for devices, binds each to a TCP port and proxies raw bytes between TCP clients and the hardware. It is part of the Pylatus software stack.
Overview
On start rioproxy scans serial ports in /sys/class/tty and, when the visa feature is enabled, scans for Keithley USBTMC
devices vendor 0x05e6 product 0x2200. Each discovered device is bound to the TCP port recorded for it in the
configuration file. Clients connect via TCP and exchange bytes directly with the device.
Serial ports are polled every second; devices that appear or disappear are automatically added or removed while keeping
the same TCP port for a device that reappears. A USB serial port is identified by vendor, product, serial number and
interface (0403:6001:FTOR4Z7U:00), or by controller and port path when it has no serial number
(0000:00:14.0/2-4:1.0), so it gets its TCP port back even under a different ttyUSB name; other ports are identified
by name. Phantom 8250 ports (sysfs type 0) are skipped. The visa implementation speaks the USBTMC VISA protocol, framing
messages with the VISA header and handling bulk transfers.
The daemon can run in background mode with PID file, user/group, working directory and log file configuration. Logging is provided by the internal besy crate.
Components
src/main.rs- entry point, daemonizes before building the tokio runtime, starts the scanners and handles signals.src/params.rs- command line parsing with clap, daemonization, logging initialization.src/config.rs- the TCP port map: loading, validation of line settings, appending new devices.src/device.rs- TCP port bookkeeping and supervision of device tasks, shared by both scanners.src/hub.rs- TCP listener per device, client sessions with per-client framing, fan-out of device bytes to all clients.src/tty.rs- serial port discovery through sysfs, device identity keys.src/serial.rs- serial port polling, one task per opened port.src/usb.rs- USB device lookup through sysfs, endpoint discovery, bulk read/write, kernel driver handling.src/visa.rs- VISA device polling, USBTMC framing per client, request/response exchange in a blocking thread.
Build
Requires Rust stable and Cargo.
Dependencies are declared in Cargo.toml. The project uses the internal besy crate:
Other crates are from crates.io: clap, daemonize, whoami, tokio-serial, tokio, bytes, serde, toml, chrono, rusb. libudev is not required.
Build release binary:
cargo build --release
Enable VISA support:
cargo build --release --features visa
The binary is placed at target/release/rioproxy.
Release profile is optimized with LTO, debug symbols stripped and rpath disabled.
Usage
Show help:
rioproxy --help
Run in foreground:
rioproxy
Run as daemon with PID file and info logging:
rioproxy --daemon --pid /var/run/rioproxy.pid -vv
Or leave it in the foreground under the init system: an OpenRC service and its configuration are in scripts/openrc.
The service hands the configuration file to the daemon user, so that new devices can be appended to it.
Use another configuration file:
rioproxy --config /opt/rioproxy/rioproxy.toml
Connect to a device with netcat:
nc localhost 7900
Multiple TCP clients share the same serial or VISA session; bytes received from the device are broadcast to all clients.
Configuration
The TCP port map lives in /etc/rioproxy.toml unless --config says otherwise. It is read once at start; to change it,
stop the daemon, edit the file and start it again. A file that cannot be read or parsed, including an unknown field, a
bad line setting, a key configured twice or a TCP port given to two devices, stops the daemon at start, so a typo never
renumbers the ports. A missing file is an empty map.
A device missing from the map is appended to the file after it has been opened successfully for the first time, as a block with a comment and explicit line settings. The daemon never rewrites the file, so hand-written comments stay; it needs write access to append. A new device gets the port after the highest one of its kind in the map, or the base port when there is none, skipping every port already taken by a serial or VISA device; holes are never refilled.
# /dev/ttyUSB0 [0403:6001:BG03YUYG:00] FTDI FT232R USB UART at /sys/devices/..., added 2026-09-24 12:00:00
[[serial]]
key = "0403:6001:BG03YUYG:00"
tcp = 7900
baud_rate = 9600
data_bits = 8
parity = "none"
stop_bits = 1
flow_control = "none"
ignore = false
# Keithley Instruments Inc. 2200-72-1 at /sys/bus/usb/devices/2-7, added 2026-09-28 10:00:00
[[visa]]
resource = "USB0::0x05e6::0x2200::9203210::INSTR"
tcp = 7950
ignore = false
data_bitsis 5 to 8,parityisnone,oddoreven,stop_bitsis 1 or 2,flow_controlisnone,softwareorhardware. Omitted line settings mean 9600 8N1 without flow control.ignore = truekeeps a device closed, e.g. a console or a BMC serial-over-LAN port.- A
[[visa]]block needs a build with thevisafeature; without it the file is rejected.
Default base ports:
- serial TCP base port 7900
- VISA TCP base port 7950, feature
visaonly
License
GPL-3.0+