MCPcopy Index your code
hub / github.com/RoanBrand/SerialToTCPBridgeProtocol

github.com/RoanBrand/SerialToTCPBridgeProtocol @0.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.0.1 ↗ · + Follow
56 symbols 131 edges 7 files 26 documented · 46%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Serial to TCP Bridge Protocol

An error tolerant serial UART to TCP connection, raw data bridge.

See Documentation

Description

TCP Connections over Serial.
Useful to connect microcontrollers on development boards like the Arduino Uno to servers, just through the Serial port over USB, without requiring any Ethernet/Wi-Fi hardware.
Meant to bridge the gap between TCP connections to servers and simple serial devices using UART/RS-232/Serial-over-USB, etc.

Host side gateway service written in Go that listens on Serial ports for clients.
Clients implementing the protocol client have a TCP-like API that they can use to make connections to real servers, without networking hardware.
The goal of the project is to have the means to connect the simplest and cheapest devices to the internet, albeit indirectly.

Included in this repo is an implementation of the Protocol Gateway and Client, written in Go. They work on Windows, Linux, Raspberry Pi OS.
The following clients are also available:

Client Platform Language
ArduinoSerialToTCPBridgeClient Arduino C++
STM32SerialToTCPBridgeClient STM32 C

Get and Run

  • Check the releases page for the latest built binaries.
  • Get and configure config.json. The serial port in Linux for the Arduino Uno is something like /dev/ttyACM0.

Development and Building

  • Install Go for your system.
  • Clone this repository.
  • Edit your local config.json and set it according to your Serial port configuration.
  • Debug example.go in your IDE, or run go run example.go or go build for a binary.

Details

  • The protocol provides the app an in order, duplicates free and error checked byte stream by adding a CRC32 and simple retry mechanism. See this for background.
  • The Protocol Gateway opens a real TCP connection to a set destination on behalf of the Protocol Client.
  • The Protocol Client connects to the Protocol Gateway over a serial-like connection, which can possibly corrupt data.
  • The client specifies the destination IPv4 address and port.
  • The gateway forwards traffic bi-directionally, as long as tcp connection is open and serial line is good.

Tests

  • Open a terminal, then run go get -u github.com/RoanBrand/goBuffers.
  • In the terminal, change directory to the protocol folder inside the repository.
  • Run go test -v in the terminal.

Future plans

  • Add ping option to periodically test serial line and drop upstream connection if timeout.
  • Multiple connections per client to servers.
  • Capability to scan system and listen on all found COM ports for clients.
  • Turn into OS service.

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Write
called by 7
protocol/transport.go
Read
called by 6
protocol/transport.go
Close
called by 4
protocol/transport.go
dropLink
called by 4
protocol/gateway.go
Listen
called by 3
protocol/gateway.go
rxSerial
called by 2
protocol/transport.go
txSerial
called by 2
protocol/transport.go
serialize
called by 2
protocol/packet.go

Shape

Method 33
Function 12
Struct 10
Interface 1

Languages

Go100%

Modules by API surface

protocol/protocol_test.go14 symbols
protocol/client.go14 symbols
protocol/transport.go8 symbols
protocol/gateway.go6 symbols
protocol/packet.go5 symbols
example.go5 symbols
comwrapper/comport.go4 symbols

For agents

$ claude mcp add SerialToTCPBridgeProtocol \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact