I am new to modbus comunication, i have to read from an inverter a single value from one register using modbus protocol (i use python with pymodbus for this): From the inverter documentation i read about register documentation:
Register ADR: 31249 Description: Active power of system at PCC (W) CNT: 2 Type: S32 Format: FIX0 Access: RO
Well, i try my python script like this:
from pymodbus.client.sync import ModbusTcpClient
client = ModbusTcpClient("192.168.1.10", port=502, timeout=3)
client.connect()
read=client.read_holding_registers(address = 31249 ,count =2,unit=1)
read.registers
So i have this value:
[65535, 65535]
I guess that are not the decoded values of the register, so i try to decode for extract value:
read_encoded = read.encode()
read_encoded
b'\xff\xff\xff\xff'
read_encoded_value = int.from_bytes(read_encoded, byteorder="big")
read_encoded_value
So if i print my variable i get:
4294967295
it mean a little big as a value. Is the procedure correct for read and decode my modbus registers value?
How can i extract and read data starting from modbus registers doc of my inverter?
So many thanks in advance