RTE RBC 2oo2 Reference Application
0.1.0 build 0006685
SIL 4 2oo2 Dual-Site Fault-Tolerant ERTMS Radio Block Centre Reference Architecture
Toggle main menu visibility
Loading...
Searching...
No Matches
ab_gp_sibling_state.c
Go to the documentation of this file.
1
5
#include "
ab_gp_sibling_state.h
"
6
7
void
ab_gp_sibling_state_reset
(
ab_gp_sibling_state_t
*st)
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
22
bool
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
41
bool
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
}
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 ca...
Definition
ab_gp_sibling_state.c:22
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.
Definition
ab_gp_sibling_state.c:41
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).
Definition
ab_gp_sibling_state.c:7
ab_gp_sibling_state.h
The A/B sibling's last site-state frame (PEER_MSG_KIND_SITE_STATE), kept raw and handed to Platform_R...
RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE
#define RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE
Definition
common_config.h:827
RTE_EXAMPLE_SINGLE_MODE_FLAG_SINGLE
#define RTE_EXAMPLE_SINGLE_MODE_FLAG_SINGLE
Definition
common_config.h:771
ab_gp_sibling_state_t
Definition
ab_gp_sibling_state.h:28
ab_gp_sibling_state_t::known
bool known
Definition
ab_gp_sibling_state.h:30
ab_gp_sibling_state_t::bytes
uint8_t bytes[RTE_EXAMPLE_AB_SITE_STATE_WIRE_SIZE]
Definition
ab_gp_sibling_state.h:29
ab_gp_sibling_state_t::fresh
bool fresh
Definition
ab_gp_sibling_state.h:31
src
application
AB
GP
com
ab_gp_sibling_state.c
Generated by
1.18.0