Open legoabram opened 1 month ago
Not sure the fix needs to be backported to v3.5(EOL)
I'd prefer if we could since it makes our bug fix path much easier, but I'd understand if you decide against it.
3.5 is not supported, no PRs allowed against that branch
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: