pymodbus-dev / pymodbus

A full modbus protocol written in python
Other
2.24k stars 915 forks source link

read_input_registers sends more information than needed. #120

Closed fcsds closed 8 years ago

fcsds commented 8 years ago

Hi,

I have been using pymodbus now for a couple of years in many different platforms to read out and store data from different sources into a dashboard program. Recently, I enabled one of our Allen Bradley PLCs to relay some info through ModbusTCP and notices that when I request to read a specific register, it then sends me all the enabled registers data. Here is my code for your analysis:

from pymodbus.client.sync import ModbusTcpClient as ModbusClient client = ModbusClient('xxx.xxx.xxx.xxx',502) client.connect()

Returns True

info = client.read_input_registers(0,1) info.registers

Returns 13 register values instead of one.

In my application, I store all the needed registers in a database that is queried register by register until all data is loaded. Is there a way I can get to read only one register (the one specified by read_input_registers) at a time?

Thanks for any help you can provide.

fcsds commented 8 years ago

Found out from the API that if I use: info = client.read_input_registers(0,1,unit=1) I solve my problem.