Serial multiplexer for Arduino

https://img.shields.io/github/last-commit/jfjlaros/serialMux.svg https://github.com/jfjlaros/serialMux/actions/workflows/arduino-package.yml/badge.svg https://readthedocs.org/projects/serialmux/badge/?version=latest https://img.shields.io/github/release-date/jfjlaros/serialMux.svg https://img.shields.io/github/release/jfjlaros/serialMux.svg https://www.ardu-badge.com/badge/serialMux.svg https://img.shields.io/github/languages/code-size/jfjlaros/serialMux.svg https://img.shields.io/github/languages/count/jfjlaros/serialMux.svg https://img.shields.io/github/languages/top/jfjlaros/serialMux.svg https://img.shields.io/github/license/jfjlaros/serialMux.svg

This library provides a simple way to create multiple virtual serial devices that communicate over one physical serial connection. A virtual device can be used as a drop-in replacement for Stream like objects such as Serial.

A service is needed on the host for multiplexing and demultiplexing and to create virtual ports. A Python client for Linux is provided as a reference implementation.

Please see ReadTheDocs for the latest documentation.

Quick start

Create multiple virtual serial devices and use them like the standard Serial object.

#include <serialMux.h>

SerialMux mux(Serial);
VSerial serialA(mux);
VSerial serialB(mux);

void setup() {
  Serial.begin(9600);
}

void loop() {
  serialA.println("Virtual device A.");
  serialB.println("Virtual device B.");
  delay(1000);
}

On the host, two virtual ports are created, e.g., /dev/pts/8 and /dev/pts/9. When we connect to one of these ports, we only see the messages that are sent to that port.

$ picocom -q /dev/pts/8
Virtual device A.
Virtual device A.