-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Versions
- Python: 3,8
- OS: 22.04, 20.04
- Pymodbus: 3.0,2
- Modbus Hardware (if used): Different sensors: Temperature, GPIO
Pymodbus Specific
- Server: NA
- Client: rtu - async
Description
Whenever there is an issue with the sensor (power loss, wiring problem) the AsyncModbusSerialClient always times out after 3.0s, despite that during the client instantiation we set a timeout with a different value.
What were you trying, what has happened, what went wrong, and what did you expect?
It can be easily repeated: just disconnect the 485 (modbus) connection cables from the peripheral and timeout raises after 3.0s
I had already reported this issue 6 weeks ago: timeout issue
GraciousGpal pointed out that this issue was also present in AsyncModbusTCPClient(). He worked out a solution that when I apply to AsyncModbusSerialClient() works too,
It seemed, though, that his comment lead to fix the same issue for AyncModbusTCPClient(), but it was not applied to AsyncSerialModbusClient)()
Code and Logs
# code and logs here.
# please use the following to format logs when posting them here
import pymodbus
pymodbus.pymodbus_apply_logging_config()
...
client = AsyncModbusSerialClient(port=self.commPort, baudrate=self.commSpeed, timeout=self.commTimeout)
await client.connect()
self.client = client
# Fix timeout issue. Otherwise it takes default 3.0s
self.client.protocol.params.timeout = self.commTimeout
self.client.protocol.transaction.client.params.timeout = self.commTimeout
...