Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
Clock Synchronization (diagnostic/timeout-sizing only)

Files

file  src/oal/clocksync/sapi_clocksync.c
 Implementation of the pluggable clock-sync backend (ADR-017).

Enumerations

enum  sapi_clocksync_quality_t { SAPI_CLOCKSYNC_UNSYNCHRONIZED = 0 , SAPI_CLOCKSYNC_DEGRADED = 1 , SAPI_CLOCKSYNC_SYNCHRONIZED = 2 }
 Coarse quality/confidence of the current clock synchronization. More...

Functions

sapi_status_t sapi_clocksync_get_offset_ms (int64_t *out_offset_ms)
 Reports this node's estimated clock offset (diagnostic/timeout- sizing only - see the file-level note; never use this to decide whether channel results are comparable).
sapi_status_t sapi_clocksync_get_quality (sapi_clocksync_quality_t *out_quality)
 Reports the backend's current confidence in the clock offset.

Detailed Description

REQ-CLOCKSYNC-001: sapi_clocksync_get_offset_ms() and sapi_clocksync_get_quality() shall return SAPI_STATUS_NOT_INITIALIZED if no backend has been registered. REQ-CLOCKSYNC-002: this module shall never be called from, or influence the outcome of, sapi_channel_checkpoint() or any other vital comparison - see the file-level note above.

Enumeration Type Documentation

◆ sapi_clocksync_quality_t

Coarse quality/confidence of the current clock synchronization.

Enumerator
SAPI_CLOCKSYNC_UNSYNCHRONIZED 

No synchronization has ever been established (e.g. just booted, or the sync source is unreachable). Reported offset, if any, must not be trusted.

SAPI_CLOCKSYNC_DEGRADED 

Synchronized in the past but the backend judges the estimate stale/degraded (e.g. sync source lost, drift accumulating).

SAPI_CLOCKSYNC_SYNCHRONIZED 

Currently synchronized within the backend's normal operating bound.

Definition at line 59 of file sapi_clocksync.h.

Function Documentation

◆ sapi_clocksync_get_offset_ms()

sapi_status_t sapi_clocksync_get_offset_ms ( int64_t * out_offset_ms)

Reports this node's estimated clock offset (diagnostic/timeout- sizing only - see the file-level note; never use this to decide whether channel results are comparable).

Parameters
out_offset_msMilliseconds, positive if local clock is ahead of the backend's reference. Must not be NULL.
Returns
SAPI_STATUS_OK; SAPI_STATUS_INVALID_PARAM if out_offset_ms is NULL; SAPI_STATUS_NOT_INITIALIZED if no backend is registered (REQ-CLOCKSYNC-001); SAPI_STATUS_NOT_SUPPORTED if the registered backend's get_offset_ms slot is NULL.

Definition at line 48 of file sapi_clocksync.c.

◆ sapi_clocksync_get_quality()

sapi_status_t sapi_clocksync_get_quality ( sapi_clocksync_quality_t * out_quality)

Reports the backend's current confidence in the clock offset.

Parameters
out_qualityMust not be NULL.
Returns
SAPI_STATUS_OK; SAPI_STATUS_INVALID_PARAM if out_quality is NULL; SAPI_STATUS_NOT_INITIALIZED if no backend is registered (REQ-CLOCKSYNC-001); SAPI_STATUS_NOT_SUPPORTED if the registered backend's get_quality slot is NULL.

Definition at line 72 of file sapi_clocksync.c.