https://github.com/soldatov-s/go-modbus
Modbus protocol framework
https://github.com/soldatov-s/go-modbus
go golang grpc-go modbus modbus-tcp rest-api
Last synced: 5 months ago
JSON representation
Modbus protocol framework
- Host: GitHub
- URL: https://github.com/soldatov-s/go-modbus
- Owner: soldatov-s
- License: apache-2.0
- Created: 2019-03-11T19:43:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-01T20:14:09.000Z (about 7 years ago)
- Last Synced: 2025-08-14T03:28:01.622Z (10 months ago)
- Topics: go, golang, grpc-go, modbus, modbus-tcp, rest-api
- Language: Go
- Size: 2.13 MB
- Stars: 2
- Watchers: 0
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://godoc.org/github.com/soldatov-s/go-modbus)
[](https://travis-ci.org/soldatov-s/go-modbus)
[](http://codecov.io/github/soldatov-s/go-modbus?branch=master)
[](https://codebeat.co/projects/github-com-soldatov-s-go-modbus-master)
[](https://opensource.org/licenses/Apache-2.0)
# 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
```sh
go get github.com/soldatov-s/go-modbus
```
Next, build and run the examples:
* [mb-server.go](mb-server/mb-server.go) for an Modbus RTU over TCP server example
* [mb-client.go](mb-client/mb-client.go) for an Modbus RTU over TCP client example
## 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:
```sh
curl -X GET -i 'http://localhost:8000/hold_reg?addr=0&cnt=5'
```
Example Write Holding Registers:
```sh
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
- [Wiki](https://en.wikipedia.org/wiki/Modbus)
- [Modbus Technical Specifications](http://www.modbus.org/specs.php)