github.com/simpleiot/simpleiot@v0.18.3/modbus/README.md (about) 1 # Simple IoT Modbus 2 3 This Simple IoT modbus packet is a package that implements both Modbus (RTU & 4 TCP) client and server functionality. 5 6 See [this test](./rtu-end-to-end_test.go) for an example of how to use this 7 library. Substitute the wire simulator with real serial ports. There are also 8 standalone 9 [client](https://github.com/simpleiot/simpleiot/blob/master/cmd/modbus-client/main.go) 10 and 11 [server](https://github.com/simpleiot/simpleiot/blob/master/cmd/modbus-server/main.go) 12 examples. 13 14 ## Why? 15 16 - really want to be able to pass in my own io.ReadWriter into these libs. New 17 and better serial libs are continually coming out, and it seems that 18 hardcoding serial operations in the modbus lib makes this brittle. 19 - allows use of https://pkg.go.dev/github.com/simpleiot/simpleiot/respreader to 20 do packet framing. This may not be the most efficient, but is super easy and 21 eliminates the need to parse packets as they come in. 22 - passing in io.ReadWriter allows us to easily unit test end to end 23 communication (see end-to-end test above) 24 - library in constructed in a modular fashion from lowest units (PDU) on up, so 25 it is easy to test 26 - not satisfied with the mbserver way of hooking in register operations. Seems 27 over complicated, and unfinished. 28 - want one library for both client/server. This is necessary to test everything, 29 and there is no big reason not to do this. 30 - need a library that is maintained, accepts PRs, etc. 31 - could not find any good tools for testing modbus (client or server). Most are 32 old apps for windows (I use Linux) and are difficult to use. After messing 33 around too long in a windows VM, I decided its time for a decent command line 34 app that does this. Seems like there should be a simple command line tool that 35 can be made to do this and run on any OS (Go is perfect for building this type 36 of thing).