Create virtual serial ports, connect them to physical serial ports, and create routes between them all.

Overview

Virtual Serial Port Router (vsp-router)

Build status Crates.io

Create virtual serial ports, connect them to physical serial ports, and create routes between them all.

vsp-router was created to connect two terminal emulators to the same physical RS-232 serial console.

asciicast

Use Cases

Multiplex two virutal serial ports to a single physical serial port.

vsp-router \
    --virtual 0 \
    --virtual 1 \
    --physical 2:/dev/ttyUSB0 \
    --route 0:2 \
    --route 1:2 \
    --route 2:0 \
    --route 2:1

Multiplex two virutal serial ports to a third virtual serial port.

vsp-router \
    --virtual 0 \
    --virtual 1 \
    --virtual 2 \
    --route 0:2 \
    --route 1:2 \
    --route 2:0 \
    --route 2:1

Example

In terminal A

cargo run -- \
    --virtual 0 \
    --virtual 1 \
    --virtual 2 \
    --route 0:2 \
    --route 1:2 \
    --route 2:0 \
    --route 2:1

In terminal 0

picocom 0

In terminal 1

picocom 1

In terminal 2

picocom 2

Characters entered in terminal 0 will be sent to terminal 2 only. Characters entered in terminal 1 will be sent to terminal 2 only. Characters entered in terminal 2 will be sent to both terminals 0 and 1.

Comparison to TTYBUS

vsp-router is similar to TTYBUS.

The key differences is in how data is written. TTYBUS broadcasts data to all ports. vsp-router routes data to select ports.

The following 3-port configurations are the equivalent.

TTYBUS

tty_bus -d -s bus
tty_fake -d -s bus 0
tty_fake -d -s bus 1
tty_fake -d -s bus 2

vsp-router

vsp-router \
    --virtual 0 \
    --virtual 1 \
    --virtual 2 \
    --route 0:1 \
    --route 0:2 \
    --route 1:0 \
    --route 1:2 \
    --route 2:0 \
    --route 2:1

Comparison to socat

Socat establishes a bidirectional channel between two end points. Vsp-router establishes a multi-directional channel between N end points. Socat supports several different types of end points. Vsp-router supports two: virtual serial ports and physical serial ports.

Vsp-router could be combined with socat to enable interesting use cases. For example, vsp-router could be used to snoop a physical serial port and paired with socat to send the snooped data over UDP.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

You might also like...
🖥 Simple Arduino Serial Monitor

Born out of the desire to connect to an Arduino without having to run the whole Arduino suite.

Log defmt messages over the serial port.
Log defmt messages over the serial port.

defmt-serial A defmt target for logging over a serial port. Messages can e.g. be read using socat and passed through defmt-print, see example-artemis

Rust wrapping serial communication with ōRouter

orouter-serial (ōRouter serial protocol) This crate provides typed messages used for serial communication between host and oRouter. It also contains c

Detect if code is running inside a virtual machine (x86 and x86-64 only).

inside-vm Detect if code is running inside a virtual machine. Only works on x86 and x86-64. How does it work Measure average cpu cycles when calling c

A framework for iterating over collections of types implementing a trait without virtual dispatch
A framework for iterating over collections of types implementing a trait without virtual dispatch

zero_v Zero_V is an experiment in defining behavior over collections of objects implementing some trait without dynamic polymorphism.

A lean, minimal, and stable set of types for color interoperation between crates in Rust.

This library provides a lean, minimal, and stable set of types for color interoperation between crates in Rust. Its goal is to serve the same function that mint provides for (linear algebra) math types.

Easy switch between AWS Profiles and Regions
Easy switch between AWS Profiles and Regions

AWSP - CLI To Manage your AWS Profiles! AWSP provides an interactive terminal to interact with your AWS Profiles. The aim of this project is to make i

This crate bridges between gstreamer and tracing ecosystems.

This crate provides a bridge between gstreamer and the tracing ecosystem. The goal is to allow Rust applications utilizing GStreamer to better integra

