Skip to content

soldatov-s/go-modbus

Repository files navigation

GoDoc Build Status Coverage Status codebeat badge License

go-modbus

About

Modbus protocol framework

Supported

  1. Modbus RTU over TCP
  2. Modbus Slave mode (Modbus Server)
  3. Modbus Master mode (Modbus Client)
  4. Rest server for read/write Modbus Data
  5. gRPC service (Server/Client)
  6. Dump Modbus packets
  7. 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)

Installation

go get github.com/soldatov-s/go-modbus

Next, build and run the examples:

Rest Server

  • /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

More documentation about Modbus is available on the

Releases

No releases published

Packages

No packages published

Languages