"NODSEN: Communication Wait State TO!" with a sensor behind the gateway:
in SERIAL_PING_PONG mode the I/O thread waited only 20 x 5 ms (~100 ms,
a serial-line value) for the reply to a request, and did not read the
socket while no request was queued. A reply slower than that, which is
normal over a mobile link, stayed in the socket. It was read with the next
request and given to that request's parser, so the sensor ran one reply
behind, retried, and after 16 failed attempts reported the timeout.
deviceETH2UART I/O thread (SERIAL_PING_PONG)
- Waits up to E2UART_REPLY_TIMEOUT_MS (800 ms, below the sensor's 1 s per
attempt) for the reply to start, and E2UART_REPLY_GAP_MS (150 ms)
between the pieces of a reply split over several TCP segments. It is
done as soon as the parser has a complete packet and no more data is
waiting (as before).
- Reads the socket also between requests. Late data goes to the parser
of the last request at once.
- Gives data only to a parser that is still bound to the transport (a
sensor that disconnected or was deleted is no longer called).
Serial resource casts (deviceNode2D, deviceNodeCamera)
- dynamic_cast<basicTransport*> instead of static_cast through
hardwareResourceSerialProvider. The resource can be a deviceETH2UART,
and the old cast was only right because of a matching base-class layout.
A NULL transport isn't bound.
Tested with a fake device answering after 50/300/700 ms, also split into
two TCP pieces. The old code delivered nothing, or the previous
request's answer. Now each request gets its own answer (ASan clean).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
PTZ health per camera (deviceNodeCamera):
- PTZ_HEALTH_INFO: state (NONE / INIT / OK / FAILED), failure and
recovery counters, consecutive failed initialisations, time of the
last state change / failure, next retry and the last error text.
getPtzHealth() returns a copy (mutex-protected, any thread).
- getPtzStatus() - already sent to the remote server as
CAMERA_STATUS_PTZ_OK - now reflects it: 1 for OK (or no PTZ protocol),
0 while PTZ is initialising or failed. Before it was 1 as soon as the
state machine left CAM_WS_INIT, whatever the protocol did.
Failure detection and re-initialisation:
- While idle (CAM_WS_READY) the camera checks the protocol's validate()
every loop and calls the new protocolPTZ::probe() every 30 s
(ONVIF: GetStatus; a SOAP Fault still means "reachable", only a
communication error marks the camera lost). Default probe() is the
protocol's validate(), so serial protocols are unchanged.
- On failure the PTZ protocol is recreated through CAM_WS_INIT: first
attempt at once, then 5, 10, 20, 40, 60 s (capped) between attempts;
recoveries are logged and counted.
- A failed target-driven goAbsolute/goPreset no longer ends the camera
thread (CAM_WS_END rebuilt the whole node): for ONVIF a command the
camera rejected (connection OK) only drops that ROI, anything else
re-initialises the PTZ protocol.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
Target-driven moves of deviceNodePTZCamControl (AbsoluteMove) and
deviceNodePresetCamControl (preset for the ROI) both end in
CAM_WS_WAIT_ONPOS, which waits for the end of the move and then
broadcasts EVT_CAMERA_ON_POSITION (EVT_CLASS_CAMERA_CTRL).
- AbsoluteMove: with video output enabled (m_bSkeepPositioningWait) the
event was broadcast right after the command, before the camera moved.
It now always goes through CAM_WS_WAIT_ONPOS, like the preset path.
- New m_bNoMoveDoneReport: set when the protocol cannot report the end
of a move (waitMoveIsDone() returns false). Then a fixed
CAM_MOVE_FIXED_WAIT_MS (3 s) wait is used before the event. Before, the
same failure set m_bSkeepPositioningWait, which made every later
AbsoluteMove broadcast the event immediately. Reset when the protocol
is (re)created.
- protocolPTZ_ONVIF::goPreset: forget the last AbsoluteMove target so
waitMoveIsDone() cannot end early by comparing with it.
Homing, init go-home and web/IR/wiper presets are unchanged (no event).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16