Open ondrej1024 opened 7 months ago
Hello @ondrej1024
Here an example https://github.com/GimmickNG/pycopy-modbus/blob/ad38bb74d2da0a4b22c518567bbee44647da7afd/examples/rtu_host_example.py#L34 where show that the default is 120 ms, and you can to change the timeout just changing the read_timeout
for a new value (in ms). It works, I'm using it, changing to 200ms, 300ms, 1000 ms in my tests.
Ps1: I don't know if that works in the last version of ModBus lib because I'm using the async version #56 that will be merged soon!
Ps2: that example that I linked still is not in the official examples because the PR #56 is not finished yet.
But I agree, it is important to put in the docs what is the default timeout for the Master RTU and how to change it. Maybe @brainelectronics can to put that information in the docs when the asyncio version is merged!
Thanks for your answer.
I had a look in serial.py
of the latest release 2.3.7 and found that class Serial()
has no parameter read_timeout
. So I guess it is not yet available and I have to wait for the merge that you mentioned to be completed.
Do you know where the default timeout is defined? I checked the source code but couldn't find it.
After some more digging, eventually I found the code which is responsible for the timeout.
It is in file serial.py
function _uart_read()
and it is determined by this loop:
# TODO: use some kind of hint or user-configurable delay
# to determine this loop counter
for x in range(1, 120):
However, the value of 120 here is not the number of ms but the number of _inter_frame_delay
which depends on the baudrate. So the default timeout actually is not 120ms but depends on the baudrate. At 9600 baud it is about 500ms.
Description
I just need an information which I couldn't find in the docs. What is the default response timeout of the RTU master and how can it be changed ?
Thanks, Ondrej
Reproduction steps
None
MicroPython version
v.1.20
MicroPython board
Raspberry Pico
MicroPython Modbus version
Relevant log output
No response
User code
No response
Additional informations
No response