I am trying to get data from a SMA Cluster Controller using pymodbus, but I don't get any response. In example, the documentation says that request in address 30005 with 2 registers and to the unit 1 I'll get the Serial Number for the Cluster Controller, I'm getting the following:
'ModbusIOException' object has no attribute 'registers'
The code i'm using:
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
from pymodbus.constants import Endian
from pymodbus.payload import BinaryPayloadDecoder as Decoder
import time
client = ModbusClient('192.168.8.103', port=502)
try:
c=client.connect()
print(c)
while c:
result = client.read_holding_registers(30005, 2, unit=1)
print(result.registers)
decoder = BinaryPayloadDecoder.fromRegisters(result.registers, wordorder=Endian.Big, byteorder=Endain.Big)
value = decoder.decode_64bit_uint()
time.sleep(5)
except Exception as e:
print(e)