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_safechannel.h
Go to the documentation of this file.
1
37#ifndef RTE_SAFECHANNEL_H
38#define RTE_SAFECHANNEL_H
39
40#include <stdbool.h>
41#include <stdint.h>
42#include <stddef.h>
43
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
57#define RTE_SAFECHANNEL_MAX_LINKS 4U
58
69
77
82typedef struct rte_safechannel_endpoint_s
83{
88 const char *host;
90 uint16_t port;
92
113
140
142typedef struct rte_safechannel_config_s
143{
146 union
147 {
150 } as;
152
160typedef struct rte_safechannel_s
161{
163 bool is_open;
164
168 rte_netlink_storage_t links[RTE_SAFECHANNEL_MAX_LINKS];
170 uint32_t link_count;
171
172 union
173 {
175 struct
176 {
180 rte_voter_t voter;
181 } vital;
182 } impl;
184
207
223rte_status_t rte_safechannel_send(rte_safechannel_t *channel, const uint8_t *payload, size_t payload_size);
224
238rte_status_t rte_safechannel_receive(rte_safechannel_t *channel, uint8_t *out_payload, size_t max_size,
239 rte_duration_ms_t timeout_ms, size_t *out_size);
240
248
257
258#ifdef __cplusplus
259}
260#endif
261
262#endif /* RTE_SAFECHANNEL_H */
263 /* SAFECHANNEL */
void(*) rte_dual_channel_status_callback_t(rte_dual_channel_status_t new_status, rte_dual_channel_status_t old_status, void *user_ctx)
Optional callback invoked whenever rte_dual_channel_get_status()'s value changes (ADR-020 section 2's...
rte_status_t rte_safechannel_receive(rte_safechannel_t *channel, uint8_t *out_payload, size_t max_size, rte_duration_ms_t timeout_ms, size_t *out_size)
Returns the most recent inbound payload, actively polling the underlying channel if nothing was alrea...
rte_status_t rte_safechannel_send(rte_safechannel_t *channel, const uint8_t *payload, size_t payload_size)
Sends payload on the underlying channel - broadcast-with-ACK- wait for DUAL_REDUNDANT (rte_dual_chann...
rte_status_t rte_safechannel_open(rte_safechannel_t *channel, const rte_safechannel_config_t *config)
Opens a channel: opens every configured endpoint via the registered rte_netlink OSAdapter,...
rte_safechannel_link_status_t rte_safechannel_get_status(const rte_safechannel_t *channel)
Aggregate status across every configured endpoint - DOWN before the first send/receive.
rte_status_t rte_safechannel_close(rte_safechannel_t *channel)
Closes every endpoint this instance opened and releases the wrapped channel. Safe to call on an alrea...
rte_safechannel_type_t
Which underlying channel implementation a rte_safechannel_t wraps.
#define RTE_SAFECHANNEL_MAX_LINKS
Maximum number of redundant endpoints one rte_safechannel_t may be configured with,...
rte_safechannel_link_status_t
Aggregate link status, uniform across both wrapped types.
@ RTE_SAFECHANNEL_TYPE_VITAL_VOTED
@ RTE_SAFECHANNEL_TYPE_DUAL_REDUNDANT
@ RTE_SAFECHANNEL_LINK_DEGRADED
@ RTE_SAFECHANNEL_LINK_FULL
@ RTE_SAFECHANNEL_LINK_DOWN
rte_status_t
Common result/status codes.
Definition rte_status.h:27
uint32_t rte_duration_ms_t
Definition rte_types.h:27
rte_voter_storage_t rte_voter_t
Opaque handle to a voter instance.
Definition rte_voter.h:149
rte_voting_strategy_t
Voting strategy: how many registered channels must agree.
Definition rte_voter.h:42
rte_voting_result_t
Outcome of one rte_voter_receive() call.
Definition rte_voter.h:54
A single redundant "channel": an opaque transport handle plus send/receive callbacks,...
"DualChannel" layer of ADR-020: wraps 1..N redundant rte_dual_msgchannel_t links for fault-tolerant,...
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
N-way voting across registered rte_channel_t links (2oo2/2oo3/NMR).
One rte_dual_channel_t instance's state. Caller-owned storage; every field is private - reach it only...
Configuration for rte_safechannel_open().
rte_safechannel_type_t type
Configuration specific to RTE_SAFECHANNEL_TYPE_DUAL_REDUNDANT.
rte_dual_channel_status_callback_t status_callback
rte_safechannel_endpoint_t endpoints[RTE_SAFECHANNEL_MAX_LINKS]
rte_duration_ms_t connect_timeout_ms
One remote endpoint to open internally - replaces a caller- supplied rte_netlink_handle_t (ADR-022 se...
rte_channel_t channels[RTE_SAFECHANNEL_MAX_LINKS]
Caller-owned storage for one rte_safechannel_t instance. Every field is private - reach it only throu...
rte_netlink_storage_t links[RTE_SAFECHANNEL_MAX_LINKS]
Configuration specific to RTE_SAFECHANNEL_TYPE_VITAL_VOTED.
rte_safechannel_endpoint_t endpoints[RTE_SAFECHANNEL_MAX_LINKS]
rte_voting_strategy_t voting_strategy
void(*) on_disagreement(void *context, rte_voting_result_t result)