ModbusDriver
ModbusDriver is the Modbus transport that register-mapped instrument drivers sit on top of. It is a public part of the library so customers can build their own drivers for Modbus-attached instruments (temperature and process controllers, meters, PLCs) without wrapping pymodbus themselves.
It is intentionally narrow: it opens, closes, and locks a Modbus TCP or RTU connection and exposes raw function-code I/O plus typed register encode and decode. The caller owns the register map (which address holds what).
Modbus is a register-and-coil protocol. A driver reads and writes numbered 16-bit registers and single-bit coils by address; there is no self-describing command set.
ModbusDriver uses pymodbus under the hood and supports both Modbus TCP and Modbus RTU (serial).When to reach for it
ModbusDriver is the right starting point when any of the following are true:
For a config-driven device where the register map lives in a JSON file rather than driver code, use
ModbusDevice instead. ModbusDevice composes ModbusDriver and adds semantic access by register alias, scaling, validation, and background polling.
Quickstart
The most common use ofModbusDriver is as a transport inside an instrument driver. Here it is on its own, talking to a Modbus TCP device directly:
RTUConnection for serial devices:
Atomic multi-step sequences
ModbusDriver serializes every op behind an internal reentrant lock, so a background poller and user code can share one connection safely. Hold the lock across several ops to keep them atomic (for example, select a page or bank register, then read from it):