Reputation: 9
This is a follow-on question from a previous posting I made. I am creating Python code to query a slave module using Modbus RTU protocol. The device is the PZEM-004T, version 3 (latest), which is used to monitor AC mains voltage and current consumed by any electrical device. Ningbo - Peacefair manufactures this globally distributed device.
I am using Pymodbus v3.8.3. Pymodbus documentation and the pop-up help available through (for example) VS-Code will mention that a particular line-of-code corresponds to a particular Modbus Function Code. For example:
The slave device's datasheet says [edited with the intention of greater clarity]:
The application layer uses the Modbus-RTU protocol to communicate. At present, it only supports function codes such as • 0x03 (Read Holding Register), • 0x04 (Read Input Register), • 0x06 (Write Single Register), • 0x41 (Calibration; for use by the manufacturer), • 0x42 (Reset the memory held at the measurements-results-registry-bits, these being at memory location 0x0005 (LSB; 16 bits total) and at 0x0006 (HSB; 16 bits total)
So far, I have been able to discover Pymodbus master-to-slave commands for 0x04 and 0x06 (and others) but..... 0x41 and 0x42 Modbus-function-codes don't have an obvious Pymodbus equivalent.
Being new to both Modbus and Pymodbus (and Python, generally), I am probably looking in the wrong place, or for the wrong keywords, etc etc.
Upvotes: 0
Views: 36
Reputation: 1122
pymodbus doesn't have a method for communicating with these function codes. (are they manufacturer specific?)
You can implement your own messages by inheriting ModbusPDU
, see examples/custom_msg.py in the pymodbus codebase.
Upvotes: 0