Skip to main content

serial_bridge

Relay a physical COM/serial port over TCP to 1–N remote machines.

One machine runs in server mode and holds the physical port. Every other machine runs in client mode and gets two local virtual transports it can use like any normal serial device:

Transport Platform Access
PTY (/dev/pts/X) Unix any program — pyserial, minicom, screen, etc.
pySerialMux virtual interface Unix + Windows pySerialMux.Serial(...)

All machines see the same data. Writes from any machine go to the physical serial port and are re-broadcast to all other connected machines.

Requirements

  • Python 3.10+
  • pySerialMux >= 0.2.1
  • pyserial >= 3.5
pip install -r requirements.txt

Quickstart

Machine A — has the physical port:

python -m serial_bridge server --port /dev/ttyUSB0 --baud 115200

Machine B, C, … — remote machines:

python -m serial_bridge client --host <machine-a-ip>

Client output:

Serial bridge connected to 192.168.1.10:5000 (port=/dev/ttyUSB0, baud=115200)
  PTY:          /dev/pts/4
  pySerialMux:  Serial("serial-bridge", virtual_interface="bus")
Press Ctrl-C to stop.

Using the virtual port

PTY (Unix — any program)

Use the printed path directly:

minicom -D /dev/pts/4
screen /dev/pts/4 115200

Or with plain pyserial:

import serial
ser = serial.Serial("/dev/pts/4")
ser.write(b"hello\n")
print(ser.readline())

pySerialMux virtual interface (Unix + Windows)

from pySerialMux import Serial

ser = Serial("serial-bridge", virtual_interface="bus", client_id="my-app")
ser.write(b"hello\n")
print(ser.readline())

Multiple local processes on the same remote machine can all connect simultaneously — pySerialMux handles the local multiplexing automatically.

CLI reference

Server

python -m serial_bridge server --port PORT [options]

  --port PORT          Serial port path (e.g. /dev/ttyUSB0 or COM3)  [required]
  --baud BAUD          Baud rate (default: 115200)
  --tcp-port TCP_PORT  TCP port to listen on (default: 5000)
  --bind ADDR          Bind address (default: 0.0.0.0)

Client

python -m serial_bridge client --host HOST [options]

  --host HOST               BridgeServer IP or hostname  [required]
  --tcp-port TCP_PORT       TCP port of the server (default: 5000)
  --client-id ID            Optional identifier for this machine
  --virtual-port NAME       pySerialMux broker name (default: serial-bridge)
  --virtual-interface NAME  pySerialMux interface name (default: bus)

Python API

from serial_bridge import BridgeServer, BridgeClient
import threading

# Server
server = BridgeServer(port="/dev/ttyUSB0", baud=115200, tcp_port=5000)
threading.Thread(target=server.start, daemon=True).start()
# ...
server.stop()

# Client
client = BridgeClient(host="192.168.1.10", tcp_port=5000)
descriptions = client.connect()   # returns list of transport description strings
client._launch_threads()
# serial port is now live — use PTY path or pySerialMux virtual interface
# ...
client.stop()

Architecture

Machine A  ┌─────────────────────────────────────────┐
           │  BridgeServer                           │
           │    pySerialMux.Serial(/dev/ttyUSB0)     │
           │         ↕                               │
           │    TCP server :5000                     │
           └──────────────┬──────────────────────────┘
                          │ TCP
          ┌───────────────┴───────────────┐
          │                               │
Machine B ▼                     Machine C ▼
  BridgeClient                    BridgeClient
    ├── PTY /dev/pts/4               ├── PTY /dev/pts/7
    └── pySerialMux                  └── pySerialMux
         Serial("serial-bridge",          Serial("serial-bridge",
           virtual_interface="bus")         virtual_interface="bus")

Data written by any machine reaches the physical serial port and is re-broadcast to all other connected machines.

Wire protocol

Simple framing over raw TCP — same 5-byte header layout used by pySerialMux internally:

[1 byte type][4 bytes payload length, big-endian][payload]
Type Direction Payload
DATA both raw binary serial bytes
CONFIG client → server JSON {"client_id": "..."}
ACK server → client JSON {"port": "...", "baud": ...}
ERROR server → client error string; connection closes
CLOSE either empty; graceful disconnect

Notes

  • No authentication or TLS. Intended for trusted local networks. Wrap with an SSH tunnel or VPN for remote access over untrusted networks.
  • Windows clients get the pySerialMux virtual interface only (no PTY). The pySerialMux broker uses localhost TCP internally, so no Unix sockets are required.
  • The server uses pySerialMux.Serial to access the physical port, so multiple local processes on the server machine can also share it simultaneously via normal pySerialMux.Serial usage.

Release files for serial-bridge 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for serial-bridge 0.2.1
File Size Uploaded
serial_bridge-0.2.1.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for serial-bridge 0.2.1
File Interpreter ABI Platform
serial_bridge-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.5 kB

Release files / serial_bridge-0.2.1.tar.gz

Download URL serial_bridge-0.2.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5fa90ada481d0192aa37d4bd050952ae223cd7cf3e53b92c43726505c6b88d55
BLAKE2b-256 checksum
How to use checksums
1ff602fd3ccdc56cf47c08bf9ae898f37481db28c8558fc2959f1a9aa00454c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 18, 2026.

Transparency log

Release files / serial_bridge-0.2.1-py3-none-any.whl

Download URL serial_bridge-0.2.1-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
930bcc310d8f4c02d67d29fcd378bac97ea2514fbb0839f7a00d23379c6d9cbd
BLAKE2b-256 checksum
How to use checksums
35e091bc7d6919bf4ef242a6ba97a4739487f83ef6d07c6d5e8f9b6e31ccc9d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page