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
Go to the documentation of this file.
1
6
8{
9 if (st != NULL)
10 {
11 size_t i;
12
13 for (i = 0U; i < (size_t)RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE; i++)
14 {
15 st->bytes[i] = 0U;
16 }
17 st->known = false;
18 st->fresh = false;
19 }
20}
21
22bool ab_gp_sibling_state_store(ab_gp_sibling_state_t *st, const uint8_t *payload, size_t size)
23{
24 bool ok = false;
25
26 if ((st != NULL) && (payload != NULL) && (size >= (size_t)RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE))
27 {
28 size_t i;
29
30 for (i = 0U; i < (size_t)RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE; i++)
31 {
32 st->bytes[i] = payload[i];
33 }
34 st->known = true;
35 st->fresh = true;
36 ok = true;
37 }
38 return ok;
39}
40
41bool ab_gp_sibling_state_take(ab_gp_sibling_state_t *st, rte_site_role_sibling_t *out)
42{
43 bool taken = false;
44
45 if ((st != NULL) && (out != NULL) && st->fresh)
46 {
47 /* The three decodes GP's local_facts() and check_site_state() used to make (site-state frame layout). */
48 out->known = true;
49 out->online = (st->bytes[0] != 0U);
50 out->single_mode = (st->bytes[1] == (uint8_t)RTE_EXAMPLE_SINGLE_MODE_FLAG_SINGLE);
51 out->ready = (st->bytes[2] != 0U);
52 st->fresh = false;
53 taken = true;
54 }
55 return taken;
56}
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 ca...
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.
void ab_gp_sibling_state_reset(ab_gp_sibling_state_t *st)
Resets the state to "no frame seen" (all zero).
The A/B sibling's last site-state frame (PEER_MSG_KIND_SITE_STATE), kept raw and handed to Platform_R...
#define RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE
#define RTE_EXAMPLE_SINGLE_MODE_FLAG_SINGLE
uint8_t bytes[RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE]