Good morning guys and thank you for this library.
I'm trying to control a machine using Modbus RTU protocol. Now I only need to read multiple holding registers. So I tried sync version of PyModbus Client and it worked.
BUT I've a problem caused by the timeout of the client. It seems that the client waits for a response that some time doesn't arrived from the machine and it returns an error.
This is my code:
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
def biomasseQuery(COMport, regIndex, numRegisters, slaveUnit):
client = ModbusClient(port=COMport,stopbits=1,bytesize=8,parity='N',baudrate=9600, method='rtu')
client.connect()
result = client.read_holding_registers(regIndex, numRegisters, unit=slaveUnit)
return result
And I recall it in the main:
...
query = biomasseQuery(COMport, reg_index, reg_numbers, SLAVEaddress)
value = query.registers[i]
...
my questions are:
1. The time elapsed between a request of the client and the next one is too long. How can I shorten this time?
2. How can I implement a check on missing responses of the machine (the execution has to go on)?
3. Could the async implementation be the solution? I could implement it? (example pleazz)
thx in advance