Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test Loopback Devices

A command-line tool designed for serial port benchmarking, WebSocket bridging, and signal testing. It is particularly focused on testing loopback devices. I tested it with loopback devices based on the FT231X. Why such a device would be useful to anyone in 2026 is beyond me.

Build

cargo build --release

Commands

write

Write 0xAA bytes continuously at maximum speed. Reports throughput every second. Ctrl+C exits immediately.

serial-tool write <port> <baud>
$ serial-tool write /dev/cu.usbserial-A 3000000
300000 bytes/sec written (300000 bytes in 1.00s)
300000 bytes/sec written (300000 bytes in 1.00s)
^C

read

Read from a serial port at maximum speed and print throughput every second.

serial-tool read <port> <baud>
$ serial-tool read /dev/cu.usbserial-B 3000000
300000 bytes/sec (300000 bytes in 1.00s)

serve

Start a WebSocket server that bridges all connected clients to a serial port. Multiple clients share the same port: reads are broadcast to all clients, writes from any client go to the port.

serial-tool serve <port> <baud> <listen-addr>
$ serial-tool serve /dev/cu.usbserial-A 115200 0.0.0.0:9000
WebSocket server listening on ws://0.0.0.0:9000
Client connected: 192.168.1.5:52431

connect

Connect to a remote WebSocket server and bridge it to a local serial port. Same bidirectional bridge as serve, but as a client.

serial-tool connect <port> <baud> <ws-url>
$ serial-tool connect /dev/cu.usbserial-B 3000000 ws://192.168.1.10:9000
Connected to ws://192.168.1.10:9000

Use serve on one machine and connect on another to link two serial ports over the network.

signals

Continuously test RTS/CTS, DTR/DSR, and DTR/CD signal lines between two serial ports. Each test asserts that both the high and low transitions are observed on the other side. Runs in a loop until Ctrl+C.

serial-tool signals <portA> <portB>
$ serial-tool signals /dev/cu.usbserial-A /dev/cu.usbserial-B
Round 142: 6/6 PASS (total: 852 pass, 0 fail)
^C

Stopped after 142 rounds: 852 passed, 0 failed

Signals tested per round:

Set on Signal Read on Signal
A RTS B CTS
B RTS A CTS
A DTR B DSR
B DTR A DSR
A DTR B CD
B DTR A CD

Exits with code 1 if any failures occurred.

bench.html

A standalone HTML page for benchmarking serial throughput via WebSocket. Open it in a browser, point it at a running serve instance, and use the Read/Write benchmark buttons.

Expected throughput

With standard 8N1 framing (10 bits per byte), the theoretical maximum is baud/10:

Baud rate Expected bytes/sec
9600 ~960
115200 ~11,520
3000000 ~300,000

About

Test Loopback Devices

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages