Trouble reading from PLC with pymodbus
<p>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: <code>runfile('C:/Users/Mike/modbustest2.py', wdir='C:/Users/Mike')
Exception Response(131, 3, IllegalValue)</code></p>

<pre><code>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
</code></pre>

<p>I realize my code should read <code>print response.registers</code> but the <code>.registers</code> extension doesn't seem to be available to me. <code>print response.registers</code> throws this error: <code>AttributeError: 'ExceptionResponse' object has no attribute 'registers'</code> I only included the <code>print response</code> error because I thought it might be helpful in some way. Does anyone know what the problem may be? </p>

<p>You're getting an ExceptionResponse object back, with the exception code 'IllegalValue'.</p>

<p>The most likely cause is you're reading a register the PLC doesn't think exists.</p>

<p>Of course there's no registers attribute on this object because it's not a ReadHoldingRegisters response.</p>

python python-2.7 modbus plc modbus-tcp