Skip to content

jfjlaros/serialMux

Repository files navigation

Serial multiplexer for Arduino

https://readthedocs.org/projects/serialmux/badge/?version=latest

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.