Relay a physical serial port to N remote machines over TCP
Project description
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.1pyserial >= 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.Serialto access the physical port, so multiple local processes on the server machine can also share it simultaneously via normalpySerialMux.Serialusage.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file serial_bridge-0.1.0.tar.gz.
File metadata
- Download URL: serial_bridge-0.1.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5562a6611c64c500b0d6a985db8b1666341efa1292adb74b880cc8fbc0dd4f0d
|
|
| MD5 |
3f7fcb1d9133990513be1513d12fe0f9
|
|
| BLAKE2b-256 |
f9873206e7a1859a567435914156d03ed7be747665e16897350e425893dfdfdd
|
Provenance
The following attestation bundles were made for serial_bridge-0.1.0.tar.gz:
Publisher:
release.yml on KilianSen/SerialBridges
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
serial_bridge-0.1.0.tar.gz -
Subject digest:
5562a6611c64c500b0d6a985db8b1666341efa1292adb74b880cc8fbc0dd4f0d - Sigstore transparency entry: 1566614754
- Sigstore integration time:
-
Permalink:
KilianSen/SerialBridges@b6be1b0e2adf50af42e22c2deaaedaef7d8e9cd8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KilianSen
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b6be1b0e2adf50af42e22c2deaaedaef7d8e9cd8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file serial_bridge-0.1.0-py3-none-any.whl.
File metadata
- Download URL: serial_bridge-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75a67b71f90771463dab8c23ff3c67c763c7aafcac93818c59dd90c54fd0e1d5
|
|
| MD5 |
cb5646344dac6ac0d14f5f4392a5a7a5
|
|
| BLAKE2b-256 |
910e7f02841092d1b178417374340856f201929490cb3c64ab67df5fbf1db364
|
Provenance
The following attestation bundles were made for serial_bridge-0.1.0-py3-none-any.whl:
Publisher:
release.yml on KilianSen/SerialBridges
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
serial_bridge-0.1.0-py3-none-any.whl -
Subject digest:
75a67b71f90771463dab8c23ff3c67c763c7aafcac93818c59dd90c54fd0e1d5 - Sigstore transparency entry: 1566614760
- Sigstore integration time:
-
Permalink:
KilianSen/SerialBridges@b6be1b0e2adf50af42e22c2deaaedaef7d8e9cd8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/KilianSen
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b6be1b0e2adf50af42e22c2deaaedaef7d8e9cd8 -
Trigger Event:
push
-
Statement type: