This is a small Rust program which relays data between a raw tcp socket (can act as server or client) and a virtual USB-ACM serial converter.
It takes many parts from the usbip crate example
-
You need to install usbip on your system. Packages are usually in the repos on Linux Distributions
-
Make sure you have Rust installed.
-
Clone and build this project
$ git clone git@github.com:voidfield101/TCP-V-Serial.git
$ cd TCP-V-Serial
$ cargo build --release
- Run the virtual serial server. This example sets up a TCP server on 8888 and a USB/IP Server on 9999
$ RUST_LOG="info" ./target/release/tcpvserial -l -a 127.0.0.1:8888 -p 9999
- Connect bind the USB/IP device
$ sudo usbip --tcp-port 9999 attach -r localhost -b 0
- Done. You can now connect to the TCP/Telnet server and use the serial device (example using netcat, cat and echo):
$ netcat localhost 8888
Hello World
Hi
Hi
$ echo "Hello World" > /dev/ttyACM0
$ cat /dev/ttyACM0
Hi