An app which reads data from a serial port and serves it on a TCP port.
Go to file
usagi-flow 54e94f6003
Add a simple woodpecker CI configuration
2023-05-27 16:41:39 +02:00
.github/workflows Update rust.yml 2022-11-09 20:01:48 +01:00
etc/init.d Add an OpenRC script 2022-04-30 13:18:05 +02:00
src Consistent formatting 2023-04-15 12:16:53 +02:00
.woodpecker.yml Add a simple woodpecker CI configuration 2023-05-27 16:41:39 +02:00
Cargo.lock Prepare for the next release 2023-05-27 16:30:24 +02:00
Cargo.toml Prepare for the next release 2023-04-15 13:50:05 +02:00
LICENSE Initial commit 2022-04-27 22:00:45 +02:00
README.md Update README.md 2023-05-27 16:36:31 +02:00
flake.lock Add a nix flake to build the app 2023-05-27 16:31:06 +02:00
flake.nix Add a nix flake to build the app 2023-05-27 16:31:06 +02:00
rustfmt.toml Consistent formatting 2023-04-15 12:16:53 +02:00

README.md

serial-to-tcp

repository build license

An app which reads data from a serial port and serves it on a TCP port.

How to use

Download a binary for your architecture or build the app as outlined below.

The app takes its configuration from the command line. Multiple instances of the app can be executed at once. The app can serve multiple clients at once.

Root privileges are most likely needed to open the serial device (and to open a port under < 1024, if applicable).

Example

Read from USB device ttyUSB0 with a baud rate of 115200, and serve the data on TCP port 2022:

serial-to-tcp -s /dev/ttyUSB0 -b 115200 -p 2022

On another client in the network, assuming the server has the IP address 192.168.0.123, test reading from the TCP port, e.g. using socat:

socat - TCP4:192.168.0.123:2022

Usage

USAGE:
    serial-to-tcp [OPTIONS] --serial-device <path> --baud-rate <number> --port <number>

OPTIONS:
    -n                            (optional) If set, do not poll the serial device: If the device
                                  is/becomes unavailable, terminate immediately.
    -s, --serial-device <path>    The serial device to read from, e.g. /dev/ttyUSB0
    -b, --baud-rate <number>      The serial baud rate to use, e.g. 115200
    -a, --address <ip>            The IP (v4 or v6) address to bind to [default: 0.0.0.0]
    -p, --port <number>           The port to listen on
    -h, --help                    Print help information
    -V, --version                 Print version information

Autostart

An OpenRC script is available.

Building

You'll need a rust toolchain, a recent stable version is recommended.

In the cloned repository:

cargo build --release

Cross-building

For targetting another platform, you could manually install the required toolchain and build respectively, e.g.:

cargo build --target=arm-unknown-linux-musleabihf

An easier way, if you have Podman or Docker installed, may be using cross, e.g.:

cargo install cross
cross build --target=arm-unknown-linux-musleabihf

With Nix

With nix flakes enabled:

nix build

After execution, the resulting executable lies in result/bin/.