Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
sapi_clocksync.c
Go to the documentation of this file.
1
9
11
13
19
21
23
24
27{
29
30 if (backend == NULL)
31 {
33 }
34 else
35 {
36 /* REQ-LIFECYCLE-001 (ADR-026): registering a backend is a setup-only
37 * action - refuse once the application's setup phase has been locked. */
39 if (status == SAPI_STATUS_OK)
40 {
41 s_backend = backend;
42 }
43 }
44
45 return status;
46}
47
49{
51
52 if (out_offset_ms == NULL)
53 {
55 }
56 else if (s_backend == NULL)
57 {
59 }
60 else if (s_backend->get_offset_ms == NULL)
61 {
63 }
64 else
65 {
66 status = s_backend->get_offset_ms(out_offset_ms);
67 }
68
69 return status;
70}
71
73{
75
76 if (out_quality == NULL)
77 {
79 }
80 else if (s_backend == NULL)
81 {
83 }
84 else if (s_backend->get_quality == NULL)
85 {
87 }
88 else
89 {
90 status = s_backend->get_quality(out_quality);
91 }
92
93 return status;
94}
sapi_status_t sapi_clocksync_register_backend(const sapi_clocksync_backend_t *backend)
Registers the backend implementation used by every sapi_clocksync_* call (ADR-005-style single global...
sapi_clocksync_quality_t
Coarse quality/confidence of the current clock synchronization.
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...
sapi_status_t sapi_clocksync_get_quality(sapi_clocksync_quality_t *out_quality)
Reports the backend's current confidence in the clock offset.
sapi_status_t sapi_lifecycle_check_setup_allowed(void)
Convenience check for a setup-only constructor: call this as one of the first checks in any function ...
sapi_status_t
Common result/status codes.
Definition sapi_status.h:27
@ SAPI_STATUS_NOT_SUPPORTED
Definition sapi_status.h:34
@ SAPI_STATUS_INVALID_PARAM
Definition sapi_status.h:29
@ SAPI_STATUS_NOT_INITIALIZED
Definition sapi_status.h:30
@ SAPI_STATUS_OK
Definition sapi_status.h:28
static const sapi_clocksync_backend_t * s_backend
Pluggable wall-clock synchronization backend (ADR-017).
OS-backend adaptation surface for Clock Synchronization (ADR-005, ADR-017, ADR-021).
Process-wide application setup-phase lock (ADR-026).
Backend vtable: an integrator's implementation of clock synchronization for a specific mechanism (PTP...
sapi_status_t(*) get_offset_ms(int64_t *out_offset_ms)
sapi_status_t(*) get_quality(sapi_clocksync_quality_t *out_quality)