43
43
/*
44
44
* Declaring the CI_LAB_IngestBuffer as a union
45
45
* ensures it is aligned appropriately to
46
- * store a CFE_MSG_Message_t type.
46
+ * store a CFE_SB_Msg_t type.
47
47
*/
48
48
typedef union
49
49
{
50
- CFE_MSG_Message_t MsgHdr ;
51
- uint8 bytes [CI_LAB_MAX_INGEST ];
52
- uint16 hwords [2 ];
50
+ CFE_SB_Msg_t SBMsg ;
51
+ uint8 bytes [CI_LAB_MAX_INGEST ];
52
+ uint16 hwords [2 ];
53
53
} CI_LAB_IngestBuffer_t ;
54
54
55
55
typedef union
56
56
{
57
- CFE_MSG_Message_t MsgHdr ;
58
- CI_LAB_HkTlm_t HkTlm ;
57
+ CFE_SB_Msg_t SBMsg ;
58
+ CI_LAB_HkTlm_t HkTlm ;
59
59
} CI_LAB_HkTlm_Buffer_t ;
60
60
61
61
typedef struct
62
62
{
63
63
bool SocketConnected ;
64
64
CFE_SB_PipeId_t CommandPipe ;
65
- CFE_MSG_Message_t * MsgPtr ;
66
65
osal_id_t SocketID ;
67
66
OS_SockAddr_t SocketAddress ;
68
67
@@ -87,7 +86,9 @@ static CFE_EVS_BinFilter_t CI_LAB_EventFilters[] =
87
86
*/
88
87
int32 CI_LAB_Noop (const CI_LAB_Noop_t * data );
89
88
int32 CI_LAB_ResetCounters (const CI_LAB_ResetCounters_t * data );
90
- int32 CI_LAB_ReportHousekeeping (const CFE_SB_CmdHdr_t * data );
89
+
90
+ /* Housekeeping message handler */
91
+ int32 CI_LAB_ReportHousekeeping (const CFE_MSG_CommandHeader_t * data );
91
92
92
93
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
93
94
/* CI_Lab_AppMain() -- Application entry point and main process loop */
@@ -101,8 +102,9 @@ int32 CI_LAB_ReportHousekeeping(const CFE_SB_CmdHdr_t *data);
101
102
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
102
103
void CI_Lab_AppMain (void )
103
104
{
104
- int32 status ;
105
- uint32 RunStatus = CFE_ES_RunStatus_APP_RUN ;
105
+ int32 status ;
106
+ uint32 RunStatus = CFE_ES_RunStatus_APP_RUN ;
107
+ CFE_SB_Msg_t * SBMsgPtr ;
106
108
107
109
CFE_ES_PerfLogEntry (CI_LAB_MAIN_TASK_PERF_ID );
108
110
@@ -116,13 +118,13 @@ void CI_Lab_AppMain(void)
116
118
CFE_ES_PerfLogExit (CI_LAB_MAIN_TASK_PERF_ID );
117
119
118
120
/* Pend on receipt of command packet -- timeout set to 500 millisecs */
119
- status = CFE_SB_RcvMsg (& CI_LAB_Global . MsgPtr , CI_LAB_Global .CommandPipe , 500 );
121
+ status = CFE_SB_RcvMsg (& SBMsgPtr , CI_LAB_Global .CommandPipe , 500 );
120
122
121
123
CFE_ES_PerfLogEntry (CI_LAB_MAIN_TASK_PERF_ID );
122
124
123
125
if (status == CFE_SUCCESS )
124
126
{
125
- CI_LAB_ProcessCommandPacket ();
127
+ CI_LAB_ProcessCommandPacket (SBMsgPtr );
126
128
}
127
129
128
130
/* Regardless of packet vs timeout, always process uplink queue */
@@ -201,7 +203,7 @@ void CI_LAB_TaskInit(void)
201
203
*/
202
204
OS_TaskInstallDeleteHandler (& CI_LAB_delete_callback );
203
205
204
- CFE_MSG_Init (& CI_LAB_Global .HkBuffer .HkTlm . TlmHeader . BaseMsg , CI_LAB_HK_TLM_MID , CI_LAB_HK_TLM_LNGTH );
206
+ CFE_MSG_Init (& CI_LAB_Global .HkBuffer .SBMsg . Msg , CI_LAB_HK_TLM_MID , CI_LAB_HK_TLM_LNGTH );
205
207
206
208
CFE_EVS_SendEvent (CI_LAB_STARTUP_INF_EID , CFE_EVS_EventType_INFORMATION , "CI Lab Initialized.%s" ,
207
209
CI_LAB_VERSION_STRING );
@@ -220,20 +222,20 @@ void CI_LAB_TaskInit(void)
220
222
/* 3. Request for housekeeping telemetry packet (from HS task) */
221
223
/* */
222
224
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
223
- void CI_LAB_ProcessCommandPacket (void )
225
+ void CI_LAB_ProcessCommandPacket (CFE_SB_Msg_t * SBMsgPtr )
224
226
{
225
227
CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID ;
226
228
227
- CFE_MSG_GetMsgId (CI_LAB_Global . MsgPtr , & MsgId );
229
+ CFE_MSG_GetMsgId (& SBMsgPtr -> Msg , & MsgId );
228
230
229
231
switch (CFE_SB_MsgIdToValue (MsgId ))
230
232
{
231
233
case CI_LAB_CMD_MID :
232
- CI_LAB_ProcessGroundCommand ();
234
+ CI_LAB_ProcessGroundCommand (SBMsgPtr );
233
235
break ;
234
236
235
237
case CI_LAB_SEND_HK_MID :
236
- CI_LAB_ReportHousekeeping ((const CFE_SB_CmdHdr_t * )CI_LAB_Global . MsgPtr );
238
+ CI_LAB_ReportHousekeeping ((const CFE_MSG_CommandHeader_t * )SBMsgPtr );
237
239
break ;
238
240
239
241
default :
@@ -253,21 +255,27 @@ void CI_LAB_ProcessCommandPacket(void)
253
255
/* */
254
256
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
255
257
256
- void CI_LAB_ProcessGroundCommand (void )
258
+ void CI_LAB_ProcessGroundCommand (CFE_SB_Msg_t * SBMsgPtr )
257
259
{
258
260
CFE_MSG_FcnCode_t CommandCode = 0 ;
259
261
260
- CFE_MSG_GetFcnCode (CI_LAB_Global . MsgPtr , & CommandCode );
262
+ CFE_MSG_GetFcnCode (& SBMsgPtr -> Msg , & CommandCode );
261
263
262
264
/* Process "known" CI task ground commands */
263
265
switch (CommandCode )
264
266
{
265
267
case CI_LAB_NOOP_CC :
266
- CI_LAB_Noop ((const CI_LAB_Noop_t * )CI_LAB_Global .MsgPtr );
268
+ if (CI_LAB_VerifyCmdLength (& SBMsgPtr -> Msg , sizeof (CI_LAB_Noop_t )))
269
+ {
270
+ CI_LAB_Noop ((const CI_LAB_Noop_t * )SBMsgPtr );
271
+ }
267
272
break ;
268
273
269
274
case CI_LAB_RESET_COUNTERS_CC :
270
- CI_LAB_ResetCounters ((const CI_LAB_ResetCounters_t * )CI_LAB_Global .MsgPtr );
275
+ if (CI_LAB_VerifyCmdLength (& SBMsgPtr -> Msg , sizeof (CI_LAB_ResetCounters_t )))
276
+ {
277
+ CI_LAB_ResetCounters ((const CI_LAB_ResetCounters_t * )SBMsgPtr );
278
+ }
271
279
break ;
272
280
273
281
/* default case already found during FC vs length test */
@@ -319,11 +327,11 @@ int32 CI_LAB_ResetCounters(const CI_LAB_ResetCounters_t *data)
319
327
/* telemetry, packetize it and send it to the housekeeping task via */
320
328
/* the software bus */
321
329
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
322
- int32 CI_LAB_ReportHousekeeping (const CFE_SB_CmdHdr_t * data )
330
+ int32 CI_LAB_ReportHousekeeping (const CFE_MSG_CommandHeader_t * data )
323
331
{
324
332
CI_LAB_Global .HkBuffer .HkTlm .Payload .SocketConnected = CI_LAB_Global .SocketConnected ;
325
- CFE_SB_TimeStampMsg (& CI_LAB_Global .HkBuffer .MsgHdr );
326
- CFE_SB_SendMsg (& CI_LAB_Global .HkBuffer .MsgHdr );
333
+ CFE_SB_TimeStampMsg (& CI_LAB_Global .HkBuffer .HkTlm . TlmHeader );
334
+ CFE_SB_SendMsg (& CI_LAB_Global .HkBuffer .SBMsg );
327
335
return CFE_SUCCESS ;
328
336
329
337
} /* End of CI_LAB_ReportHousekeeping() */
0 commit comments