pymodbus-dev / pymodbus

A full modbus protocol written in python
Other
2.16k stars 889 forks source link

Pymodbus StartAsyncSerialServer serves only 1 result from datastore even when many are requested #2115

Closed kusiyana closed 3 months ago

kusiyana commented 3 months ago

When I run the server_updating example it completes correctly, giving me the following parameters set in the updating_task method:

 fc_as_hex = 3
 slave_id = 0x01
 address = 0x10
 count = 6

I get the following output:

2024-03-22 08:36:51,401 INFO logging:97 Server listening. updating_task: started: initialised values: [0, 0, 0, 0, 0, 0] at address 16 updating_task: incremented values: [1, 1, 1, 1, 1, 1] at address 16 updating_task: incremented values: [2, 2, 2, 2, 2, 2] at address 16 updating_task: incremented values: [3, 3, 3, 3, 3, 3] at address 16 updating_task: incremented values: [4, 4, 4, 4, 4, 4] at address 16 updating_task: incremented values: [5, 5, 5, 5, 5, 5] at address 16 ... However, when I attempt to query the above server modbus addresses with a simple client over an RS485-USB connection:

from pymodbus.client import ModbusSerialClient

port = '/dev/tty.usbserial-AB0M9JMN'. 
master = ModbusSerialClient(port=port, baudrate=9600)
master.connect()
result = master.read_holding_registers( 0x10, 6, slave=0x01)
print(result.registers)

I can only ever get 1 reading from the slave, for example:

[2]

when I was expecting to get: [2, 2, 2, 2, 2, 2]

(ie only 1 address is found to populated when there should be 6.)

Is there something wrong with the setup of the slave addresses in the example script? If so, how can I set it up so that the master will find all 6 when it looks for them?

If not, then I imagine this is a bug?

Versions

Pymodbus Specific

janiversen commented 3 months ago

Please add the pymodbus debug log on the server so we can see what actually happens.

We have not looked at that example in a long time, mostly because the simulator does a better job.