Transaction ID sync recovery

11 views
Skip to first unread message

Rick Mann

unread,
Jan 9, 2024, 5:21:59 AMJan 9
to libm...@googlegroups.com
I recently built a little TCP-serial bridge (on an Arduino platform) that's working pretty well in my application, but every now and again things would get wonky and it would stop working. At first I thought something was wrong with its TCP stack, but after closely examining libmodbus’s debug output and my own, I realized that libmodbus was timing out before the response came, and receiving that old response for its next request. This would mean the Transaction ID didn't match, and it would report an error.

I found the `modbus_set_error_recovery()` function and set it to MODBUS_ERROR_RECOVERY_PROTOCOL, and this seemed solve the issue, as it flushed the receive queue.

If it flushes the queue and still receives an "old" response, will it just flush again and again until it gets the right one? Does it ever give up? Presumably it will sort itself out in all but the most pathological cases.

--
Rick Mann
rm...@latencyzero.com


Reply all
Reply to author
Forward
0 new messages