la_mojo ONVIF: wait for the real end of an AbsoluteMove #11

Merged
ClaudeAI merged 1 commits from feature/onvif-abs-move-wait into master 19 minutes ago
ClaudeAI commented 4 hours ago
Collaborator

Summary

After an ONVIF AbsoluteMove, la_mojo now waits until the camera reports that the move is finished, instead of a fixed time. When the camera reports nothing, it falls back to a fixed 3 s wait.

How the camera is checked

Right after protocolPTZ_ONVIF::create() connects:

  • PTZ GetServiceCapabilities: reads the MoveStatus / StatusPosition attributes.
  • One real GetStatus call: shows what the camera actually sends.

An explicit false in the capabilities wins, because some cameras send fixed values. The result is logged once:
PTZ status support: MoveStatus=yes Position=yes (...) -> wait for IDLE

How waitMoveIsDone() waits

Camera reports Wait ends when
MoveStatus pan/tilt and zoom are IDLE (polled every 200 ms)
Position only the AbsoluteMove target is reached, or the position stops changing
Neither after a fixed 3 s

Rules applied in all cases:

  • Early IDLE: IDLE right after the command is ignored for 1 s. The exceptions are a camera already seen MOVING, or one already on target.
  • Timeout: the wait gives up after 10 s.
  • Failing status: after 3 failed GetStatus calls in a row it falls back to the fixed wait.

The constants are in protocolPTZ_ONVIF.h.

Fixes needed for this

  • pOnvif::ptz_GetStatus:
    • Position and MoveStatus are optional in the schema. Every element is now read without crashing when it is missing.
    • MoveStatus is always read. Before, it was read only when the position was not 0/0/0.
    • The result now says what was reported (hasPosition, hasZoomPosition, isMoving).
  • pOnvif::_send_request: the reply flag is set up before the request is queued. Late replies to requests that already timed out are ignored. Without this, a status poll could get the answer to the previous request.
  • New pOnvif::ptz_GetServiceCapabilities().

Testing

  • Compile check: g++ -fsyntax-only with the la_mojo flags, no new warnings.
  • Simulated ONVIF camera with AddressSanitizer, each move taking 2.5 s; no ASan findings:
Simulated camera Wait
Reports MoveStatus and Position ~2.6 s
Starts 0.6 s late, says IDLE meanwhile ~3.2 s (no early exit)
Position only ~2.6 s; 11 ms when already on target
Reports nothing 3.0 s
  • Not tested on a real camera. On the device:
    • Check the PTZ status support log line.
    • Check that the time to EVT_CAMERA_ON_POSITION now follows the real move.

Notes

  • Video output mode: deviceNodeCamera is unchanged. With video output enabled (m_bSkeepPositioningWait), it still does not wait at all.
  • HTTP Digest (auth mode 1): curl sends the first POST without a body and expects a 401 challenge. A camera that does not ask for HTTP auth gets an empty request. Existing behaviour, not changed here.

Generated with Claude Code

https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16

## Summary After an ONVIF `AbsoluteMove`, la_mojo now waits until the camera reports that the move is finished, instead of a fixed time. When the camera reports nothing, it falls back to a fixed 3 s wait. ## How the camera is checked Right after `protocolPTZ_ONVIF::create()` connects: - **PTZ `GetServiceCapabilities`**: reads the `MoveStatus` / `StatusPosition` attributes. - **One real `GetStatus` call**: shows what the camera actually sends. An explicit `false` in the capabilities wins, because some cameras send fixed values. The result is logged once: `PTZ status support: MoveStatus=yes Position=yes (...) -> wait for IDLE` ## How `waitMoveIsDone()` waits | Camera reports | Wait ends when | |---|---| | MoveStatus | pan/tilt and zoom are IDLE (polled every 200 ms) | | Position only | the AbsoluteMove target is reached, or the position stops changing | | Neither | after a fixed 3 s | Rules applied in all cases: - **Early IDLE:** IDLE right after the command is ignored for 1 s. The exceptions are a camera already seen MOVING, or one already on target. - **Timeout:** the wait gives up after 10 s. - **Failing status:** after 3 failed `GetStatus` calls in a row it falls back to the fixed wait. The constants are in `protocolPTZ_ONVIF.h`. ## Fixes needed for this - **`pOnvif::ptz_GetStatus`:** - Position and MoveStatus are optional in the schema. Every element is now read without crashing when it is missing. - MoveStatus is always read. Before, it was read only when the position was not 0/0/0. - The result now says what was reported (`hasPosition`, `hasZoomPosition`, `isMoving`). - **`pOnvif::_send_request`:** the reply flag is set up before the request is queued. Late replies to requests that already timed out are ignored. Without this, a status poll could get the answer to the previous request. - **New `pOnvif::ptz_GetServiceCapabilities()`.** ## Testing - **Compile check:** `g++ -fsyntax-only` with the la_mojo flags, no new warnings. - **Simulated ONVIF camera with AddressSanitizer**, each move taking 2.5 s; no ASan findings: | Simulated camera | Wait | |---|---| | Reports MoveStatus and Position | ~2.6 s | | Starts 0.6 s late, says IDLE meanwhile | ~3.2 s (no early exit) | | Position only | ~2.6 s; 11 ms when already on target | | Reports nothing | 3.0 s | - **Not tested on a real camera.** On the device: - Check the `PTZ status support` log line. - Check that the time to `EVT_CAMERA_ON_POSITION` now follows the real move. ## Notes - **Video output mode:** `deviceNodeCamera` is unchanged. With video output enabled (`m_bSkeepPositioningWait`), it still does not wait at all. - **HTTP Digest (auth mode 1):** curl sends the first POST without a body and expects a 401 challenge. A camera that does not ask for HTTP auth gets an empty request. Existing behaviour, not changed here. Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
ClaudeAI added 1 commit 4 hours ago
e39f8b5aef
la_mojo ONVIF: wait for the real end of an AbsoluteMove
ClaudeAI merged commit 9a1d4a7023 into master 19 minutes ago
The pull request has been merged as 9a1d4a7023.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.