Modbus protocol framework
- Modbus RTU over TCP
- Modbus Slave mode (Modbus Server)
- Modbus Master mode (Modbus Client)
- Rest server for read/write Modbus Data
- gRPC service (Server/Client)
- Dump Modbus packets
- Function:
- Read Coil Status (0x1)
- Read Discrete Inputs (0x2)
- Read Holding Registers (0x3)
- Read Input Registers (0x4)
- Force Single Coil (0x5)
- Preset Single Register (0x6)
- Force Multiple Coils (0xF)
- Preset Multiple Registers (0x10)
go get github.com/soldatov-s/go-modbus
Next, build and run the examples:
- mb-server.go for an Modbus RTU over TCP server example
- mb-client.go for an Modbus RTU over TCP client example
- /coils - Coils (GET and PUT)
- /d_in - Discrete Inputs (only GET)
- /hold_reg - Holding Registers (GET and PUT)
- /in_reg - Input Registers (only GET)
Example Read Holding Registers:
curl -X GET -i 'http://localhost:8000/hold_reg?addr=0&cnt=5'
Example Write Holding Registers:
curl -X POST -i http://localhost:8000/hold_reg --data '{
"addr": 0,
"data": [77, 11]
}'
More documentation about Modbus is available on the