Simple interoperability between C++ coroutines and asynchronous Rust

cxx-async Overview cxx-async is a Rust crate that extends the cxx library to provide seamless interoperability between asynchronous Rust code using as

Comments
  • Question: Macos compatibility

    Question: Macos compatibility

    Hello guys, I was wondering if this is able to compile and run on OSX, I noticed that Apple changed the way IO is managed in the OS with DriverKit and I was wondering if the ports are created as real virtual devices

    opened by beckmx 1
  • Resources

    Resources

    See nix::pty::posix_openpt()

    socat pty source: https://github.com/3ndG4me/socat/blob/3f33a20e3556558c459ece8582d8ef4a7e9f1fb2/xio-pty.c

    socat docs: http://www.dest-unreach.org/socat/doc/socat.html

    A blog post on using posix_openpt: https://www.uninformativ.de/blog/postings/2018-02-24/0/POSTING-en.html

    Which suggests openpty is better.

    Gnu docs on ptys https://www.gnu.org/software/libc/manual/html_node/Pseudo_002dTerminals.html

    opened by rfdonnelly 1
Releases(v0.2.0)
  • v0.2.0(Oct 29, 2022)

    Changed

    • Upgraded from clap v3 to clap v4
    • Replaced tokio::select! + tokio_util::sync::CancellationToken with futures_util::future::Abortable
    Source code(tar.gz)
    Source code(zip)
Owner
Rob Donnelly
Rob Donnelly
Strongly typed routes for Rust

routetype This repository is a work in progress, experimental exploration of strongly typed routing in Rust. It follows my previous work with Yesod in

Michael Snoyman 32 Jul 22, 2022
A nushell plugin for scanning ports on a target.

nu_plugin_port_scan A nushell plugin for scanning ports on a target Similar to nc -vz {ip} {port} -w {timeout} the parameters are mapped to port scan

Motalleb Fallahnezhad 4 Nov 9, 2023
Generate enum from a trait, with converters between them

Derive macro for Rust that turns traits into enums, providing tools for calling funtions over channels

Vitaly Shukela 16 Nov 3, 2022
Bongo Copy Cat wants to be involved in everything you do but instead just imitates you hitting your keyboard all day. After all it's just a cat.

Bongo Copy Cat Introduction Bongo Copy Cat wants to be involved in everything you do but instead just imitates you hitting your keyboard all day. Afte

Abhijeet Singh 4 Jan 23, 2023
1️⃣ el lisp number uno - one lisp to rule them all 🏆

luno el lisp number uno luno is the one lisp to rule them all. Still experimental, do not use it in production yet. goals embeddable small size simple

Eva Pace 3 Apr 25, 2022
One copy of Electron to rule them all.

chroma One copy of Electron to rule them all. chroma keeps a central, up-to-date version of Electron, and makes all your installed Electron apps use i

Gergő Móricz 12 Mar 20, 2023
Code for connecting an RP2040 to a Bosch BNO055 IMU and having the realtime orientation data be sent to the host machine via serial USB

Code for connecting an RP2040 (via Raspberry Pi Pico) to a Bosch BNO055 IMU (via an Adafruit breakout board) and having the realtime orientation data be sent to the host machine via serial USB.

Gerald Nash 3 Nov 4, 2022
A cross-platform serial port library in Rust. Provides a blocking I/O interface and port enumeration including USB device information.

Note: This is a fork of the original serialport-rs project on GitLab. Please note there have been some changes to both the supported targets and which

Serialport 128 Jan 4, 2023
Postgres proxy which allows tools that don't natively supports IAM auth to connect to AWS RDS instances.

rds-iamauth-proxy rds-proxy lets you make use of IAM-based authentication to AWS RDS instances from tools that don't natively support that method of a

Gold Fig Labs Inc. 10 Nov 7, 2022
A cross-platform serial port library in Rust.

Introduction serialport-rs is a general-purpose cross-platform serial port library for Rust. It provides a blocking I/O interface and port enumeration

Bryant Mairs 143 Nov 5, 2021