ljean / modbus-tk

Create Modbus app easily with Python
Other
566 stars 212 forks source link

Reading Signed Values #101

Closed deepak5g closed 6 years ago

deepak5g commented 6 years ago

Hello,

I am trying to read the signed values,

This is my step for reading the data, help me in reading the signed values

master =  modbus_tcp.TcpMaster("CC.XXX.20.242", 4161, 10.0)
master.execute(1, cst.READ_HOLDING_REGISTERS, 36352, 68)

Thanks in advance, Deepak

ljean commented 6 years ago

You can try to set a custom data format. Something like this should work

quantity = 68
data_format = ">" + (quantity * "h")
master.execute(1, cst.READ_HOLDING_REGISTERS, 36352, quantity, data_format=data_format)