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
Unified Channel Factory

App-facing channel open/send/receive/close, transport hidden (ADR-022). More...

Data Structures

struct  rte_safechannel_endpoint_t
 One remote endpoint to open internally - replaces a caller- supplied rte_netlink_handle_t (ADR-022 section 2.2). More...
struct  rte_safechannel_dual_config_t
 Configuration specific to RTE_SAFECHANNEL_TYPE_DUAL_REDUNDANT. More...
struct  rte_safechannel_vital_config_t
 Configuration specific to RTE_SAFECHANNEL_TYPE_VITAL_VOTED. More...
struct  rte_safechannel_config_t
 Configuration for rte_safechannel_open(). More...
union  rte_safechannel_config_t::[union].as
struct  rte_safechannel_t
 Caller-owned storage for one rte_safechannel_t instance. Every field is private - reach it only through the functions below. No dynamic allocation (REQ-SAFECHANNEL-002): sized to hold up to RTE_SAFECHANNEL_MAX_LINKS opened netlink links plus whichever of rte_dual_channel_t/rte_channel_t is in use. More...
union  rte_safechannel_t::[union].impl
struct  rte_safechannel_t::[struct].impl.vital

Macros

#define RTE_SAFECHANNEL_MAX_LINKS   4U
 Maximum number of redundant endpoints one rte_safechannel_t may be configured with, for either type. Fixed, not dynamic.

Enumerations

enum  rte_safechannel_type_t { RTE_SAFECHANNEL_TYPE_DUAL_REDUNDANT = 0 , RTE_SAFECHANNEL_TYPE_VITAL_VOTED = 1 }
 Which underlying channel implementation a rte_safechannel_t wraps. More...
enum  rte_safechannel_link_status_t { RTE_SAFECHANNEL_LINK_DOWN = 0 , RTE_SAFECHANNEL_LINK_DEGRADED = 1 , RTE_SAFECHANNEL_LINK_FULL = 2 }
 Aggregate link status, uniform across both wrapped types. More...

Functions

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, then initializes the wrapped rte_dual_channel_t or rte_channel_t on top of the resulting links (ADR-022 section 2.2). Retries each endpoint's rte_netlink_open() internally up to config's own connect_timeout_ms, matching the retry pattern every current hand-rolled caller already implemented itself.
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_channel_send()), atomic all-or-nothing broadcast to every registered channel for VITAL_VOTED (rte_voter_send()).
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 already staged.
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 already-closed/never-opened instance (no-op).

Detailed Description

App-facing channel open/send/receive/close, transport hidden (ADR-022).

Macro Definition Documentation

◆ RTE_SAFECHANNEL_MAX_LINKS

#define RTE_SAFECHANNEL_MAX_LINKS   4U

Maximum number of redundant endpoints one rte_safechannel_t may be configured with, for either type. Fixed, not dynamic.

Definition at line 57 of file rte_safechannel.h.

Enumeration Type Documentation

◆ rte_safechannel_type_t

Which underlying channel implementation a rte_safechannel_t wraps.

Enumerator
RTE_SAFECHANNEL_TYPE_DUAL_REDUNDANT 

Wraps rte_dual_channel_t: 1..N redundant links, always-send + bounded-ACK-wait delivery, EN 50159-framed (ADR-020).

RTE_SAFECHANNEL_TYPE_VITAL_VOTED 

Wraps a rte_voter_t over N rte_channel_t links: 2oo2/2oo3/NMR voting arbitration (ADR-025).

Definition at line 60 of file rte_safechannel.h.

◆ rte_safechannel_link_status_t

Aggregate link status, uniform across both wrapped types.

Enumerator
RTE_SAFECHANNEL_LINK_DOWN 

No configured endpoint is usable.

RTE_SAFECHANNEL_LINK_DEGRADED 

Some, but not all, endpoints usable.

RTE_SAFECHANNEL_LINK_FULL 

Every configured endpoint usable.

Definition at line 71 of file rte_safechannel.h.

Function Documentation

◆ rte_safechannel_open()

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, then initializes the wrapped rte_dual_channel_t or rte_channel_t on top of the resulting links (ADR-022 section 2.2). Retries each endpoint's rte_netlink_open() internally up to config's own connect_timeout_ms, matching the retry pattern every current hand-rolled caller already implemented itself.

Parameters
channelCaller-owned storage to initialize. Must not be NULL.
configConfiguration. Must not be NULL; config->type selects which union member is read; that member's link_count must be in [1, its type's max] and every endpoints[0..link_count-1].host must not be NULL for a CONNECT-role endpoint.
Returns
RTE_STATUS_OK; RTE_STATUS_INVALID_PARAM for a bad argument; RTE_STATUS_TIMEOUT if any configured endpoint fails to establish within its connect_timeout_ms (every endpoint opened so far is closed again before returning - all-or-nothing); RTE_STATUS_NOT_INITIALIZED if no rte_netlink OSAdapter is registered.

Definition at line 211 of file rte_safechannel.c.

◆ rte_safechannel_send()

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_channel_send()), atomic all-or-nothing broadcast to every registered channel for VITAL_VOTED (rte_voter_send()).

Parameters
channelOpened channel. Must not be NULL.
payloadPayload to send. May be NULL only if payload_size is 0.
payload_sizePayload size in bytes; must be <= RTE_DUAL_CHANNEL_MAX_PAYLOAD (DUAL_REDUNDANT) or the configured message_size (VITAL_VOTED).
Returns
RTE_STATUS_OK; RTE_STATUS_TIMEOUT; RTE_STATUS_INVALID_PARAM; RTE_STATUS_HARDWARE_FAULT (VITAL_VOTED disagreement/fault) - see rte_dual_channel_send()/rte_voter_send() for the exact per-type semantics.

Definition at line 239 of file rte_safechannel.c.

◆ rte_safechannel_receive()

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 already staged.

Parameters
channelOpened channel. Must not be NULL.
out_payloadDestination buffer. Must not be NULL.
max_sizeUsable size of out_payload; must be > 0.
timeout_msMaximum time to actively poll if nothing was already staged; 0 = check only what is already staged.
out_sizeReceives the actual payload size. Must not be NULL.
Returns
RTE_STATUS_OK; RTE_STATUS_TIMEOUT if nothing arrived in time; RTE_STATUS_INVALID_PARAM for a bad argument or an already-staged frame larger than max_size.

Definition at line 257 of file rte_safechannel.c.

◆ rte_safechannel_get_status()

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.

Parameters
channelChannel to query. May be NULL (returns DOWN, defensive default).
Returns
The current aggregate status.

Definition at line 286 of file rte_safechannel.c.

◆ rte_safechannel_close()

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 already-closed/never-opened instance (no-op).

Parameters
channelChannel to close. May be NULL (no-op).
Returns
RTE_STATUS_OK.

Definition at line 323 of file rte_safechannel.c.