diff --git a/modules/msg/mission_inc/default_cfe_msg_hdr_pri.h b/modules/msg/mission_inc/default_cfe_msg_hdr_pri.h index d422106db..0e8558d5d 100644 --- a/modules/msg/mission_inc/default_cfe_msg_hdr_pri.h +++ b/modules/msg/mission_inc/default_cfe_msg_hdr_pri.h @@ -54,14 +54,23 @@ typedef struct CCSDS_PrimaryHeader_t Pri; /**< \brief CCSDS Primary Header */ } CCSDS_SpacePacket_t; +/** + * \brief cFS generic base message + */ +typedef union +{ + CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS Header (Pri or Pri + Ext) */ + uint8 Byte[sizeof(CCSDS_SpacePacket_t)]; /**< \brief Byte level access */ +} CFE_MSG_Message_t; + /** * \brief cFS command header */ typedef struct { - CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS header */ - CFE_MSG_CommandSecondaryHeader_t Sec; /**< \brief Secondary header */ + CFE_MSG_Message_t Msg; /**< \brief Base message */ + CFE_MSG_CommandSecondaryHeader_t Sec; /**< \brief Secondary header */ } CFE_MSG_CommandHeader_t; @@ -71,19 +80,9 @@ typedef struct typedef struct { - CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS header */ - CFE_MSG_TelemetrySecondaryHeader_t Sec; /**< \brief Secondary header */ + CFE_MSG_Message_t Msg; /**< \brief Base message */ + CFE_MSG_TelemetrySecondaryHeader_t Sec; /**< \brief Secondary header */ } CFE_MSG_TelemetryHeader_t; -/** - * \brief cFS Generic packet header - */ -typedef union -{ - CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS Header (Pri or Pri + Ext) */ - uint32 Align; /**< \brief Force 32-bit alignment */ - uint8 Byte[sizeof(CCSDS_SpacePacket_t)]; /**< \brief Byte level access */ -} CFE_MSG_Message_t; - #endif /* _cfe_msg_hdr_ */ diff --git a/modules/msg/mission_inc/default_cfe_msg_hdr_priext.h b/modules/msg/mission_inc/default_cfe_msg_hdr_priext.h index 652925269..aa401bd8b 100644 --- a/modules/msg/mission_inc/default_cfe_msg_hdr_priext.h +++ b/modules/msg/mission_inc/default_cfe_msg_hdr_priext.h @@ -55,14 +55,23 @@ typedef struct CCSDS_ExtendedHeader_t Ext; /**< \brief CCSDS Extended Header */ } CCSDS_SpacePacket_t; +/** + * \brief cFS generic base message + */ +typedef union +{ + CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS Header (Pri or Pri + Ext) */ + uint8 Byte[sizeof(CCSDS_SpacePacket_t)]; /**< \brief Byte level access */ +} CFE_MSG_Message_t; + /** * \brief cFS command header */ typedef struct { - CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS header */ - CFE_MSG_CommandSecondaryHeader_t Sec; /**< \brief Secondary header */ + CFE_MSG_Message_t Msg; /**< \brief Base message */ + CFE_MSG_CommandSecondaryHeader_t Sec; /**< \brief Secondary header */ } CFE_MSG_CommandHeader_t; @@ -72,19 +81,9 @@ typedef struct typedef struct { - CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS header */ - CFE_MSG_TelemetrySecondaryHeader_t Sec; /**< \brief Secondary header */ + CFE_MSG_Message_t Msg; /**< \brief Base message */ + CFE_MSG_TelemetrySecondaryHeader_t Sec; /**< \brief Secondary header */ } CFE_MSG_TelemetryHeader_t; -/** - * \brief cFS Generic packet header - */ -typedef union -{ - CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS Header (Pri or Pri + Ext) */ - uint32 Align; /**< \brief Force 32-bit alignment */ - uint8 Byte[sizeof(CCSDS_SpacePacket_t)]; /**< \brief Byte level access */ -} CFE_MSG_Message_t; - #endif /* _cfe_msg_hdr_ */ diff --git a/modules/msg/src/cfe_msg_sechdr_checksum.c b/modules/msg/src/cfe_msg_sechdr_checksum.c index ceb8ef0b9..a958250ab 100644 --- a/modules/msg/src/cfe_msg_sechdr_checksum.c +++ b/modules/msg/src/cfe_msg_sechdr_checksum.c @@ -35,7 +35,7 @@ CFE_MSG_Checksum_t CFE_MSG_ComputeCheckSum(const CFE_MSG_Message_t *MsgPtr) { - uint32 PktLen = 0; + CFE_MSG_Size_t PktLen = 0; const uint8 * BytePtr = MsgPtr->Byte; CFE_MSG_Checksum_t chksum = 0xFF; diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_checksum.c b/modules/msg/unit-test-coverage/test_cfe_msg_checksum.c index b4bdfe7f0..304b171df 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_checksum.c +++ b/modules/msg/unit-test-coverage/test_cfe_msg_checksum.c @@ -36,9 +36,9 @@ void Test_MSG_Checksum(void) { - CFE_SB_CmdHdr_t cmd; - CFE_MSG_Message_t *msgptr = (CFE_MSG_Message_t *)&cmd; - bool actual; + CFE_MSG_CommandHeader_t cmd; + CFE_MSG_Message_t *msgptr = &cmd.Msg; + bool actual; UtPrintf("Bad parameter tests, Null pointers"); memset(&cmd, 0, sizeof(cmd)); diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_fc.c b/modules/msg/unit-test-coverage/test_cfe_msg_fc.c index 56f6c851d..664fa4b1e 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_fc.c +++ b/modules/msg/unit-test-coverage/test_cfe_msg_fc.c @@ -41,11 +41,11 @@ void Test_MSG_FcnCode(void) { - CFE_SB_CmdHdr_t cmd; - CFE_MSG_Message_t *msgptr = (CFE_MSG_Message_t *)&cmd; - CFE_MSG_FcnCode_t input[] = {0, TEST_FCNCODE_MAX / 2, TEST_FCNCODE_MAX}; - CFE_MSG_FcnCode_t actual = TEST_FCNCODE_MAX; - int i; + CFE_MSG_CommandHeader_t cmd; + CFE_MSG_Message_t *msgptr = &cmd.Msg; + CFE_MSG_FcnCode_t input[] = {0, TEST_FCNCODE_MAX / 2, TEST_FCNCODE_MAX}; + CFE_MSG_FcnCode_t actual = TEST_FCNCODE_MAX; + int i; UtPrintf("Bad parameter tests, Null pointers, invalid (max valid + 1, max)"); memset(&cmd, 0, sizeof(cmd)); diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_init.c b/modules/msg/unit-test-coverage/test_cfe_msg_init.c index 33964762e..3cf9bc2f4 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_init.c +++ b/modules/msg/unit-test-coverage/test_cfe_msg_init.c @@ -43,7 +43,7 @@ void Test_MSG_Init(void) { - CFE_MSG_Message_t msg; + CFE_MSG_CommandHeader_t cmd; CFE_MSG_Size_t size; CFE_SB_MsgId_Atom_t msgidval_exp; CFE_SB_MsgId_t msgid_act; @@ -54,28 +54,28 @@ void Test_MSG_Init(void) bool is_v1; UtPrintf("Bad parameter tests, Null pointer, invalid size, invalid msgid"); - ASSERT_EQ(CFE_MSG_Init(NULL, CFE_SB_ValueToMsgId(0), sizeof(msg)), CFE_MSG_BAD_ARGUMENT); - ASSERT_EQ(CFE_MSG_Init(&msg, CFE_SB_ValueToMsgId(0), 0), CFE_MSG_BAD_ARGUMENT); - ASSERT_EQ(CFE_MSG_Init(&msg, CFE_SB_ValueToMsgId(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1), sizeof(msg)), + ASSERT_EQ(CFE_MSG_Init(NULL, CFE_SB_ValueToMsgId(0), sizeof(cmd)), CFE_MSG_BAD_ARGUMENT); + ASSERT_EQ(CFE_MSG_Init(&cmd.Msg, CFE_SB_ValueToMsgId(0), 0), CFE_MSG_BAD_ARGUMENT); + ASSERT_EQ(CFE_MSG_Init(&cmd.Msg, CFE_SB_ValueToMsgId(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1), sizeof(cmd)), CFE_MSG_BAD_ARGUMENT); - ASSERT_EQ(CFE_MSG_Init(&msg, CFE_SB_ValueToMsgId(-1), sizeof(msg)), CFE_MSG_BAD_ARGUMENT); + ASSERT_EQ(CFE_MSG_Init(&cmd.Msg, CFE_SB_ValueToMsgId(-1), sizeof(cmd)), CFE_MSG_BAD_ARGUMENT); UtPrintf("Set to all F's, msgid value = 0"); - memset(&msg, 0xFF, sizeof(msg)); + memset(&cmd, 0xFF, sizeof(cmd)); msgidval_exp = 0; - ASSERT_EQ(CFE_MSG_Init(&msg, CFE_SB_ValueToMsgId(msgidval_exp), sizeof(msg)), CFE_SUCCESS); - Test_MSG_PrintMsg(&msg, 0); - ASSERT_EQ(CFE_MSG_GetMsgId(&msg, &msgid_act), CFE_SUCCESS); + ASSERT_EQ(CFE_MSG_Init(&cmd.Msg, CFE_SB_ValueToMsgId(msgidval_exp), sizeof(cmd)), CFE_SUCCESS); + Test_MSG_PrintMsg(&cmd.Msg, 0); + ASSERT_EQ(CFE_MSG_GetMsgId(&cmd.Msg, &msgid_act), CFE_SUCCESS); ASSERT_EQ(CFE_SB_MsgIdToValue(msgid_act), msgidval_exp); - ASSERT_EQ(CFE_MSG_GetSize(&msg, &size), CFE_SUCCESS); - ASSERT_EQ(size, sizeof(msg)); - ASSERT_EQ(CFE_MSG_GetSegmentationFlag(&msg, &segflag), CFE_SUCCESS); + ASSERT_EQ(CFE_MSG_GetSize(&cmd.Msg, &size), CFE_SUCCESS); + ASSERT_EQ(size, sizeof(cmd)); + ASSERT_EQ(CFE_MSG_GetSegmentationFlag(&cmd.Msg, &segflag), CFE_SUCCESS); ASSERT_EQ(segflag, CFE_MSG_SegFlag_Unsegmented); - ASSERT_EQ(CFE_MSG_GetApId(&msg, &apid), CFE_SUCCESS); - ASSERT_EQ(CFE_MSG_GetHeaderVersion(&msg, &hdrver), CFE_SUCCESS); - ASSERT_EQ(CFE_MSG_GetHasSecondaryHeader(&msg, &hassec), CFE_SUCCESS); + ASSERT_EQ(CFE_MSG_GetApId(&cmd.Msg, &apid), CFE_SUCCESS); + ASSERT_EQ(CFE_MSG_GetHeaderVersion(&cmd.Msg, &hdrver), CFE_SUCCESS); + ASSERT_EQ(CFE_MSG_GetHasSecondaryHeader(&cmd.Msg, &hassec), CFE_SUCCESS); /* A zero msgid will set hassec to false for v1 */ is_v1 = !hassec; @@ -92,25 +92,25 @@ void Test_MSG_Init(void) } /* Confirm the rest of the fields not already explicitly checked */ - ASSERT_EQ(Test_MSG_Pri_NotZero(&msg) & ~(MSG_APID_FLAG | MSG_HDRVER_FLAG | MSG_HASSEC_FLAG), + ASSERT_EQ(Test_MSG_Pri_NotZero(&cmd.Msg) & ~(MSG_APID_FLAG | MSG_HDRVER_FLAG | MSG_HASSEC_FLAG), MSG_LENGTH_FLAG | MSG_SEGMENT_FLAG); UtPrintf("Set to all 0, max msgid value"); - memset(&msg, 0, sizeof(msg)); + memset(&cmd, 0, sizeof(cmd)); msgidval_exp = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID; - ASSERT_EQ(CFE_MSG_Init(&msg, CFE_SB_ValueToMsgId(msgidval_exp), sizeof(msg)), CFE_SUCCESS); - Test_MSG_PrintMsg(&msg, 0); - ASSERT_EQ(CFE_MSG_GetMsgId(&msg, &msgid_act), CFE_SUCCESS); + ASSERT_EQ(CFE_MSG_Init(&cmd.Msg, CFE_SB_ValueToMsgId(msgidval_exp), sizeof(cmd)), CFE_SUCCESS); + Test_MSG_PrintMsg(&cmd.Msg, 0); + ASSERT_EQ(CFE_MSG_GetMsgId(&cmd.Msg, &msgid_act), CFE_SUCCESS); ASSERT_EQ(CFE_SB_MsgIdToValue(msgid_act), msgidval_exp); - ASSERT_EQ(CFE_MSG_GetSize(&msg, &size), CFE_SUCCESS); - ASSERT_EQ(size, sizeof(msg)); - ASSERT_EQ(CFE_MSG_GetSegmentationFlag(&msg, &segflag), CFE_SUCCESS); + ASSERT_EQ(CFE_MSG_GetSize(&cmd.Msg, &size), CFE_SUCCESS); + ASSERT_EQ(size, sizeof(cmd)); + ASSERT_EQ(CFE_MSG_GetSegmentationFlag(&cmd.Msg, &segflag), CFE_SUCCESS); ASSERT_EQ(segflag, CFE_MSG_SegFlag_Unsegmented); - ASSERT_EQ(CFE_MSG_GetApId(&msg, &apid), CFE_SUCCESS); - ASSERT_EQ(CFE_MSG_GetHeaderVersion(&msg, &hdrver), CFE_SUCCESS); - ASSERT_EQ(CFE_MSG_GetHasSecondaryHeader(&msg, &hassec), CFE_SUCCESS); + ASSERT_EQ(CFE_MSG_GetApId(&cmd.Msg, &apid), CFE_SUCCESS); + ASSERT_EQ(CFE_MSG_GetHeaderVersion(&cmd.Msg, &hdrver), CFE_SUCCESS); + ASSERT_EQ(CFE_MSG_GetHasSecondaryHeader(&cmd.Msg, &hassec), CFE_SUCCESS); ASSERT_EQ(hassec, true); if (!is_v1) { @@ -123,5 +123,6 @@ void Test_MSG_Init(void) ASSERT_EQ(hdrver, 0); } - ASSERT_EQ(Test_MSG_Pri_NotZero(&msg) & ~MSG_HDRVER_FLAG, MSG_APID_FLAG | MSG_HASSEC_FLAG | MSG_TYPE_FLAG | MSG_LENGTH_FLAG | MSG_SEGMENT_FLAG); + ASSERT_EQ(Test_MSG_Pri_NotZero(&cmd.Msg) & ~MSG_HDRVER_FLAG, MSG_APID_FLAG | MSG_HASSEC_FLAG | MSG_TYPE_FLAG | + MSG_LENGTH_FLAG | MSG_SEGMENT_FLAG); } diff --git a/modules/msg/unit-test-coverage/test_cfe_msg_time.c b/modules/msg/unit-test-coverage/test_cfe_msg_time.c index c3ca7e312..cb57d372f 100644 --- a/modules/msg/unit-test-coverage/test_cfe_msg_time.c +++ b/modules/msg/unit-test-coverage/test_cfe_msg_time.c @@ -36,11 +36,11 @@ void Test_MSG_Time(void) { - CFE_SB_TlmHdr_t tlm; - CFE_MSG_Message_t *msgptr = (CFE_MSG_Message_t *)&tlm; - CFE_TIME_SysTime_t input[] = {{0, 0}, {0x12345678, 0xABCDEF12}, {0xFFFFFFFF, 0xFFFFFFFF}}; - CFE_TIME_SysTime_t actual = {0xFFFFFFFF, 0xFFFFFFFF}; - int i; + CFE_MSG_TelemetryHeader_t tlm; + CFE_MSG_Message_t *msgptr = &tlm.Msg; + CFE_TIME_SysTime_t input[] = {{0, 0}, {0x12345678, 0xABCDEF12}, {0xFFFFFFFF, 0xFFFFFFFF}}; + CFE_TIME_SysTime_t actual = {0xFFFFFFFF, 0xFFFFFFFF}; + int i; UtPrintf("Bad parameter tests, Null pointers, no secondary header"); memset(&tlm, 0, sizeof(tlm));