|
Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
|
Files | |
| file | src/redundancy/channel_link/rte_channel.c |
| One redundant channel: validates parameters, then dispatches to its configured send/recv callbacks, tracking health as a side effect (ADR-025). | |
Data Structures | |
| struct | rte_channel_health_t |
| Health statistics for one vital channel. More... | |
| struct | rte_channel_config_t |
| Configuration for rte_channel_init(). More... | |
| struct | rte_channel_storage_t |
| Storage for one vital channel instance (opaque to caller). More... | |
Typedefs | |
| typedef rte_status_t(*) | rte_channel_send_fn(void *channel_handle, const void *data, size_t data_size) |
| OSAdapter send callback: transmits on this channel's underlying transport. | |
| typedef rte_status_t(*) | rte_channel_recv_fn(void *channel_handle, void *data, size_t data_size, uint32_t timeout_ms) |
| OSAdapter receive callback: reads from this channel's underlying transport. | |
| typedef rte_channel_storage_t | rte_channel_t |
| Opaque handle to a vital channel instance. | |
Functions | |
| rte_status_t | rte_channel_init (rte_channel_storage_t *storage, const rte_channel_config_t *config) |
| Initializes one vital channel over a caller-supplied transport. | |
| rte_status_t | rte_channel_send (rte_channel_t *handle, const void *data, size_t data_size) |
| Sends data on this channel via its OSAdapter send callback. | |
| rte_status_t | rte_channel_receive (rte_channel_t *handle, void *data, size_t data_size, uint32_t timeout_ms) |
| Receives data on this channel via its OSAdapter receive callback. | |
| rte_status_t | rte_channel_get_health (const rte_channel_t *handle, rte_channel_health_t *out_health) |
| Queries this channel's health statistics. | |
| const char * | rte_channel_get_name (const rte_channel_t *handle) |
| Returns this channel's name, as given in rte_channel_config_t::name at rte_channel_init() time. | |
| rte_status_t | rte_channel_set_healthy (rte_channel_t *handle, bool is_healthy) |
| Marks this channel healthy/unhealthy. | |
| rte_status_t | rte_channel_destroy (rte_channel_t *handle) |
| Destroys a vital channel instance. | |
| typedef rte_status_t(*) rte_channel_send_fn(void *channel_handle, const void *data, size_t data_size) |
OSAdapter send callback: transmits on this channel's underlying transport.
| [in] | channel_handle | Opaque transport handle (as supplied in rte_channel_config_t::channel_handle) |
| [in] | data | Data to send |
| [in] | data_size | Size of data in bytes |
Definition at line 67 of file rte_channel.h.
| typedef rte_status_t(*) rte_channel_recv_fn(void *channel_handle, void *data, size_t data_size, uint32_t timeout_ms) |
OSAdapter receive callback: reads from this channel's underlying transport.
| [in] | channel_handle | Opaque transport handle |
| [out] | data | Buffer to receive data |
| [in] | data_size | Size of data buffer |
| [in] | timeout_ms | Timeout in milliseconds |
Definition at line 82 of file rte_channel.h.
| typedef rte_channel_storage_t rte_channel_t |
Opaque handle to a vital channel instance.
Created by rte_channel_init(); used directly, or registered into a rte_voter_t (N-way voting) or rte_cross_comparator_t (2-way comparison) for the redundancy/comparison use case.
Definition at line 127 of file rte_channel.h.
| rte_status_t rte_channel_init | ( | rte_channel_storage_t * | storage, |
| const rte_channel_config_t * | config ) |
Initializes one vital channel over a caller-supplied transport.
| [out] | storage | Pre-allocated storage. Must not be NULL. |
| [in] | config | Configuration with send/recv callbacks. Must not be NULL; config->send and config->recv must not be NULL. |
REQ-CHANNEL-001: No dynamic allocation; caller supplies storage. REQ-CHANNEL-002: Rejects a NULL config->send/config->recv.
Local makros Local types declarations Local variables declarations Global variables declarations Local function declarations Global functions
Definition at line 23 of file rte_channel.c.
| rte_status_t rte_channel_send | ( | rte_channel_t * | handle, |
| const void * | data, | ||
| size_t | data_size ) |
Sends data on this channel via its OSAdapter send callback.
| [in] | handle | Vital channel handle. Must not be NULL and must have been initialized. |
| [in] | data | Data to send. Must not be NULL. |
| [in] | data_size | Size of data in bytes. Must be > 0. |
REQ-CHANNEL-003: Dispatches to config->send and updates health counters on every call, regardless of outcome.
Definition at line 56 of file rte_channel.c.
| rte_status_t rte_channel_receive | ( | rte_channel_t * | handle, |
| void * | data, | ||
| size_t | data_size, | ||
| uint32_t | timeout_ms ) |
Receives data on this channel via its OSAdapter receive callback.
| [in] | handle | Vital channel handle. Must not be NULL and must have been initialized. |
| [out] | data | Buffer to receive data. Must not be NULL. |
| [in] | data_size | Size of data buffer. Must be > 0. |
| [in] | timeout_ms | Timeout passed to config->recv(). |
REQ-CHANNEL-003: Dispatches to config->recv and updates health counters on every call, regardless of outcome.
Definition at line 84 of file rte_channel.c.
| rte_status_t rte_channel_get_health | ( | const rte_channel_t * | handle, |
| rte_channel_health_t * | out_health ) |
Queries this channel's health statistics.
| [in] | handle | Vital channel handle. Must not be NULL. |
| [out] | out_health | Receives a copy of the current health state. Must not be NULL. |
Definition at line 113 of file rte_channel.c.
| const char * rte_channel_get_name | ( | const rte_channel_t * | handle | ) |
Returns this channel's name, as given in rte_channel_config_t::name at rte_channel_init() time.
| [in] | handle | Vital channel handle. Must not be NULL. |
REQ-CHANNEL-005: rte_channel_config_t::name is optional and not copied (caller-owned, must outlive the channel); returned verbatim, NULL if handle is NULL or no name was configured.
Definition at line 124 of file rte_channel.c.
| rte_status_t rte_channel_set_healthy | ( | rte_channel_t * | handle, |
| bool | is_healthy ) |
Marks this channel healthy/unhealthy.
Intended for a rte_voter_t/rte_cross_comparator_t (or any other owner) to call after deciding, by its own policy, that this channel should stop (or resume) participating - this module itself never changes is_healthy on its own (a single I/O failure alone does not mark a channel unhealthy; that decision belongs to the owner tracking failures across multiple channels).
| [in] | handle | Vital channel handle. Must not be NULL. |
| [in] | is_healthy | New health state. |
REQ-CHANNEL-004: is_healthy defaults true at init and is never cleared automatically by this module - only via this explicit call.
Definition at line 133 of file rte_channel.c.
| rte_status_t rte_channel_destroy | ( | rte_channel_t * | handle | ) |
Destroys a vital channel instance.
No dynamic memory to free; the underlying transport is NOT closed (caller retains ownership of channel_handle).
| [in] | handle | Vital channel handle. May be NULL. |
Definition at line 144 of file rte_channel.c.