Temporary Modbus Client "Soft Lock" #79518
Labels
area: modbus
bug
The issue is a bug, or the PR is fixing a bug
priority: low
Low impact/importance bug
Stale
Describe the bug
Using the modbus subsystem, a response returned after a request times out would increment the semaphore and stay until the next request is made which will immediately return when k_sem_take is called even before a response is returned. This will once again have the same problem when the actual response arrives. The result is that the modbus client will temporarily "soft lock".
To fix this, the wait semaphore just needs to be reset before transmitting.
To Reproduce
I don't have an easy way to reproduce this yet. When I have time, I'll create a test case in the modbus twister test to reproduce this behavior.
Expected behavior
Modbus client should recover for the next transmission, and ignore previously received information.
Impact
In our case, this temporarily blocks any and all communication with the target device for several if not tens of seconds. Theoretically, this particular lockup could happen indefinitely.
Logs and console output
This is an annotated log of what is happening, with a couple additional logs added to the modbus source code to make it clearer.
Environment:
The text was updated successfully, but these errors were encountered: