0

I have written the following little block of code:

from pymodbus.client.sync import ModbuTcpClient

def test(client):
   client.connect()
   print client.read_holding_registers(10, 1, unit=10)
   client.close()

test(client)

.

The output I get from print is:

ReadRegisterResponse (1)

.

Why am I getting this and not the actual value (integer/string) the register is holding?

Thanks for the answers!

2 Answers2

0

You asked for 1 register at address 10 and got a response that says the value at address 10 is 1. What were you expecting to be different?

Kevin Herron
  • 6,500
  • 3
  • 26
  • 35
  • nope, it is not the value which is held there. this is only a response that shows that the message was accepted. – jurnerea121 May 17 '15 at 11:46
0

#For me this solution was enough hope it helps

res = client.read_holding_registers(address=10,count=1, unit=10)
print res.encode()    
print res.registers
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 23 '22 at 00:49