Field: the Ethernet2UART gateway connection dropped and reconnected
within a second ("Peer Closes Connection!" -> "Connected to ..."), but the
2D sensor stayed offline until la_mojo was restarted.
The sensor was re-initialised (MODE_DETECTOR + handshake) only if its
thread saw the transport's short CS_DISCONNECTED. On a fast reconnect it
did not, and stayed in idle mode, believing the device to be in detector
mode (m_bActualDeviceWM) and only polling getState2. A device that left
detector mode while the link was down was never set back. A restart
starts from MODE_NONE, which is why it helped.
- basicTransport::getConnectEpoch(): +1 on every change to CS_CONNECTED.
- device2DSensor remembers the epoch when it binds its port
(connectMode). validateCommunicationRessource() (every loop pass
above connection mode) runs the connection sequence again when the
epoch changed: "Transport reconnected - re-initialising the sensor".
- deviceETH2UART: "Peer Closes Connection!" says why: "closed by the
gateway" (FIN) or "error: <errno>" (e.g. Connection timed out = sent
data not acknowledged within E2UART_TCP_USER_TIMEOUT_MS), plus the
TCP_INFO figures.
Tested with the real gateway class: a device that goes silent (reconnect
after 5 unanswered requests) and a gateway that closes the connection.
After each reconnect the epoch changes (1 -> 2), so the sensor would
re-initialise, and requests are answered again. The close is logged as
"closed by the gateway; TCP: ...". ASan clean. The full 2D sensor
can't run here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
A 2D sensor waited 10 x 100 ms (LGS_DEFAULT_TO_COUNTER) for each reply,
which is a local serial-line value. Through an Ethernet to serial gateway
on a mobile link the round trip is longer at times.
- basicTransport::isNetworkLink() (false by default). deviceETH2UART
returns true.
- deviceNodeSensor::m_nTOCounterBase is the wait per attempt.
device2DSensor sets it when it binds to its port:
LGS_NETWORK_TO_COUNTER (30 = 3 s) for a network link,
LGS_DEFAULT_TO_COUNTER (1 s) for a local serial port, which is unchanged.
All 2D waits use it, including the longer x4 / x16 waits of the
detection profile and mask commands. waitStateFunction() re-arms the
retry with it.
- E2UART_REPLY_TIMEOUT_MS 800 -> 2500 ms, below the sensor's 3 s, so the
gateway's I/O thread waits for the reply before sending the next request.
Tested with the fake device: replies after 300 ms (split), 1200 ms and
2000 ms (split) all reach their own request within the 3 s wait (ASan clean).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16