Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
clock_alignment.c File Reference

Implementation of USHER's token-bound, interval-based clock alignment. More...

#include <stddef.h>
#include "clock_alignment.h"
Include dependency graph for clock_alignment.c:

Go to the source code of this file.

Functions

static bool same_token (union usher_clock_request_union first, union usher_clock_request_union second)
 Compare opaque wire tokens without depending on host structure padding.
bool clock_alignment_request (struct clock_alignment *clock, union usher_clock_request_union token, uint64_t sent_us)
 Register a newly transmitted clock probe.
bool clock_alignment_reply (struct clock_alignment *clock, const uint8_t *payload, size_t length, uint64_t received_us)
 Validate a flight-controller clock reply and establish a mapping anchor.
bool clock_alignment_map (const struct clock_alignment *clock, union usher_clock_request_union token, uint32_t fc_us, uint64_t now_us, struct clock_interval *interval)
 Project a controller timestamp into a conservative USHER time interval.

Detailed Description

Implementation of USHER's token-bound, interval-based clock alignment.

This intentionally avoids synchronizing clocks globally. It validates a small request/reply exchange, then maps only poses that carry the matching token. Integer interval arithmetic makes the drift assumptions explicit and handles normal uint32_t flight-controller timer wrap by subtraction.

Definition in file clock_alignment.c.

Function Documentation

◆ clock_alignment_map()

bool clock_alignment_map ( const struct clock_alignment * clock,
union usher_clock_request_union token,
uint32_t fc_us,
uint64_t now_us,
struct clock_interval * interval )

Project a controller timestamp into a conservative USHER time interval.

Parameters
clockAccepted alignment state.
tokenToken proving the pose belongs to this probe epoch.
fc_us32-bit controller microsecond timestamp.
now_usCurrent USHER monotonic time, used to reject stale/future projections.
intervalReceives inclusive projected bounds.
Returns
True when interval contains a plausible mapping.
Warning
The result is an interval, not a claimed exact timestamp.

Definition at line 75 of file clock_alignment.c.

◆ clock_alignment_reply()

bool clock_alignment_reply ( struct clock_alignment * clock,
const uint8_t * payload,
size_t length,
uint64_t received_us )

Validate a flight-controller clock reply and establish a mapping anchor.

Parameters
clockMutable synchronization state.
payloadExact reply payload bytes.
lengthPayload length.
received_usUSHER monotonic receive timestamp.
Returns
True only for a matching, bounded-latency reply.

Rather than guessing a one-way delay, this stores an interval spanning the possible controller transmit instant, including bounded service time and clock drift.

Definition at line 50 of file clock_alignment.c.

◆ clock_alignment_request()

bool clock_alignment_request ( struct clock_alignment * clock,
union usher_clock_request_union token,
uint64_t sent_us )

Register a newly transmitted clock probe.

Parameters
clockMutable synchronization state.
tokenNonzero random token carried on the wire.
sent_usUSHER monotonic timestamp at transmission.
Returns
True if the probe is accepted as pending.

Tokens must not repeat the pending or last accepted probe; this prevents a delayed reply from being mistaken for fresh timing evidence.

Definition at line 39 of file clock_alignment.c.

◆ same_token()

bool same_token ( union usher_clock_request_union first,
union usher_clock_request_union second )
static

Compare opaque wire tokens without depending on host structure padding.

Definition at line 34 of file clock_alignment.c.