3434#include "to_lab_perfids.h"
3535#include "to_lab_version.h"
3636#include "to_lab_sub_table.h"
37+ #include "cfe_msg_api.h"
3738
3839/*
3940** Global Data Section
4041*/
41- typedef union
42- {
43- CFE_SB_Msg_t MsgHdr ;
44- TO_LAB_HkTlm_t HkTlm ;
45- } TO_LAB_HkTlm_Buffer_t ;
46-
47- typedef union
48- {
49- CFE_SB_Msg_t MsgHdr ;
50- TO_LAB_DataTypes_t DataTypes ;
51- } TO_LAB_DataTypes_Buffer_t ;
52-
5342typedef struct
5443{
5544 CFE_SB_PipeId_t Tlm_pipe ;
@@ -59,8 +48,8 @@ typedef struct
5948 char tlm_dest_IP [17 ];
6049 bool suppress_sendto ;
6150
62- TO_LAB_HkTlm_Buffer_t HkBuf ;
63- TO_LAB_DataTypes_Buffer_t DataTypesBuf ;
51+ TO_LAB_HkTlm_t HkTlm ;
52+ TO_LAB_DataTypesTlm_t DataTypesTlm ;
6453} TO_LAB_GlobalData_t ;
6554
6655TO_LAB_GlobalData_t TO_LAB_Global ;
@@ -81,7 +70,7 @@ static CFE_EVS_BinFilter_t CFE_TO_EVS_Filters[] = {/* Event ID mask */
8170*/
8271void TO_LAB_openTLM (void );
8372int32 TO_LAB_init (void );
84- void TO_LAB_exec_local_command (CFE_SB_MsgPtr_t cmd );
73+ void TO_LAB_exec_local_command (CFE_MSG_Message_t * MsgPtr );
8574void TO_LAB_process_commands (void );
8675void TO_LAB_forward_telemetry (void );
8776
@@ -179,7 +168,7 @@ int32 TO_LAB_init(void)
179168 /*
180169 ** Initialize housekeeping packet (clear user data area)...
181170 */
182- CFE_SB_InitMsg (& TO_LAB_Global .HkBuf . MsgHdr , TO_LAB_HK_TLM_MID , sizeof (TO_LAB_Global .HkBuf . HkTlm ), true );
171+ CFE_MSG_Init (& TO_LAB_Global .HkTlm . TlmHeader . BaseMsg , TO_LAB_HK_TLM_MID , sizeof (TO_LAB_Global .HkTlm ));
183172
184173 status = CFE_TBL_Register (& TO_SubTblHandle , "TO_LAB_Subs" , sizeof (* TO_LAB_Subs ), CFE_TBL_OPT_DEFAULT , NULL );
185174
@@ -276,7 +265,7 @@ int32 TO_LAB_EnableOutput(const TO_LAB_EnableOutput_t *data)
276265 TO_LAB_Global .downlink_on = true;
277266 }
278267
279- ++ TO_LAB_Global .HkBuf . HkTlm .Payload .CommandCounter ;
268+ ++ TO_LAB_Global .HkTlm .Payload .CommandCounter ;
280269 return CFE_SUCCESS ;
281270} /* End of TO_LAB_EnableOutput() */
282271
@@ -287,16 +276,17 @@ int32 TO_LAB_EnableOutput(const TO_LAB_EnableOutput_t *data)
287276/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
288277void TO_LAB_process_commands (void )
289278{
290- CFE_SB_Msg_t * MsgPtr ;
291- CFE_SB_MsgId_t MsgId ;
279+ CFE_MSG_Message_t * MsgPtr ;
280+ CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID ;
292281
293282 while (1 )
294283 {
295284 switch (CFE_SB_RcvMsg (& MsgPtr , TO_LAB_Global .Cmd_pipe , CFE_SB_POLL ))
296285 {
297286 case CFE_SUCCESS :
298287
299- MsgId = CFE_SB_GetMsgId (MsgPtr );
288+ CFE_MSG_GetMsgId (MsgPtr , & MsgId );
289+
300290 /* For SB return statuses that imply a message: process it. */
301291 switch (CFE_SB_MsgIdToValue (MsgId ))
302292 {
@@ -326,45 +316,47 @@ void TO_LAB_process_commands(void)
326316/* TO_exec_local_command() -- Process local message */
327317/* */
328318/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
329- void TO_LAB_exec_local_command (CFE_SB_MsgPtr_t cmd )
319+ void TO_LAB_exec_local_command (CFE_MSG_Message_t * MsgPtr )
330320{
331- uint16 CommandCode ;
332- CommandCode = CFE_SB_GetCmdCode (cmd );
321+ CFE_MSG_FcnCode_t CommandCode = 0 ;
322+
323+ CFE_MSG_GetFcnCode (MsgPtr , & CommandCode );
333324
334325 switch (CommandCode )
335326 {
336327 case TO_NOP_CC :
337- TO_LAB_Noop ((const TO_LAB_Noop_t * )cmd );
328+ TO_LAB_Noop ((const TO_LAB_Noop_t * )MsgPtr );
338329 break ;
339330
340331 case TO_RESET_STATUS_CC :
341- TO_LAB_ResetCounters ((const TO_LAB_ResetCounters_t * )cmd );
332+ TO_LAB_ResetCounters ((const TO_LAB_ResetCounters_t * )MsgPtr );
342333 break ;
343334
344335 case TO_SEND_DATA_TYPES_CC :
345- TO_LAB_SendDataTypes ((const TO_LAB_SendDataTypes_t * )cmd );
336+ TO_LAB_SendDataTypes ((const TO_LAB_SendDataTypes_t * )MsgPtr );
346337 break ;
347338
348339 case TO_ADD_PKT_CC :
349- TO_LAB_AddPacket ((const TO_LAB_AddPacket_t * )cmd );
340+ TO_LAB_AddPacket ((const TO_LAB_AddPacket_t * )MsgPtr );
350341 break ;
351342
352343 case TO_REMOVE_PKT_CC :
353- TO_LAB_RemovePacket ((const TO_LAB_RemovePacket_t * )cmd );
344+ TO_LAB_RemovePacket ((const TO_LAB_RemovePacket_t * )MsgPtr );
354345 break ;
355346
356347 case TO_REMOVE_ALL_PKT_CC :
357- TO_LAB_RemoveAll ((const TO_LAB_RemoveAll_t * )cmd );
348+ TO_LAB_RemoveAll ((const TO_LAB_RemoveAll_t * )MsgPtr );
358349 break ;
359350
360351 case TO_OUTPUT_ENABLE_CC :
361- TO_LAB_EnableOutput ((const TO_LAB_EnableOutput_t * )cmd );
352+ TO_LAB_EnableOutput ((const TO_LAB_EnableOutput_t * )MsgPtr );
362353 break ;
363354
364355 default :
365356 CFE_EVS_SendEvent (TO_FNCODE_ERR_EID , CFE_EVS_EventType_ERROR ,
366- "L%d TO: Invalid Function Code Rcvd In Ground Command 0x%x" , __LINE__ , CommandCode );
367- ++ TO_LAB_Global .HkBuf .HkTlm .Payload .CommandErrorCounter ;
357+ "L%d TO: Invalid Function Code Rcvd In Ground Command 0x%x" , __LINE__ ,
358+ (unsigned int )CommandCode );
359+ ++ TO_LAB_Global .HkTlm .Payload .CommandErrorCounter ;
368360 }
369361
370362} /* End of TO_exec_local_command() */
@@ -377,7 +369,7 @@ void TO_LAB_exec_local_command(CFE_SB_MsgPtr_t cmd)
377369int32 TO_LAB_Noop (const TO_LAB_Noop_t * data )
378370{
379371 CFE_EVS_SendEvent (TO_NOOP_INF_EID , CFE_EVS_EventType_INFORMATION , "No-op command" );
380- ++ TO_LAB_Global .HkBuf . HkTlm .Payload .CommandCounter ;
372+ ++ TO_LAB_Global .HkTlm .Payload .CommandCounter ;
381373 return CFE_SUCCESS ;
382374}
383375
@@ -388,8 +380,8 @@ int32 TO_LAB_Noop(const TO_LAB_Noop_t *data)
388380/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
389381int32 TO_LAB_ResetCounters (const TO_LAB_ResetCounters_t * data )
390382{
391- TO_LAB_Global .HkBuf . HkTlm .Payload .CommandErrorCounter = 0 ;
392- TO_LAB_Global .HkBuf . HkTlm .Payload .CommandCounter = 0 ;
383+ TO_LAB_Global .HkTlm .Payload .CommandErrorCounter = 0 ;
384+ TO_LAB_Global .HkTlm .Payload .CommandCounter = 0 ;
393385 return CFE_SUCCESS ;
394386} /* End of TO_LAB_ResetCounters() */
395387
@@ -404,43 +396,43 @@ int32 TO_LAB_SendDataTypes(const TO_LAB_SendDataTypes_t *data)
404396 char string_variable [10 ] = "ABCDEFGHIJ" ;
405397
406398 /* initialize data types packet */
407- CFE_SB_InitMsg (& TO_LAB_Global .DataTypesBuf . MsgHdr , TO_LAB_DATA_TYPES_MID ,
408- sizeof (TO_LAB_Global .DataTypesBuf . DataTypes ), true );
399+ CFE_MSG_Init (& TO_LAB_Global .DataTypesTlm . TlmHeader . BaseMsg , TO_LAB_DATA_TYPES_MID ,
400+ sizeof (TO_LAB_Global .DataTypesTlm ) );
409401
410- CFE_SB_TimeStampMsg (& TO_LAB_Global .DataTypesBuf . MsgHdr );
402+ CFE_SB_TimeStampMsg (& TO_LAB_Global .DataTypesTlm . TlmHeader . BaseMsg );
411403
412404 /* initialize the packet data */
413- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .synch = 0x6969 ;
405+ TO_LAB_Global .DataTypesTlm .Payload .synch = 0x6969 ;
414406#if 0
415- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .bit1 = 1 ;
416- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .bit2 = 0 ;
417- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .bit34 = 2 ;
418- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .bit56 = 3 ;
419- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .bit78 = 1 ;
420- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .nibble1 = 0xA ;
421- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .nibble2 = 0x4 ;
407+ TO_LAB_Global .DataTypesTlm .Payload .bit1 = 1 ;
408+ TO_LAB_Global .DataTypesTlm .Payload .bit2 = 0 ;
409+ TO_LAB_Global .DataTypesTlm .Payload .bit34 = 2 ;
410+ TO_LAB_Global .DataTypesTlm .Payload .bit56 = 3 ;
411+ TO_LAB_Global .DataTypesTlm .Payload .bit78 = 1 ;
412+ TO_LAB_Global .DataTypesTlm .Payload .nibble1 = 0xA ;
413+ TO_LAB_Global .DataTypesTlm .Payload .nibble2 = 0x4 ;
422414#endif
423- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .bl1 = false;
424- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .bl2 = true;
425- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .b1 = 16 ;
426- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .b2 = 127 ;
427- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .b3 = 0x7F ;
428- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .b4 = 0x45 ;
429- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .w1 = 0x2468 ;
430- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .w2 = 0x7FFF ;
431- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .dw1 = 0x12345678 ;
432- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .dw2 = 0x87654321 ;
433- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .f1 = 90.01 ;
434- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .f2 = .0000045 ;
435- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .df1 = 99.9 ;
436- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .df2 = .4444 ;
415+ TO_LAB_Global .DataTypesTlm .Payload .bl1 = false;
416+ TO_LAB_Global .DataTypesTlm .Payload .bl2 = true;
417+ TO_LAB_Global .DataTypesTlm .Payload .b1 = 16 ;
418+ TO_LAB_Global .DataTypesTlm .Payload .b2 = 127 ;
419+ TO_LAB_Global .DataTypesTlm .Payload .b3 = 0x7F ;
420+ TO_LAB_Global .DataTypesTlm .Payload .b4 = 0x45 ;
421+ TO_LAB_Global .DataTypesTlm .Payload .w1 = 0x2468 ;
422+ TO_LAB_Global .DataTypesTlm .Payload .w2 = 0x7FFF ;
423+ TO_LAB_Global .DataTypesTlm .Payload .dw1 = 0x12345678 ;
424+ TO_LAB_Global .DataTypesTlm .Payload .dw2 = 0x87654321 ;
425+ TO_LAB_Global .DataTypesTlm .Payload .f1 = 90.01 ;
426+ TO_LAB_Global .DataTypesTlm .Payload .f2 = .0000045 ;
427+ TO_LAB_Global .DataTypesTlm .Payload .df1 = 99.9 ;
428+ TO_LAB_Global .DataTypesTlm .Payload .df2 = .4444 ;
437429
438430 for (i = 0 ; i < 10 ; i ++ )
439- TO_LAB_Global .DataTypesBuf . DataTypes .Payload .str [i ] = string_variable [i ];
431+ TO_LAB_Global .DataTypesTlm .Payload .str [i ] = string_variable [i ];
440432
441- CFE_SB_SendMsg (& TO_LAB_Global .DataTypesBuf . MsgHdr );
433+ CFE_SB_SendMsg (& TO_LAB_Global .DataTypesTlm . TlmHeader . BaseMsg );
442434
443- ++ TO_LAB_Global .HkBuf . HkTlm .Payload .CommandCounter ;
435+ ++ TO_LAB_Global .HkTlm .Payload .CommandCounter ;
444436 return CFE_SUCCESS ;
445437} /* End of TO_LAB_SendDataTypes() */
446438
@@ -451,8 +443,8 @@ int32 TO_LAB_SendDataTypes(const TO_LAB_SendDataTypes_t *data)
451443/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
452444int32 TO_LAB_SendHousekeeping (const CFE_SB_CmdHdr_t * data )
453445{
454- CFE_SB_TimeStampMsg (& TO_LAB_Global .HkBuf . MsgHdr );
455- CFE_SB_SendMsg (& TO_LAB_Global .HkBuf . MsgHdr );
446+ CFE_SB_TimeStampMsg (& TO_LAB_Global .HkTlm . TlmHeader . BaseMsg );
447+ CFE_SB_SendMsg (& TO_LAB_Global .HkTlm . TlmHeader . BaseMsg );
456448 return CFE_SUCCESS ;
457449} /* End of TO_LAB_SendHousekeeping() */
458450
@@ -496,7 +488,7 @@ int32 TO_LAB_AddPacket(const TO_LAB_AddPacket_t *data)
496488 __LINE__ , (unsigned int )CFE_SB_MsgIdToValue (pCmd -> Stream ), pCmd -> Flags .Priority ,
497489 pCmd -> Flags .Reliability , pCmd -> BufLimit );
498490
499- ++ TO_LAB_Global .HkBuf . HkTlm .Payload .CommandCounter ;
491+ ++ TO_LAB_Global .HkTlm .Payload .CommandCounter ;
500492 return CFE_SUCCESS ;
501493} /* End of TO_AddPkt() */
502494
@@ -518,7 +510,7 @@ int32 TO_LAB_RemovePacket(const TO_LAB_RemovePacket_t *data)
518510 else
519511 CFE_EVS_SendEvent (TO_REMOVEPKT_INF_EID , CFE_EVS_EventType_INFORMATION , "L%d TO RemovePkt 0x%x" , __LINE__ ,
520512 (unsigned int )CFE_SB_MsgIdToValue (pCmd -> Stream ));
521- ++ TO_LAB_Global .HkBuf . HkTlm .Payload .CommandCounter ;
513+ ++ TO_LAB_Global .HkTlm .Payload .CommandCounter ;
522514 return CFE_SUCCESS ;
523515} /* End of TO_LAB_RemovePacket() */
524516
@@ -561,7 +553,7 @@ int32 TO_LAB_RemoveAll(const TO_LAB_RemoveAll_t *data)
561553 CFE_EVS_SendEvent (TO_REMOVEALLPKTS_INF_EID , CFE_EVS_EventType_INFORMATION ,
562554 "L%d TO Unsubscribed to all Commands and Telemetry" , __LINE__ );
563555
564- ++ TO_LAB_Global .HkBuf . HkTlm .Payload .CommandCounter ;
556+ ++ TO_LAB_Global .HkTlm .Payload .CommandCounter ;
565557 return CFE_SUCCESS ;
566558} /* End of TO_LAB_RemoveAll() */
567559
@@ -572,11 +564,11 @@ int32 TO_LAB_RemoveAll(const TO_LAB_RemoveAll_t *data)
572564/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
573565void TO_LAB_forward_telemetry (void )
574566{
575- OS_SockAddr_t d_addr ;
576- int32 status ;
577- int32 CFE_SB_status ;
578- uint16 size ;
579- CFE_SB_Msg_t * PktPtr ;
567+ OS_SockAddr_t d_addr ;
568+ int32 status ;
569+ int32 CFE_SB_status ;
570+ CFE_MSG_Size_t size ;
571+ CFE_MSG_Message_t * PktPtr ;
580572
581573 OS_SocketAddrInit (& d_addr , OS_SocketDomain_INET );
582574 OS_SocketAddrSetPort (& d_addr , cfgTLM_PORT );
@@ -589,7 +581,7 @@ void TO_LAB_forward_telemetry(void)
589581
590582 if ((CFE_SB_status == CFE_SUCCESS ) && (TO_LAB_Global .suppress_sendto == false))
591583 {
592- size = CFE_SB_GetTotalMsgLength (PktPtr );
584+ CFE_MSG_GetSize (PktPtr , & size );
593585
594586 if (TO_LAB_Global .downlink_on == true)
595587 {
0 commit comments