RTE RBC 2oo2 Reference Application 0.1.0 build 0006685
SIL 4 2oo2 Dual-Site Fault-Tolerant ERTMS Radio Block Centre Reference Architecture
Loading...
Searching...
No Matches
ab_gp_sibling_state.c File Reference

See ab_gp_sibling_state.h. More...

Include dependency graph for ab_gp_sibling_state.c:

Go to the source code of this file.

Functions

void ab_gp_sibling_state_reset (ab_gp_sibling_state_t *st)
 Resets the state to "no frame seen" (all zero).
bool ab_gp_sibling_state_store (ab_gp_sibling_state_t *st, const uint8_t *payload, size_t size)
 Stores a received site-state frame payload: the rule of on_peer_frame_received() (the payload must carry at least the whole frame). A later store before a take replaces the earlier bytes.
bool ab_gp_sibling_state_take (ab_gp_sibling_state_t *st, rte_site_role_sibling_t *out)
 The rte_site_role_sibling_source_fn contract: hands out the frame stored since the previous take.

Detailed Description

Function Documentation

◆ ab_gp_sibling_state_reset()

void ab_gp_sibling_state_reset ( ab_gp_sibling_state_t * st)

Resets the state to "no frame seen" (all zero).

Parameters
stthe state; NULL is ignored

Definition at line 7 of file ab_gp_sibling_state.c.

◆ ab_gp_sibling_state_store()

bool ab_gp_sibling_state_store ( ab_gp_sibling_state_t * st,
const uint8_t * payload,
size_t size )

Stores a received site-state frame payload: the rule of on_peer_frame_received() (the payload must carry at least the whole frame). A later store before a take replaces the earlier bytes.

Parameters
stthe state
payloadthe frame payload (the bytes after the message kind)
sizenumber of bytes available in payload
Returns
true when size is at least RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE and the first RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE bytes were copied (known and fresh set); false otherwise (NULL argument or a short payload: the state is left unchanged)

Definition at line 22 of file ab_gp_sibling_state.c.

◆ ab_gp_sibling_state_take()

bool ab_gp_sibling_state_take ( ab_gp_sibling_state_t * st,
rte_site_role_sibling_t * out )

The rte_site_role_sibling_source_fn contract: hands out the frame stored since the previous take.

Parameters
stthe state
outreceives known = true, online = (byte 0 != 0), single_mode = (byte 1 == RTE_EXAMPLE_SINGLE_MODE_FLAG_SINGLE), ready = (byte 2 != 0) when the result is true; left untouched otherwise
Returns
true when a fresh frame was handed out (fresh is cleared, known stays); false when nothing fresh is held or an argument is NULL

Definition at line 41 of file ab_gp_sibling_state.c.