Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
sapi_dual_negotiator.c File Reference

Dual state negotiator of ADR-020 - see sapi_dual_negotiator.h. More...

Include dependency graph for sapi_dual_negotiator.c:

Go to the source code of this file.

Functions

static bool negotiator_decide_online (uint32_t own_id, uint64_t own_ts, uint32_t peer_id, uint64_t peer_ts)
 Older-timestamp-wins tie-break, own_id/peer_id as the deterministic fallback on an exact tie - same rule safeAPIRBC2oo2's site.c decide_online() uses today.
static void negotiator_process_peer_frame (sapi_dual_negotiator_t *negotiator, const sapi_dual_state_frame_t *frame)
static void negotiator_update_states (sapi_dual_negotiator_t *negotiator)
sapi_status_t sapi_dual_negotiator_init (sapi_dual_negotiator_t *negotiator, const sapi_dual_negotiator_config_t *config)
 Initializes a sapi_dual_negotiator_t. Captures this instance's own startup timestamp once (sapi_timer_now(), degrading to 0 if no timer backend is registered - same best-effort posture as sapi_log_write_event()'s Timestamp field) for use on every beacon this negotiator ever sends - see sapi_dual_state_frame_t's own doc on why this must stay fixed. Both own and peer state start at SAPI_DUAL_STATE_IDLE.
sapi_status_t sapi_dual_negotiator_execute (sapi_dual_negotiator_t *negotiator, sapi_duration_ms_t receive_timeout_ms)
 Drives one round of state negotiation: refreshes own_channel_degraded from the attached channel's current sapi_dual_channel_get_status(), sends this instance's own beacon, drains and processes every currently-pending inbound STATE frame, then recomputes both own and peer sapi_dual_state_t:
sapi_dual_state_t sapi_dual_negotiator_get_own_state (const sapi_dual_negotiator_t *negotiator)
 Returns this instance's own current sapi_dual_state_t.
sapi_dual_state_t sapi_dual_negotiator_get_peer_state (const sapi_dual_negotiator_t *negotiator)
 Returns this instance's last-known view of the peer's sapi_dual_state_t.

Detailed Description

Dual state negotiator of ADR-020 - see sapi_dual_negotiator.h.

Definition in file sapi_dual_negotiator.c.

Function Documentation

◆ negotiator_decide_online()

bool negotiator_decide_online ( uint32_t own_id,
uint64_t own_ts,
uint32_t peer_id,
uint64_t peer_ts )
static

Older-timestamp-wins tie-break, own_id/peer_id as the deterministic fallback on an exact tie - same rule safeAPIRBC2oo2's site.c decide_online() uses today.

Definition at line 15 of file sapi_dual_negotiator.c.

◆ negotiator_process_peer_frame()

void negotiator_process_peer_frame ( sapi_dual_negotiator_t * negotiator,
const sapi_dual_state_frame_t * frame )
static

Definition at line 24 of file sapi_dual_negotiator.c.

◆ negotiator_update_states()

void negotiator_update_states ( sapi_dual_negotiator_t * negotiator)
static

Definition at line 37 of file sapi_dual_negotiator.c.