Basic Usage =========== .. argparse:: :ref: modpoll.arg_parser.get_parser :prog: modpoll The `config` option is required. Commandline Usage ------------------ - Connect to Modbus TCP device .. code-block:: shell modpoll --tcp 192.168.1.10 --config examples/modsim.csv - Connect to Modbus serial device .. code-block:: shell modpoll --serial /dev/ttyUSB0 --serial-baud 9600 --config contrib/eniwise/scpms6.csv - Connect to Modbus TCP device and publish data to remote MQTT broker .. code-block:: shell modpoll --tcp 192.168.1.10 --config examples/modsim.csv --mqtt-host broker.emqx.io - Connect to Modbus TCP device and export data to local csv file .. code-block:: shell modpoll --tcp modsim.topmaker.net --config https://raw.githubusercontent.com/gavinying/modpoll/main/examples/modsim.csv --export data.csv Configuration File ------------------ The configuration file (`--config`) is a CSV file that defines the devices, pollers, and references to be read. For register references (i.e., Holding or Input registers) with a ``dtype`` of ``bool``, you can specify a single bit to be extracted from the 16-bit register. This is done by appending ``:bit`` to the address, where ``bit`` is an integer from 0 to 15. - ``40110``: Reads the entire 16-bit register at address 40110. - ``40110:15``: Reads the 16-bit register at address 40110, extracts bit 15, and returns a boolean value. The bit is extracted from the final 16-bit value after byte/word swapping based on the poller's endianness configuration. Framers and transports ---------------------- - Serial (`--serial`, alias `--rtu`) supports framers `rtu` and `ascii` (e.g., `--serial ... --framer ascii`). Binary framer was removed in pymodbus 3.9+. If `--framer default` is used, pymodbus defaults to RTU framer. - TCP/UDP (`--tcp`/`--udp`) use the `socket` framer; other framers are rejected. If `--framer default` is used, pymodbus defaults to socket framer. MQTT write commands with malformed payloads, invalid values, ambiguous device names, or a retained-message flag are ignored and logged. Register arrays use FC16 and support 1–123 unsigned 16-bit values. Configure the broker not to retain messages on write-command topics; the MQTT retained flag is not guaranteed to remain set during live forwarding. References that fail in a poll cycle are omitted from MQTT output and represented as ``null`` in JSON snapshots. Multiple configuration files are combined into one atomically replaced snapshot.