Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
rte_fsou.c
Go to the documentation of this file.
1
10
12
14#define RTE_FSOU_LOG_TAG "FSOU"
15
17
21static const rte_osadapter_fsou_t *s_osadapter = NULL;
22
24
26
27
30{
32
33 /* REQ-FSOU-001 */
34 if (adapter == NULL)
35 {
37 }
38 else
39 {
40 /* REQ-LIFECYCLE-001 (ADR-026): registering an OSAdapter is a setup-only
41 * action - refuse once the application's setup phase has been locked. */
43 if (status == RTE_STATUS_OK)
44 {
45 s_osadapter = adapter;
46 }
47 }
48
49 return status;
50}
51
52rte_status_t rte_fsou_grant(uint32_t cycle_id)
53{
55
56 /* REQ-FSOU-002 */
57 if (s_osadapter == NULL)
58 {
60 }
61 else if (s_osadapter->grant == NULL)
62 {
64 }
65 else
66 {
67 status = s_osadapter->grant(cycle_id);
68 }
69
70 return status;
71}
72
74{
76
77 /* REQ-FSOU-002 */
78 if (s_osadapter == NULL)
79 {
81 }
82 else if (s_osadapter->revoke == NULL)
83 {
85 }
86 else
87 {
88 status = s_osadapter->revoke(reason);
89 }
90
91 return status;
92}
93
95{
96 return (s_osadapter != NULL);
97}
98
100{
102 static bool s_presence_reported = false;
103
104 /* REQ-FSOU-003: one line per process, latched. */
105 if (!s_presence_reported)
106 {
107 s_presence_reported = true;
108 if (s_osadapter != NULL)
109 {
111 }
112 else
113 {
114 rte_log_write(RTE_LOG_LEVEL_INFO, RTE_FSOU_LOG_TAG, "no FSOU registered");
115 }
116 }
117}
void rte_fsou_report_presence(void)
Logs once whether an FSOU is present (REQ-FSOU-003).
Definition rte_fsou.c:99
rte_status_t rte_fsou_grant(uint32_t cycle_id)
Grants this channel's output permission to the FSOU for one cycle (REQ-FSOU-002).
Definition rte_fsou.c:52
bool rte_fsou_is_present(void)
Tells whether an FSOU OSAdapter is registered.
Definition rte_fsou.c:94
rte_status_t rte_fsou_revoke(rte_safestate_reason_t reason)
Withdraws this channel's output permission from the FSOU (REQ-FSOU-002).
Definition rte_fsou.c:73
rte_status_t rte_lifecycle_check_setup_allowed(void)
Convenience check for a setup-only constructor: call this as one of the first checks in any function ...
void rte_log_write(rte_log_level_t level, const char *tag, const char *message)
Emits one log message. Non-blocking; never fails the caller's control flow even if the message is dro...
Definition rte_log.c:108
@ RTE_LOG_LEVEL_INFO
Definition rte_log.h:36
uint16_t rte_safestate_reason_t
Diagnostic reason code accompanying a safe-state transition.
rte_status_t
Common result/status codes.
Definition rte_status.h:27
@ RTE_STATUS_OK
Definition rte_status.h:28
@ RTE_STATUS_INVALID_PARAM
Definition rte_status.h:29
@ RTE_STATUS_NOT_SUPPORTED
Definition rte_status.h:34
@ RTE_STATUS_NOT_INITIALIZED
Definition rte_status.h:30
static const rte_osadapter_clocksync_t * s_osadapter
#define RTE_FSOU_LOG_TAG
Definition rte_fsou.c:14
Fail-Safe Output Unit (FSOU) output permission, optional OSAdapter seam (ADR-041, proposed).
Process-wide application setup-phase lock (ADR-026).
OS Abstraction Layer - Logging/diagnostics service.
OSAdapter interface for the Fail-Safe Output Unit (FSOU) output permission (ADR-041).
rte_status_t rte_osadapter_fsou_register(const rte_osadapter_fsou_t *adapter)
Registers the OSAdapter FSOU implementation (REQ-FSOU-001).
Definition rte_fsou.c:29
OSAdapter FSOU operations vtable.
rte_status_t(*) grant(uint32_t cycle_id)
rte_status_t(*) revoke(rte_safestate_reason_t reason)