Fixed-size camera-control wire codec and FC-side ticket state. More...


Go to the source code of this file.
Data Structures | |
| struct | usher_control_request |
| One addressed command request shared with the companion protocol. More... | |
| struct | usher_control_result |
| Result evidence for one camera selected by a request mask. More... | |
| struct | usher_control_slot |
| Fixed pending/result slot retained for one addressable camera. More... | |
| struct | usher_control_client |
| Handshake, capability cache, and eight-camera ticket state. More... | |
Macros | |
| #define | USHER_CONTROL_TIMEOUT_US UINT32_C(70000000) |
| #define | USHER_CONTROL_LEASE_US UINT32_C(6000000) |
Functions | |
| bool | usher_control_put_u32 (uint8_t *bytes, size_t size, size_t offset, uint32_t value) |
| Encode a 32-bit value as four little-endian protocol bytes. | |
| bool | usher_control_get_u32 (const uint8_t *bytes, size_t size, size_t offset, uint32_t *value) |
| Decode a bounded four-byte little-endian protocol value. | |
| bool | usher_control_encode_request (uint8_t *bytes, size_t size, const struct usher_control_request *request) |
| Encode one command payload with the fixed wire size and field order. | |
| bool | usher_control_decode_request (const uint8_t *bytes, size_t size, struct usher_control_request *request) |
| Validate and decode one fixed-size command payload. | |
| bool | usher_control_encode_result (uint8_t *bytes, size_t size, const struct usher_control_result *result) |
| Encode one camera's correlated control result. | |
| bool | usher_control_decode_result (const uint8_t *bytes, size_t size, struct usher_control_result *result) |
| Validate and decode one camera result payload. | |
| bool | usher_control_value_valid (uint8_t command, uint8_t value) |
| Validate the command-specific legal value range. | |
| void | usher_control_client_reset (struct usher_control_client *client, uint32_t nonce) |
| Reset session state and invalidate outstanding tickets without replay. | |
| bool | usher_control_client_hello (struct usher_control_client *client, const uint8_t *bytes, size_t size, uint32_t now_us) |
| Accept only a HELLO matching the current nonce-bound negotiation. | |
| bool | usher_control_client_ready (const struct usher_control_client *client, uint32_t now_us) |
| Check confirmed-session readiness and the bounded HELLO lease. | |
| void | usher_control_client_expire (struct usher_control_client *client, uint32_t now_us) |
| Mark expired pending commands UNKNOWN; never resubmit them. | |
| bool | usher_control_client_prepare (struct usher_control_client *client, uint8_t mask, uint8_t command, uint8_t value, uint32_t now_us, struct usher_control_request *request) |
| Prepare a request without consuming its ticket before UART admission. | |
| void | usher_control_client_commit (struct usher_control_client *client, const struct usher_control_request *request, uint32_t now_us) |
| Commit a prepared request after full-frame UART admission. | |
| bool | usher_control_client_receive (struct usher_control_client *client, const uint8_t *bytes, size_t size, uint32_t now_us) |
| Accept a result only when session, ticket, camera, and evidence correlate. | |
| uint8_t | usher_control_client_result (const struct usher_control_client *client, uint32_t ticket) |
| Aggregate per-camera results for one group ticket. | |
| uint8_t | usher_control_client_camera_result (const struct usher_control_client *client, uint32_t ticket, uint8_t camera_id) |
| Read one camera's status for a group request. | |
Detailed Description
Fixed-size camera-control wire codec and FC-side ticket state.
Control tickets are distinct from photo numbers and shot requests. Eight per-camera slots keep the flight-controller footprint bounded; a ticket is consumed only after its complete UART frame is admitted. Commands are not replayed after timeout because the camera may already have acted.
Definition in file camera_control.h.
Macro Definition Documentation
◆ USHER_CONTROL_LEASE_US
| #define USHER_CONTROL_LEASE_US UINT32_C(6000000) |
Definition at line 33 of file camera_control.h.
◆ USHER_CONTROL_TIMEOUT_US
| #define USHER_CONTROL_TIMEOUT_US UINT32_C(70000000) |
Definition at line 32 of file camera_control.h.
Function Documentation
◆ usher_control_client_camera_result()
| uint8_t usher_control_client_camera_result | ( | const struct usher_control_client * | client, |
| uint32_t | ticket, | ||
| uint8_t | camera_id ) |
Read one camera's status for a group request.
- Parameters
-
[in] client Client result slots. [in] ticket Request ID; zero means NOT_SENT. [in] camera_id One-based camera slot from 1 through 8.
- Returns
- Matching result status, UNKNOWN for absent/replaced tickets, or NOT_SENT.
Definition at line 196 of file camera_control.c.
◆ usher_control_client_commit()
| void usher_control_client_commit | ( | struct usher_control_client * | client, |
| const struct usher_control_request * | request, | ||
| uint32_t | now_us ) |
Commit a prepared request after full-frame UART admission.
- Parameters
-
[in,out] client Client state whose ticket and selected slots are updated. [in] request Request previously returned by usher_control_client_prepare. [in] now_us Monotonic send time in microseconds.
Definition at line 160 of file camera_control.c.
◆ usher_control_client_expire()
| void usher_control_client_expire | ( | struct usher_control_client * | client, |
| uint32_t | now_us ) |
Mark expired pending commands UNKNOWN; never resubmit them.
- Parameters
-
[in,out] client Client state to update. [in] now_us Current monotonic time in microseconds.
Definition at line 138 of file camera_control.c.
◆ usher_control_client_hello()
| bool usher_control_client_hello | ( | struct usher_control_client * | client, |
| const uint8_t * | bytes, | ||
| size_t | size, | ||
| uint32_t | now_us ) |
Accept only a HELLO matching the current nonce-bound negotiation.
- Parameters
-
[in,out] client Handshake and capability state. [in] bytes HELLO payload. [in] size Payload size; must equal USHER_CONTROL_HELLO_SIZE. [in] now_us Current monotonic time in microseconds.
- Returns
- True if the reply is structurally valid and belongs to this negotiation.
Definition at line 115 of file camera_control.c.
◆ usher_control_client_prepare()
| bool usher_control_client_prepare | ( | struct usher_control_client * | client, |
| uint8_t | mask, | ||
| uint8_t | command, | ||
| uint8_t | value, | ||
| uint32_t | now_us, | ||
| struct usher_control_request * | request ) |
Prepare a request without consuming its ticket before UART admission.
- Parameters
-
[in,out] client Session state and pending slots. [in] mask Eight-bit camera selection mask. [in] command Command identifier. [in] value Command-specific value. [in] now_us Current monotonic time in microseconds. [out] request Receives the tentative request on success.
- Returns
- True only if the session is ready, values are legal, and selected slots are free.
- Note
- Call usher_control_client_commit only after the complete frame is admitted.
Definition at line 147 of file camera_control.c.
◆ usher_control_client_ready()
| bool usher_control_client_ready | ( | const struct usher_control_client * | client, |
| uint32_t | now_us ) |
Check confirmed-session readiness and the bounded HELLO lease.
- Parameters
-
[in] client Client state. [in] now_us Current monotonic time in microseconds.
- Returns
- True only while the negotiated session is fresh and confirmed.
Definition at line 133 of file camera_control.c.
◆ usher_control_client_receive()
| bool usher_control_client_receive | ( | struct usher_control_client * | client, |
| const uint8_t * | bytes, | ||
| size_t | size, | ||
| uint32_t | now_us ) |
Accept a result only when session, ticket, camera, and evidence correlate.
- Parameters
-
[in,out] client Client state containing pending requests. [in] bytes Received result payload. [in] size Payload length. [in] now_us Current monotonic time in microseconds.
- Returns
- True when the result belongs to a pending request and its evidence is valid.
Definition at line 173 of file camera_control.c.
◆ usher_control_client_reset()
| void usher_control_client_reset | ( | struct usher_control_client * | client, |
| uint32_t | nonce ) |
Reset session state and invalidate outstanding tickets without replay.
- Parameters
-
[in,out] client Client state to reset. [in] nonce New handshake nonce; zero is normalized to one.
Definition at line 101 of file camera_control.c.
◆ usher_control_client_result()
| uint8_t usher_control_client_result | ( | const struct usher_control_client * | client, |
| uint32_t | ticket ) |
Aggregate per-camera results for one group ticket.
- Parameters
-
[in] client Client result slots. [in] ticket Request ID; zero means NOT_SENT.
- Returns
- UNKNOWN if evidence is missing, PENDING if any selected camera is pending, PARTIAL for mixed terminal outcomes, or the common terminal status.
Definition at line 203 of file camera_control.c.
◆ usher_control_decode_request()
| bool usher_control_decode_request | ( | const uint8_t * | bytes, |
| size_t | size, | ||
| struct usher_control_request * | request ) |
Validate and decode one fixed-size command payload.
- Parameters
-
[in] bytes Received payload. [in] size Payload size; must equal USHER_CONTROL_COMMAND_SIZE. [out] request Receives decoded fields on success.
- Returns
- True only when version, mask, command, session, and ticket are valid.
Definition at line 61 of file camera_control.c.
◆ usher_control_decode_result()
| bool usher_control_decode_result | ( | const uint8_t * | bytes, |
| size_t | size, | ||
| struct usher_control_result * | result ) |
Validate and decode one camera result payload.
- Parameters
-
[in] bytes Received payload. [in] size Payload size; must equal USHER_CONTROL_RESULT_SIZE. [out] result Receives decoded fields on success.
- Returns
- True only when version, identity, status, and evidence are valid.
Definition at line 88 of file camera_control.c.
◆ usher_control_encode_request()
| bool usher_control_encode_request | ( | uint8_t * | bytes, |
| size_t | size, | ||
| const struct usher_control_request * | request ) |
Encode one command payload with the fixed wire size and field order.
- Parameters
-
[out] bytes Destination payload buffer. [in] size Payload size; must equal USHER_CONTROL_COMMAND_SIZE. [in] request Session, ticket, camera mask, command, and value.
- Returns
- True only for valid required fields and exact payload size.
Definition at line 48 of file camera_control.c.
◆ usher_control_encode_result()
| bool usher_control_encode_result | ( | uint8_t * | bytes, |
| size_t | size, | ||
| const struct usher_control_result * | result ) |
Encode one camera's correlated control result.
- Parameters
-
[out] bytes Destination payload buffer. [in] size Payload size; must equal USHER_CONTROL_RESULT_SIZE. [in] result Result status and evidence for one camera.
- Returns
- True only when camera, request, status, and evidence fields are valid.
Definition at line 71 of file camera_control.c.
◆ usher_control_get_u32()
| bool usher_control_get_u32 | ( | const uint8_t * | bytes, |
| size_t | size, | ||
| size_t | offset, | ||
| uint32_t * | value ) |
Decode a bounded four-byte little-endian protocol value.
- Parameters
-
[in] bytes Source payload buffer. [in] size Total buffer size. [in] offset Byte offset for the field. [out] value Receives the decoded value.
- Returns
- True if the field fits and both pointers are valid.
Definition at line 34 of file camera_control.c.
◆ usher_control_put_u32()
| bool usher_control_put_u32 | ( | uint8_t * | bytes, |
| size_t | size, | ||
| size_t | offset, | ||
| uint32_t | value ) |
Encode a 32-bit value as four little-endian protocol bytes.
- Parameters
-
[out] bytes Destination payload buffer. [in] size Total buffer size. [in] offset Byte offset for the field. [in] value Value to encode.
- Returns
- True if the field fits and the buffer is non-null.
Definition at line 27 of file camera_control.c.
◆ usher_control_value_valid()
| bool usher_control_value_valid | ( | uint8_t | command, |
| uint8_t | value ) |
Validate the command-specific legal value range.
- Parameters
-
[in] command Control command ID. [in] value Command value.
- Returns
- True for a supported value, false before any ticket is reserved otherwise.
Definition at line 42 of file camera_control.c.