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_proc_text_message.c
Go to the documentation of this file.
1
5
7#include "rte/oal/memory/rte_mem_util.h"
8#include "rte/utils/string/rte_string.h"
9
10/* REQ-ID: RBC_ERTMS_TXT_001 - Text Message Context Initialization */
12{
13 if (ctx == NULL)
14 {
15 return;
16 }
17
18 ctx->text_msg.has_pending_msg = false;
19 ctx->text_msg.nid_textmessage = 0U;
20 ctx->text_msg.q_textclass = 0U;
21 ctx->text_msg.q_textconfirm = 0U;
22 ctx->text_msg.duration_s = 0U;
23 ctx->text_msg.ack_received = false;
24 ctx->text_msg.ack_timestamp_ms = 0U;
25}
26
27/* REQ-ID: RBC_ERTMS_TXT_002 - Dispatch Driver Text Message */
29 uint8_t nid_textmessage,
30 uint8_t q_textclass,
31 uint8_t q_textconfirm,
32 uint32_t duration_s,
33 const char *text,
35{
36 rte_string_t str;
37
38 if ((ctx == NULL) || (out_p72 == NULL) || (text == NULL) || (nid_textmessage == 0U))
39 {
40 return false;
41 }
42
43 ctx->text_msg.has_pending_msg = true;
44 ctx->text_msg.nid_textmessage = nid_textmessage;
45 ctx->text_msg.q_textclass = q_textclass;
46 ctx->text_msg.q_textconfirm = q_textconfirm;
47 ctx->text_msg.duration_s = duration_s;
48 ctx->text_msg.ack_received = false;
49 ctx->text_msg.ack_timestamp_ms = 0U;
50
51 out_p72->ack_required = (q_textconfirm != 0U);
52 out_p72->duration_s = duration_s;
53
54 /* Safely copy bounded string using rte_string_t */
55 rte_mem_set(out_p72->text, 0, sizeof(out_p72->text));
56 if (rte_string_init(&str, out_p72->text, sizeof(out_p72->text)) == RTE_STATUS_OK)
57 {
58 (void)rte_string_copy(&str, text);
59 (void)rte_string_c_str(&str, NULL);
60 }
61
62 return true;
63}
64
65/* REQ-ID: RBC_ERTMS_TXT_003 - Driver Confirmation Handling */
67 uint8_t nid_textmessage,
68 uint32_t timestamp_ms)
69{
70 if ((ctx == NULL) || (nid_textmessage == 0U))
71 {
72 return false;
73 }
74
75 if (ctx->text_msg.has_pending_msg && (ctx->text_msg.nid_textmessage == nid_textmessage))
76 {
77 ctx->text_msg.ack_received = true;
78 ctx->text_msg.ack_timestamp_ms = timestamp_ms;
79 ctx->text_msg.has_pending_msg = false;
80 return true;
81 }
82
83 return false;
84}
85
86/* REQ-ID: RBC_ERTMS_TXT_004 - Pending Confirmation Query */
88{
89 if (ctx == NULL)
90 {
91 return false;
92 }
93
94 return (ctx->text_msg.has_pending_msg && (ctx->text_msg.q_textconfirm != 0U) && !ctx->text_msg.ack_received);
95}
96
bool ab_gp_proc_text_message_handle_ack(ab_gp_ertms_train_context_t *ctx, uint8_t nid_textmessage, uint32_t timestamp_ms)
Handles driver acknowledgement of a text message (Msg 146 / Msg 158).
bool ab_gp_proc_text_message_is_pending_ack(const ab_gp_ertms_train_context_t *ctx)
Checks if a driver text message acknowledgement is currently pending.
void ab_gp_proc_text_message_init(ab_gp_ertms_train_context_t *ctx)
Initializes text message tracking for a train context.
bool ab_gp_proc_text_message_send(ab_gp_ertms_train_context_t *ctx, uint8_t nid_textmessage, uint8_t q_textclass, uint8_t q_textconfirm, uint32_t duration_s, const char *text, rbc_packet_72_text_message_t *out_p72)
Dispatches a plain text message to the driver DMI (Subset-026 §5.12 / Packet 72).
ERTMS Subset-026 §5.12 Plain Text Message to Driver (Packet 72) Procedure.
Complete ERTMS state and procedure context for one train slot.
ab_gp_ertms_text_msg_record_t text_msg
char text[RBC_MAX_TEXT_MESSAGE_LEN]