Field log: after a PTZ liveness failure the protocol was re-created
(camera and stream kept), but the camera then ran its whole start-up
sequence again (power mode, WB, BLC, AF, home) in the middle of the work.
- A successful re-creation of a protocol that worked before in this node
(a recovery) goes straight to CAM_WS_READY: "PTZ protocol re-created
- camera settings kept, back to ready". The first initialisation of
the node still runs the full sequence.
- CAM_REBUILD_AFTER_FAILED_INITS 10 -> 3: three failed re-creations in a
row (back-off 0, 5, 10 s) are a major problem (camera power supply,
network). The node is rebuilt and the new node fully initialises the
camera: "PTZ protocol re-creation failed 3 times in a row (camera power /
network?) - rebuilding the camera".
- Only for a camera whose protocol worked in this node (m_bPtzEverOk):
one that never worked (e.g. switched off) keeps retrying with the
back-off instead of being rebuilt every few seconds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
A pOnvif problem could delete and re-create the whole camera node, which
dropped the video stream bound to it, so recordings were cut although the
video was fine.
deviceNodeCamera::validate() compared the whole camera record with
memcmp; any difference rebuilt the node:
- CAM_WS_INIT sets m_sCamData.online = false before re-creating the
PTZ protocol and writes the DB only afterwards. A validate() during a
slow ONVIF re-init saw "online" differ and deleted the camera
mid-re-init.
- The ONVIF discovery (updateIPCam) wrote online=1 and the whole XAddrs
list into onvif_ctrl (the web UI and la_mojo store only the path), so
the record changed on discovery rounds.
- A failed read (SQLite busy, queries fail at once) returned NULL =
"camera deleted".
Now:
- Field classes (camDataChange):
- runtime and discovery fields (online, status, session, max_range,
uuid, mac): ignored;
- name and hardware: taken over;
- PTZ access (onvif_ctrl, onvif_access, port, auth_mode, ptz_token):
the camera thread re-creates only the PTZ protocol, keeping the node
and the stream;
- anything else (ip and credentials used by the stream, stream_id,
type, geometry, ...): rebuild as before, logged with the reason.
- A lasting PTZ problem rebuilds the camera only after
CAM_REBUILD_AFTER_FAILED_INITS (10) failed protocol initialisations
in a row (several minutes with the retry back-off).
- Node / camera record not read: rebuild only after
NODE_DATA_MISSES_TO_REBUILD (3) validations in a row, for all nodes
(deviceNode::validate).
- updateIPCam: onvif_ctrl = path of the first XAddr. Host and port come
from the first XAddr only: ':' was searched in the whole list, so a
second, IPv6 XAddr gave a broken IP. A result without an address
doesn't wipe the IP.
Tested (functions extracted unchanged): camDataChange classifies
online / status / max_range / uuid / mac as ignored, rename as
cosmetic, port / onvif_ctrl / auth / ptz token as PTZ re-init, and ip /
password / stream / geometry as rebuild. The XAddrs parser was checked
with a port, without a port, with an IPv6 second XAddr, with a query, and
with no address.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
"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