Browse Source
Ethernet2UART gateway: never lose a sensor query around a reconnect
Ethernet2UART gateway: never lose a sensor query around a reconnect
The sensor answers only when queried, and it re-sends its query after every attempt without reply (idle mode: getState2() in stage 1 again). The gateway must deliver each of these queries: - Queued requests are no longer dropped by closePort(). A query queued while the I/O thread ended for a reconnect is sent on the new connection (the previous commit dropped it, so the sensor stayed unqueried for that attempt). - sendData() queues while the connection is up, while the I/O thread is still starting (TH_ARMED: the first query right after a connect was refused with "Trying to Send Data Before Thread is Started!"), while the thread has ended and the reconnect is pending, and while create_SOL() is connecting. It refuses only without any connection. - At most E2UART_MAX_QUEUED (16) requests wait; the oldest are dropped. A failed reconnect clears the queue, because those queries are stale. - The "NO reply" debug line shows the request bytes (first 12), so a repeated query can be recognised in the log. Tested with a fake device that goes silent after 3 replies: the query sent while the thread was starting and the query queued during the reconnect were both answered, and nothing was refused (ASan clean). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16pull/24/head
Failed to extract signature
2 changed files with 60 additions and 17 deletions
Write
Preview
Loading…
Cancel
Save
Reference in new issue