Skip to content

edgecommons/modbus-adapter

Repository files navigation

EdgeCommons Modbus Adapter

The Python reference southbound protocol adapter, built on the edgecommons (edgecommons) library and the southbound contract (docs/SOUTHBOUND.md in the edgecommons monorepo). It bridges Modbus devices — TCP, serial RTU, and RTU-over-TCP — onto a message bus: it polls register maps and republishes value changes as SouthboundSignalUpdate messages on the Unified Namespace data class (ecv1/{device}/modbus-adapter/{instance}/data/{signal}), serves on-demand reads/writes/control through the library command inbox (sb/read, sb/write, sb/status, sb/signals, sb/browse, sb/pause, sb/resume, reconnect, repoll), gates writes by a per-signal writes.allow[] allow-list, emits evt-class connection/write events (through the library's data()/events() facades), and reports southbound_health plus Modbus operational metrics for connection, inventory, polling, publishing, and commands. It runs wherever you deploy it — a Greengrass v2 component, a standalone process, or a Kubernetes pod.

Sibling of the Java OPC UA reference adapter; same southbound contract, the poll-based counterpart to OPC UA's subscribe-based model.

Status

In development. See docs/ for the operator/integrator guide and validation/ for the reproducible end-to-end test harness (a pymodbus simulator + MQTT validators).

Quick start (local, against the simulator)

pip install -e . -r requirements-test.txt
python validation/modbus_sim_server.py &          # pymodbus TCP slave
python main.py --platform HOST --transport MQTT validation/messaging-local.json \
       -c FILE validation/config.json -t modbus-thing

Subscribe to ecv1/+/+/+/data/# to watch telemetry (and ecv1/+/+/+/state, ecv1/+/+/+/metric/# for the keepalive, health, and operational metrics). For local dev against the sibling edgecommons UNS library, install it editable into the venv first: pip install -e ../core/libs/python, then pip install -e . -r requirements-test.txt.

Tests

python -m pytest          # unit suite (codec / config / coalescing / commands / publisher / events),
                          # with the org 90% coverage gate (scoped to the CI-testable surface; see .coveragerc)

About

Modbus southbound adapter (Python/pymodbus) for the edgecommons ecosystem

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages