How simonvetter/modbus works
Project type and purpose
• This is a Go library (“Go modbus stack”) implementing the Modbus protocol.
• It provides both a client API (for master devices) and a server API (for slave devices), plus a CLI tool (modbus-cli) and example programs.
• Its goal is to let Go programs communicate with Modbus devices over serial (RTU) or network (TCP, TLS, UDP) transports.
File structure
• Top-level files:
• client.go, server.go – core client and server entrypoints
• transport.go – transport interface
• crc.go, encoding.go, tls_utils.go, logger.go – shared utilities
• *.go and *_test.go – implementation and unit tests
• cmd/modbus-cli.go – CLI application
• examples/… – runnable examples for TCP, TLS, serial
• Transport implementations:
• tcp_transport.go, tls_utils.go, udp.go, rtu_transport.go, serial.go
• Build and dependency files: go.mod, go.sum
• No database or persistent storage – stateless protocol library.
README for additional insights
• Describes supported Modbus variants (RTU, TCP, TLS, UDP, tunneled RTU).
• Shows how to instantiate a client with a URL-based configuration and how to open/close connections.
• Calls out use of goburrow/serial for serial port access.
• Mentions logging via standard log.Logger.