From 204b27f0f772a12e0b9ea80d3d839d7e8666c9eb Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 4 Nov 2020 12:04:16 -0500 Subject: [PATCH 1/3] Fix #103, Use MSG APIs --- fsw/src/sample_app.c | 64 ++++++------ fsw/src/sample_app.h | 22 ++--- fsw/src/sample_app_msg.h | 3 +- .../coveragetest/coveragetest_sample_app.c | 98 ++++++++++++------- 4 files changed, 104 insertions(+), 83 deletions(-) diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index a20fb10..cebe98a 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -43,7 +43,7 @@ SAMPLE_APP_Data_t SAMPLE_APP_Data; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* SAMPLE_APP_Main() -- Application entry point and main process loop */ +/* SAMPLE_APP_Main() -- Application entry point and main process loop */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ void SAMPLE_APP_Main(void) @@ -113,7 +113,7 @@ void SAMPLE_APP_Main(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ -/* SAMPLE_APP_Init() -- initialization */ +/* SAMPLE_APP_Init() -- initialization */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ int32 SAMPLE_APP_Init(void) @@ -168,7 +168,7 @@ int32 SAMPLE_APP_Init(void) /* ** Initialize housekeeping packet (clear user data area). */ - CFE_SB_InitMsg(&SAMPLE_APP_Data.HkBuf.MsgHdr, SAMPLE_APP_HK_TLM_MID, sizeof(SAMPLE_APP_Data.HkBuf), true); + CFE_MSG_Init(&SAMPLE_APP_Data.HkTlm.TlmHeader.BaseMsg, SAMPLE_APP_HK_TLM_MID, sizeof(SAMPLE_APP_Data.HkTlm)); /* ** Create Software Bus message pipe. @@ -225,27 +225,27 @@ int32 SAMPLE_APP_Init(void) } /* End of SAMPLE_APP_Init() */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* Name: SAMPLE_APP_ProcessCommandPacket */ +/* Name: SAMPLE_APP_ProcessCommandPacket */ /* */ /* Purpose: */ /* This routine will process any packet that is received on the SAMPLE */ /* command pipe. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void SAMPLE_APP_ProcessCommandPacket(CFE_SB_MsgPtr_t Msg) +void SAMPLE_APP_ProcessCommandPacket(CFE_MSG_Message_t *MsgPtr) { - CFE_SB_MsgId_t MsgId; + CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; - MsgId = CFE_SB_GetMsgId(Msg); + CFE_MSG_GetMsgId(MsgPtr, &MsgId); switch (MsgId) { case SAMPLE_APP_CMD_MID: - SAMPLE_APP_ProcessGroundCommand(Msg); + SAMPLE_APP_ProcessGroundCommand(MsgPtr); break; case SAMPLE_APP_SEND_HK_MID: - SAMPLE_APP_ReportHousekeeping((CFE_SB_CmdHdr_t *)Msg); + SAMPLE_APP_ReportHousekeeping((CFE_SB_CmdHdr_t *)MsgPtr); break; default: @@ -260,14 +260,14 @@ void SAMPLE_APP_ProcessCommandPacket(CFE_SB_MsgPtr_t Msg) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ /* */ -/* SAMPLE_APP_ProcessGroundCommand() -- SAMPLE ground commands */ +/* SAMPLE_APP_ProcessGroundCommand() -- SAMPLE ground commands */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -void SAMPLE_APP_ProcessGroundCommand(CFE_SB_MsgPtr_t Msg) +void SAMPLE_APP_ProcessGroundCommand(CFE_MSG_Message_t *MsgPtr) { - uint16 CommandCode; + CFE_MSG_FcnCode_t CommandCode = 0; - CommandCode = CFE_SB_GetCmdCode(Msg); + CFE_MSG_GetFcnCode(MsgPtr, &CommandCode); /* ** Process "known" SAMPLE app ground commands @@ -275,25 +275,25 @@ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_MsgPtr_t Msg) switch (CommandCode) { case SAMPLE_APP_NOOP_CC: - if (SAMPLE_APP_VerifyCmdLength(Msg, sizeof(SAMPLE_APP_Noop_t))) + if (SAMPLE_APP_VerifyCmdLength(MsgPtr, sizeof(SAMPLE_APP_Noop_t))) { - SAMPLE_APP_Noop((SAMPLE_APP_Noop_t *)Msg); + SAMPLE_APP_Noop((SAMPLE_APP_Noop_t *)MsgPtr); } break; case SAMPLE_APP_RESET_COUNTERS_CC: - if (SAMPLE_APP_VerifyCmdLength(Msg, sizeof(SAMPLE_APP_ResetCounters_t))) + if (SAMPLE_APP_VerifyCmdLength(MsgPtr, sizeof(SAMPLE_APP_ResetCounters_t))) { - SAMPLE_APP_ResetCounters((SAMPLE_APP_ResetCounters_t *)Msg); + SAMPLE_APP_ResetCounters((SAMPLE_APP_ResetCounters_t *)MsgPtr); } break; case SAMPLE_APP_PROCESS_CC: - if (SAMPLE_APP_VerifyCmdLength(Msg, sizeof(SAMPLE_APP_Process_t))) + if (SAMPLE_APP_VerifyCmdLength(MsgPtr, sizeof(SAMPLE_APP_Process_t))) { - SAMPLE_APP_Process((SAMPLE_APP_Process_t *)Msg); + SAMPLE_APP_Process((SAMPLE_APP_Process_t *)MsgPtr); } break; @@ -325,14 +325,14 @@ int32 SAMPLE_APP_ReportHousekeeping(const CFE_SB_CmdHdr_t *Msg) /* ** Get command execution counters... */ - SAMPLE_APP_Data.HkBuf.HkTlm.Payload.CommandErrorCounter = SAMPLE_APP_Data.ErrCounter; - SAMPLE_APP_Data.HkBuf.HkTlm.Payload.CommandCounter = SAMPLE_APP_Data.CmdCounter; + SAMPLE_APP_Data.HkTlm.Payload.CommandErrorCounter = SAMPLE_APP_Data.ErrCounter; + SAMPLE_APP_Data.HkTlm.Payload.CommandCounter = SAMPLE_APP_Data.CmdCounter; /* ** Send housekeeping telemetry packet... */ - CFE_SB_TimeStampMsg(&SAMPLE_APP_Data.HkBuf.MsgHdr); - CFE_SB_SendMsg(&SAMPLE_APP_Data.HkBuf.MsgHdr); + CFE_SB_TimeStampMsg(&SAMPLE_APP_Data.HkTlm.TlmHeader.BaseMsg); + CFE_SB_SendMsg(&SAMPLE_APP_Data.HkTlm.TlmHeader.BaseMsg); /* ** Manage any pending table loads, validations, etc. @@ -429,23 +429,27 @@ int32 SAMPLE_APP_Process(const SAMPLE_APP_Process_t *Msg) /* SAMPLE_APP_VerifyCmdLength() -- Verify command packet length */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -bool SAMPLE_APP_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength) +bool SAMPLE_APP_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Size_t ExpectedLength) { - bool result = true; + bool result = true; + CFE_MSG_Size_t ActualLength = 0; + CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; + CFE_MSG_FcnCode_t FcnCode = 0; - uint16 ActualLength = CFE_SB_GetTotalMsgLength(Msg); + CFE_MSG_GetSize(MsgPtr, &ActualLength); /* ** Verify the command packet length. */ if (ExpectedLength != ActualLength) { - CFE_SB_MsgId_t MessageID = CFE_SB_GetMsgId(Msg); - uint16 CommandCode = CFE_SB_GetCmdCode(Msg); + CFE_MSG_GetMsgId(MsgPtr, &MsgId); + CFE_MSG_GetFcnCode(MsgPtr, &FcnCode); CFE_EVS_SendEvent(SAMPLE_APP_LEN_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid Msg length: ID = 0x%X, CC = %d, Len = %d, Expected = %d", - (unsigned int)CFE_SB_MsgIdToValue(MessageID), CommandCode, ActualLength, ExpectedLength); + "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u", + (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, + (unsigned int)ActualLength, (unsigned int)ExpectedLength); result = false; diff --git a/fsw/src/sample_app.h b/fsw/src/sample_app.h index fe7344f..354a716 100644 --- a/fsw/src/sample_app.h +++ b/fsw/src/sample_app.h @@ -57,16 +57,6 @@ ** Type Definitions *************************************************************************/ -/* - * Buffer to hold telemetry data prior to sending - * Defined as a union to ensure proper alignment for a CFE_SB_Msg_t type - */ -typedef union -{ - CFE_SB_Msg_t MsgHdr; - SAMPLE_APP_HkTlm_t HkTlm; -} SAMPLE_APP_HkBuffer_t; - /* ** Global Data */ @@ -81,7 +71,7 @@ typedef struct /* ** Housekeeping telemetry packet... */ - SAMPLE_APP_HkBuffer_t HkBuf; + SAMPLE_APP_HkTlm_t HkTlm; /* ** Run Status variable used in the main processing loop @@ -91,8 +81,8 @@ typedef struct /* ** Operational data (not reported in housekeeping)... */ - CFE_SB_PipeId_t CommandPipe; - CFE_SB_MsgPtr_t MsgPtr; + CFE_SB_PipeId_t CommandPipe; + CFE_MSG_Message_t *MsgPtr; /* ** Initialization data (not reported in housekeeping)... @@ -114,8 +104,8 @@ typedef struct */ void SAMPLE_APP_Main(void); int32 SAMPLE_APP_Init(void); -void SAMPLE_APP_ProcessCommandPacket(CFE_SB_MsgPtr_t Msg); -void SAMPLE_APP_ProcessGroundCommand(CFE_SB_MsgPtr_t Msg); +void SAMPLE_APP_ProcessCommandPacket(CFE_MSG_Message_t *MsgPtr); +void SAMPLE_APP_ProcessGroundCommand(CFE_MSG_Message_t *MsgPtr); int32 SAMPLE_APP_ReportHousekeeping(const CFE_SB_CmdHdr_t *Msg); int32 SAMPLE_APP_ResetCounters(const SAMPLE_APP_ResetCounters_t *Msg); int32 SAMPLE_APP_Process(const SAMPLE_APP_Process_t *Msg); @@ -124,6 +114,6 @@ void SAMPLE_APP_GetCrc(const char *TableName); int32 SAMPLE_APP_TblValidationFunc(void *TblData); -bool SAMPLE_APP_VerifyCmdLength(CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength); +bool SAMPLE_APP_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Size_t ExpectedLength); #endif /* _sample_app_h_ */ diff --git a/fsw/src/sample_app_msg.h b/fsw/src/sample_app_msg.h index 742bfac..92431d0 100644 --- a/fsw/src/sample_app_msg.h +++ b/fsw/src/sample_app_msg.h @@ -73,9 +73,8 @@ typedef struct typedef struct { - uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE]; + CFE_SB_TlmHdr_t TlmHeader; SAMPLE_APP_HkTlm_Payload_t Payload; - } OS_PACK SAMPLE_APP_HkTlm_t; #endif /* _sample_app_msg_h_ */ diff --git a/unit-test/coveragetest/coveragetest_sample_app.c b/unit-test/coveragetest/coveragetest_sample_app.c index 3a90b83..01f499d 100644 --- a/unit-test/coveragetest/coveragetest_sample_app.c +++ b/unit-test/coveragetest/coveragetest_sample_app.c @@ -133,6 +133,8 @@ static void UT_CheckEvent_Setup(UT_CheckEvent_t *Evt, uint16 ExpectedEvent, cons void Test_SAMPLE_APP_Main(void) { + CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; + /* * Test Case For: * void SAMPLE_APP_Main( void ) @@ -197,6 +199,9 @@ void Test_SAMPLE_APP_Main(void) */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_RunLoop), 1, true); + /* Set up buffer for command processing */ + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); + /* * Invoke again */ @@ -267,38 +272,44 @@ void Test_SAMPLE_APP_ProcessCommandPacket(void) { /* * Test Case For: - * void SAMPLE_APP_ProcessCommandPacket( CFE_SB_MsgPtr_t Msg ) + * void SAMPLE_APP_ProcessCommandPacket */ /* a buffer large enough for any command message */ union { - CFE_SB_Msg_t Base; + CFE_MSG_Message_t Base; CFE_SB_CmdHdr_t Cmd; SAMPLE_APP_Noop_t Noop; SAMPLE_APP_ResetCounters_t Reset; SAMPLE_APP_Process_t Process; } TestMsg; - CFE_SB_MsgId_t TestMsgId; - UT_CheckEvent_t EventTest; + CFE_SB_MsgId_t TestMsgId; + CFE_MSG_FcnCode_t FcnCode; + CFE_MSG_Size_t MsgSize; + UT_CheckEvent_t EventTest; memset(&TestMsg, 0, sizeof(TestMsg)); UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_INVALID_MSGID_ERR_EID, "SAMPLE: invalid command packet,MID = 0x%x"); /* - * The CFE_SB_GetMsgId() stub uses a data buffer to hold the + * The CFE_MSG_GetMsgId() stub uses a data buffer to hold the * message ID values to return. */ TestMsgId = SAMPLE_APP_CMD_MID; - UT_SetDataBuffer(UT_KEY(CFE_SB_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); + FcnCode = SAMPLE_APP_NOOP_CC; + MsgSize = sizeof(SAMPLE_APP_Noop_t); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); SAMPLE_APP_ProcessCommandPacket(&TestMsg.Base); TestMsgId = SAMPLE_APP_SEND_HK_MID; - UT_SetDataBuffer(UT_KEY(CFE_SB_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); SAMPLE_APP_ProcessCommandPacket(&TestMsg.Base); /* invalid message id */ TestMsgId = CFE_SB_INVALID_MSG_ID; - UT_SetDataBuffer(UT_KEY(CFE_SB_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); SAMPLE_APP_ProcessCommandPacket(&TestMsg.Base); /* @@ -312,13 +323,15 @@ void Test_SAMPLE_APP_ProcessGroundCommand(void) { /* * Test Case For: - * void SAMPLE_APP_ProcessGroundCommand( CFE_SB_MsgPtr_t Msg ) + * void SAMPLE_APP_ProcessGroundCommand */ + CFE_MSG_FcnCode_t FcnCode; + CFE_MSG_Size_t Size; /* a buffer large enough for any command message */ union { - CFE_SB_Msg_t Base; + CFE_MSG_Message_t Base; CFE_SB_CmdHdr_t Cmd; SAMPLE_APP_Noop_t Noop; SAMPLE_APP_ResetCounters_t Reset; @@ -330,7 +343,7 @@ void Test_SAMPLE_APP_ProcessGroundCommand(void) /* * call with each of the supported command codes - * The CFE_SB_GetCmdCode stub allows the code to be + * The CFE_MSG_GetFcnCode stub allows the code to be * set to whatever is needed. There is no return * value here and the actual implementation of these * commands have separate test cases, so this just @@ -338,31 +351,44 @@ void Test_SAMPLE_APP_ProcessGroundCommand(void) */ /* test dispatch of NOOP */ - UT_SetDeferredRetcode(UT_KEY(CFE_SB_GetCmdCode), 1, SAMPLE_APP_NOOP_CC); - UT_SetDeferredRetcode(UT_KEY(CFE_SB_GetTotalMsgLength), 1, sizeof(TestMsg.Noop)); + FcnCode = SAMPLE_APP_NOOP_CC; + Size = sizeof(TestMsg.Noop); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_COMMANDNOP_INF_EID, NULL); SAMPLE_APP_ProcessGroundCommand(&TestMsg.Base); + UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_COMMANDNOP_INF_EID generated (%u)", + (unsigned int)EventTest.MatchCount); + /* test dispatch of RESET */ - UT_SetDeferredRetcode(UT_KEY(CFE_SB_GetCmdCode), 1, SAMPLE_APP_RESET_COUNTERS_CC); - UT_SetDeferredRetcode(UT_KEY(CFE_SB_GetTotalMsgLength), 1, sizeof(TestMsg.Reset)); + FcnCode = SAMPLE_APP_RESET_COUNTERS_CC; + Size = sizeof(TestMsg.Reset); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_COMMANDRST_INF_EID, NULL); SAMPLE_APP_ProcessGroundCommand(&TestMsg.Base); + UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_COMMANDRST_INF_EID generated (%u)", + (unsigned int)EventTest.MatchCount); + /* test dispatch of PROCESS */ /* note this will end up calling SAMPLE_APP_Process(), and as such it needs to * avoid dereferencing a table which does not exist. */ + FcnCode = SAMPLE_APP_PROCESS_CC; + Size = sizeof(TestMsg.Process); UT_SetForceFail(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_UNREGISTERED); - UT_SetDeferredRetcode(UT_KEY(CFE_SB_GetCmdCode), 1, SAMPLE_APP_PROCESS_CC); - UT_SetDeferredRetcode(UT_KEY(CFE_SB_GetTotalMsgLength), 1, sizeof(TestMsg.Process)); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); SAMPLE_APP_ProcessGroundCommand(&TestMsg.Base); /* test an invalid CC */ + FcnCode = 1000; + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_COMMAND_ERR_EID, "Invalid ground command code: CC = %d"); - UT_SetDeferredRetcode(UT_KEY(CFE_SB_GetCmdCode), 1, 1000); SAMPLE_APP_ProcessGroundCommand(&TestMsg.Base); /* @@ -378,12 +404,12 @@ void Test_SAMPLE_APP_ReportHousekeeping(void) * Test Case For: * void SAMPLE_APP_ReportHousekeeping( const CFE_SB_CmdHdr_t *Msg ) */ - CFE_SB_Msg_t * MsgSend; - CFE_SB_Msg_t * MsgTimestamp; - CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(SAMPLE_APP_SEND_HK_MID); + CFE_MSG_Message_t *MsgSend; + CFE_MSG_Message_t *MsgTimestamp; + CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(SAMPLE_APP_SEND_HK_MID); /* Set message id to return so SAMPLE_APP_Housekeeping will be called */ - UT_SetDataBuffer(UT_KEY(CFE_SB_GetMsgId), &MsgId, sizeof(MsgId), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); /* Set up to capture send message address */ UT_SetDataBuffer(UT_KEY(CFE_SB_SendMsg), &MsgSend, sizeof(MsgSend), false); @@ -392,15 +418,15 @@ void Test_SAMPLE_APP_ReportHousekeeping(void) UT_SetDataBuffer(UT_KEY(CFE_SB_TimeStampMsg), &MsgTimestamp, sizeof(MsgTimestamp), false); /* Call unit under test, NULL pointer confirms command access is through APIs */ - SAMPLE_APP_ProcessCommandPacket((CFE_SB_Msg_t *)NULL); + SAMPLE_APP_ProcessCommandPacket((CFE_MSG_Message_t *)NULL); /* Confirm message sent*/ UtAssert_True(UT_GetStubCount(UT_KEY(CFE_SB_SendMsg)) == 1, "CFE_SB_SendMsg() called once"); - UtAssert_True(MsgSend == &SAMPLE_APP_Data.HkBuf.MsgHdr, "CFE_SB_SendMsg() address matches expected"); + UtAssert_True(MsgSend == &SAMPLE_APP_Data.HkTlm.TlmHeader.BaseMsg, "CFE_SB_SendMsg() address matches expected"); /* Confirm timestamp msg address */ UtAssert_True(UT_GetStubCount(UT_KEY(CFE_SB_TimeStampMsg)) == 1, "CFE_SB_TimeStampMsg() called once"); - UtAssert_True(MsgTimestamp == &SAMPLE_APP_Data.HkBuf.MsgHdr, "CFE_SB_TimeStampMsg() adress matches expected"); + UtAssert_True(MsgTimestamp == &SAMPLE_APP_Data.HkTlm.TlmHeader.BaseMsg, "CFE_SB_TimeStampMsg() adress matches expected"); /* * Confirm that the CFE_TBL_Manage() call was done @@ -495,21 +521,21 @@ void Test_SAMPLE_APP_VerifyCmdLength(void) { /* * Test Case For: - * bool SAMPLE_APP_VerifyCmdLength( CFE_SB_MsgPtr_t Msg, uint16 ExpectedLength ) + * bool SAMPLE_APP_VerifyCmdLength */ - CFE_SB_Msg_t TestMsg; - UT_CheckEvent_t EventTest; - - memset(&TestMsg, 0, sizeof(TestMsg)); + UT_CheckEvent_t EventTest; + CFE_MSG_Size_t size = 1; + CFE_MSG_FcnCode_t fcncode = 2; + CFE_SB_MsgId_t msgid = CFE_SB_ValueToMsgId(3); /* * test a match case */ - UT_SetDeferredRetcode(UT_KEY(CFE_SB_GetTotalMsgLength), 1, sizeof(TestMsg)); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &size, sizeof(size), false); UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_LEN_ERR_EID, - "Invalid Msg length: ID = 0x%X, CC = %d, Len = %d, Expected = %d"); + "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u"); - SAMPLE_APP_VerifyCmdLength(&TestMsg, sizeof(TestMsg)); + SAMPLE_APP_VerifyCmdLength(NULL, size); /* * Confirm that the event was NOT generated @@ -520,8 +546,10 @@ void Test_SAMPLE_APP_VerifyCmdLength(void) /* * test a mismatch case */ - UT_SetDeferredRetcode(UT_KEY(CFE_SB_GetTotalMsgLength), 1, 10 + sizeof(TestMsg)); - SAMPLE_APP_VerifyCmdLength(&TestMsg, sizeof(TestMsg)); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &size, sizeof(size), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &msgid, sizeof(msgid), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &fcncode, sizeof(fcncode), false); + SAMPLE_APP_VerifyCmdLength(NULL, size+1); /* * Confirm that the event WAS generated From 874bedae1a77c2acd063084fe932aaf109677464 Mon Sep 17 00:00:00 2001 From: skliper <47541139+skliper@users.noreply.github.com> Date: Fri, 13 Nov 2020 15:27:45 -0500 Subject: [PATCH 2/3] Fix #105, Remove non-portable OS_PACK (#109) Co-authored-by: Gerardo E. Cruz-Ortiz <59618057+astrogeco@users.noreply.github.com> --- fsw/src/sample_app_msg.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fsw/src/sample_app_msg.h b/fsw/src/sample_app_msg.h index 92431d0..6ae76db 100644 --- a/fsw/src/sample_app_msg.h +++ b/fsw/src/sample_app_msg.h @@ -75,7 +75,8 @@ typedef struct { CFE_SB_TlmHdr_t TlmHeader; SAMPLE_APP_HkTlm_Payload_t Payload; -} OS_PACK SAMPLE_APP_HkTlm_t; +} SAMPLE_APP_HkTlm_t; + #endif /* _sample_app_msg_h_ */ From f7f2d19e277a2cf2f4fa3a7bfe32dedae2e1c516 Mon Sep 17 00:00:00 2001 From: astrogeco <59618057+astrogeco@users.noreply.github.com> Date: Fri, 13 Nov 2020 16:09:04 -0500 Subject: [PATCH 3/3] Bump to v1.2.0-rc1+dev22 and update ReadMe --- README.md | 6 ++++++ fsw/src/sample_app_version.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9842e8f..8f80346 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,12 @@ sample_app is an example for how to build and link an application in cFS. See al ## Version History +### Development Build: 1.2.0-rc1+dev22 + +- Replaces deprecated SB API's with MSG +- No impact, removes undesirable pattern use of `OS_PACK` +- See + ### Development Build: 1.2.0-rc1+dev18 - No behavior changes. All identifiers now use the prefix `SAMPLE_APP_`. Changes the name of the main function from SAMPLE_AppMain to SAMPLE_APP_Main which affects the CFE startup script. diff --git a/fsw/src/sample_app_version.h b/fsw/src/sample_app_version.h index 2c797bd..bddd550 100644 --- a/fsw/src/sample_app_version.h +++ b/fsw/src/sample_app_version.h @@ -32,7 +32,7 @@ /* Development Build Macro Definitions */ -#define SAMPLE_APP_BUILD_NUMBER 18 /*!< Development Build: Number of commits since baseline */ +#define SAMPLE_APP_BUILD_NUMBER 22 /*!< Development Build: Number of commits since baseline */ #define SAMPLE_APP_BUILD_BASELINE \ "v1.2.0-rc1" /*!< Development Build: git tag that is the base for the current development */