0

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)
  • You will have to use the offset and not the absolute address , so in this case you will have to use 4 instead of 30005. Please also note that the address you are using looks to be of input_register and you probably will have to use `client.read_input_registers` instead of `client.read_holding_registers`. please share the debug logs and specs for the device if this doesn't workout – Sanju Oct 08 '19 at 05:30
  • @Sanju thank you for the response, I have 2 Cluster Controllers, for the second one i don't have problems to retrieve data and was how you said (with the read_input_registers instead of holding), for the another the first one I get a Broken Pipe error in the debug – Sebastián Olhaberry Oct 14 '19 at 13:20
  • Broken pipe happens when the server is closing the connection on its side . – Sanju Oct 15 '19 at 01:21
  • Do you have the modbus interface enabled on the web interface of the cluster controller? – Pipo Apr 23 '20 at 00:10

0 Answers0