-
Notifications
You must be signed in to change notification settings - Fork 149
Open
Description
When enabling debug mode and letting a write command run into a timeout, the displayed roundtrip time is displayed in ms but is not converted from the internal value stored in s. So the shown roundtrip time is 1000 times smaller as it actually was.
Code:
ser = serial.Serial(
PORT, BAUDRATE, BYTESIZE, PARITY, stopbits=STOPBITS
)
dev = minimalmodbus.Instrument(ser, ADDRESS, debug=True)
dev.serial.timeout = X
dev.write_register(..., ...)
Output:
MinimalModbus debug mode. Will write to instrument (expecting 8 bytes back): ... (x bytes)
MinimalModbus debug mode. Clearing serial buffers for port ...
MinimalModbus debug mode. Sleeping 0.87 ms before sending. Minimum silent period: 1.75 ms, time since read: 0.88 ms.
MinimalModbus debug mode. Response from instrument: 10 90 04 1D C6 (5 bytes), roundtrip time: X ms. Timeout for reading: 200.0 ms.
Solution:
minimalmodbus/minimalmodbus.py
Lines 1510 to 1517 in 785262d
text = ( | |
"Response from instrument: {}, roundtrip time: {:.1f} ms." | |
" Timeout for reading: {:.1f} ms.\n" | |
).format( | |
_describe_bytes(answer), | |
roundtrip_time, | |
timeout_time, | |
) |
Change
roundtrip_time
to: roundtrip_time * _SECONDS_TO_MILLISECONDS
Metadata
Metadata
Assignees
Labels
No labels