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_channel_service.c File Reference

Validation and dispatch for the named channel service. More...

Include dependency graph for rte_channel_service.c:

Go to the source code of this file.

Functions

static rte_status_t validate_osadapter (void)
rte_status_t rte_osadapter_channel_service_register (const rte_osadapter_channel_service_t *osadapter)
 Registers the OSAdapter that implements named channels (ADR-005).
rte_status_t rte_channel_service_setup (rte_channel_service_t *storage, const char *channel_name)
rte_status_t rte_channel_service_setup_by_id (rte_channel_service_t *storage, uint32_t channel_id)
rte_status_t rte_channel_service_read (rte_channel_service_t *storage, void *data, size_t data_size, rte_duration_ms_t timeout_ms)
rte_status_t rte_channel_service_read_ex (rte_channel_service_t *storage, void *data, size_t data_size, rte_duration_ms_t timeout_ms, size_t *out_actual_size)
 Same as rte_channel_service_read, but also reports the actual number of bytes received into data (never more than data_size). Use this instead of rte_channel_service_read whenever a channel may carry messages shorter than its configured buffer size - a caller that only has the plain read can't tell a short message from one that filled the buffer exactly, and forwarding data_size bytes verbatim would forward trailing garbage. out_actual_size must not be NULL. On any non-OK return its value is unspecified - the caller does not have a valid message to look at anyway.
rte_status_t rte_channel_service_send (rte_channel_service_t *storage, const void *data, size_t data_size, rte_duration_ms_t timeout_ms)
 Sends data_size bytes of data on the named channel in storage through the registered OSAdapter's send.
rte_status_t rte_channel_service_close (rte_channel_service_t *storage)

Variables

static const rte_osadapter_channel_service_t * s_osadapter

Detailed Description

Validation and dispatch for the named channel service.

Definition in file rte_channel_service.c.

Function Documentation

◆ validate_osadapter()

rte_status_t validate_osadapter ( void )
static

Definition at line 12 of file rte_channel_service.c.

◆ rte_osadapter_channel_service_register()

rte_status_t rte_osadapter_channel_service_register ( const rte_osadapter_channel_service_t * osadapter)

Registers the OSAdapter that implements named channels (ADR-005).

Returns
RTE_STATUS_OK on success, RTE_STATUS_INVALID_PARAM if osadapter is NULL.

Definition at line 22 of file rte_channel_service.c.

◆ rte_channel_service_setup()

rte_status_t rte_channel_service_setup ( rte_channel_service_t * storage,
const char * channel_name )

Definition at line 33 of file rte_channel_service.c.

◆ rte_channel_service_setup_by_id()

rte_status_t rte_channel_service_setup_by_id ( rte_channel_service_t * storage,
uint32_t channel_id )

Definition at line 58 of file rte_channel_service.c.

◆ rte_channel_service_read()

rte_status_t rte_channel_service_read ( rte_channel_service_t * storage,
void * data,
size_t data_size,
rte_duration_ms_t timeout_ms )

Definition at line 80 of file rte_channel_service.c.

◆ rte_channel_service_read_ex()

rte_status_t rte_channel_service_read_ex ( rte_channel_service_t * storage,
void * data,
size_t data_size,
rte_duration_ms_t timeout_ms,
size_t * out_actual_size )

Same as rte_channel_service_read, but also reports the actual number of bytes received into data (never more than data_size). Use this instead of rte_channel_service_read whenever a channel may carry messages shorter than its configured buffer size - a caller that only has the plain read can't tell a short message from one that filled the buffer exactly, and forwarding data_size bytes verbatim would forward trailing garbage. out_actual_size must not be NULL. On any non-OK return its value is unspecified - the caller does not have a valid message to look at anyway.

Returns
RTE_STATUS_OK, or whatever the registered OSAdapter's read returns.

Definition at line 99 of file rte_channel_service.c.

◆ rte_channel_service_send()

rte_status_t rte_channel_service_send ( rte_channel_service_t * storage,
const void * data,
size_t data_size,
rte_duration_ms_t timeout_ms )

Sends data_size bytes of data on the named channel in storage through the registered OSAdapter's send.

Parameters
storageChannel set up by rte_channel_service_setup; must not be NULL.
dataBytes to send; must not be NULL.
data_sizeNumber of bytes to send; must not be 0.
timeout_msUpper bound for the OSAdapter's send.
Returns
RTE_STATUS_INVALID_PARAM for a NULL storage / data or a zero data_size; RTE_STATUS_NOT_INITIALIZED with no complete OSAdapter registered; RTE_STATUS_NOT_CONNECTED when a listen-role link has no peer yet and nothing was sent (REQ-CHANSVC-001); otherwise the OSAdapter's own result, unchanged.

Definition at line 130 of file rte_channel_service.c.

◆ rte_channel_service_close()

rte_status_t rte_channel_service_close ( rte_channel_service_t * storage)

Definition at line 149 of file rte_channel_service.c.

Variable Documentation

◆ s_osadapter

const rte_osadapter_channel_service_t* s_osadapter
static

Definition at line 10 of file rte_channel_service.c.