I'm having some trouble reading registers from my WAGO 750-881 PLC using pymodbus, python 2.7, and Windows. I can read just fine with the Modbus Poll utility so I think the problem is in my python code. Using the following code I get the error: runfile('C:/Users/Mike/modbustest2.py', wdir='C:/Users/Mike')
Exception Response(131, 3, IllegalValue)
from pymodbus.client.sync import ModbusTcpClient
c = ModbusTcpClient(host="192.168.1.20")
chk = c.read_holding_registers(257,10, unit = 1)
response = c.execute(chk)
print response
I realize my code should read print response.registers
but the .registers
extension doesn't seem to be available to me. print response.registers
throws this error: AttributeError: 'ExceptionResponse' object has no attribute 'registers'
I only included the print response
error because I thought it might be helpful in some way. Does anyone know what the problem may be?
You're getting an ExceptionResponse object back, with the exception code 'IllegalValue'.
The most likely cause is you're reading a register the PLC doesn't think exists.
Of course there's no registers attribute on this object because it's not a ReadHoldingRegisters response.