1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# gateway.toml — Example configuration for modbus-gateway
# Run with: modbus-gateway run --config gateway.toml
[]
= "info" # trace | debug | info | warn | error
= true # false → headless mode, structured logs to stderr
# ── Optional traffic capture ────────────────────────────────────────────────
[]
= true
= "./traffic.pcap"
[]
= true
= "./traffic.csv"
# ── Upstream Listeners ──────────────────────────────────────────────────────
[[]]
= "tcp"
= "0.0.0.0:5020" # Bind to 5020 to avoid permission issues with low ports like 502
[[]]
= "websocket"
= "0.0.0.0:8502"
= 30
= 64
= true
# ── Downstream Targets ──────────────────────────────────────────────────────
# [[downstream]]
# name = "tcp-slave"
# type = "tcp"
# address = "127.0.0.1:502" # localhost 502
[[]]
= "serial-slave"
= "serial"
= "/dev/cu.usbserial-A1010CA6" # serial port /dev/cu.usbserial-A1010CA6. /dev/cu.usbmodem142203
= 115200 # <-- Match your slave's baudrate (e.g. 9600, 19200, 115200)
= 8 # <-- Match your slave's data bits (typically 8)
= "none" # <-- Match your slave's parity ("none", "even", "odd")
= 1 # <-- Match your slave's stop bits (typically 1 or 2)
= 2000 # Wait up to 2 seconds for a response
# ── Routing Rules ───────────────────────────────────────────────────────────
[[]]
= "unit"
= 1
= "serial-slave"
# [[route]]
# type = "unit"
# unit_id = 10
# downstream = "tcp-slave"