v1.0.0 Released
Modbus Gateway TCP to RTU Bridge
A high-performance, configurable gateway written in Go. Connect multiple Modbus TCP masters to a single Serial RTU slave without conflicts.
Architecture
Serialized concurrency control ensures bus stability.
TCP Masters
Client 1
Client 2
Client 3
TCP/IP
Gateway
Queue Buffer
Serializer
RS485
RTU Slave
/dev/ttyUSB0
Protocol Conversion
Seamless conversion between Modbus TCP and Modbus RTU.
Concurrency
Multiple TCP clients supported.
Flexible Config
CLI arguments or YAML files.
RS485 Control
Full support for RTS signal control.
Logging
Configurable levels and targets.
Auto Reconnect
Handles serial port disconnections.
Quick Start
1. Build
bash
git clone https://github.com/ffutop/modbus-gateway.git
cd modbus-gateway
go build -o modbus-gateway
2. Run
# Listen on port 5020, Device /dev/ttyUSB0
./modbus-gateway -p /dev/ttyUSB0 -s 9600 -P 5020 -v debug
Configuration
Use config.yaml for advanced settings.
# TCP Server
tcp_address: "0.0.0.0"
tcp_port: 502
max_conns: 32
# Serial/RTU
device: "/dev/ttyUSB0"
baud_rate: 19200
data_bits: 8
parity: "N"
stop_bits: 1
timeout: 500ms
# RS485
rs485:
enabled: true
delay_rts_before_send: 2ms