From bd37cabf5e7605627b3cda9c47bca206e10e7a83 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 24 Oct 2023 12:30:57 -0400 Subject: [PATCH] Fix #123, use CFE_MSG_PTR conversion macro Rather than taking the address of a sub-member, use the macro provided from the CFE_MSG module to convert from a local container to a CFE_MSG_Messge_t pointer. --- fsw/src/sc_app.c | 3 ++- fsw/src/sc_cmds.c | 16 ++++++++-------- fsw/src/sc_loads.c | 12 ++++++------ fsw/src/sc_rtsrq.c | 6 +++--- fsw/src/sc_state.c | 4 ++-- unit-test/sc_dispatch_tests.c | 6 +++--- 6 files changed, 24 insertions(+), 23 deletions(-) diff --git a/fsw/src/sc_app.c b/fsw/src/sc_app.c index 4df0c4e..badb829 100644 --- a/fsw/src/sc_app.c +++ b/fsw/src/sc_app.c @@ -157,7 +157,8 @@ CFE_Status_t SC_AppInit(void) SC_AppData.NextCmdTime[SC_Process_RTP] = SC_MAX_TIME; /* Initialize the SC housekeeping packet */ - CFE_MSG_Init(&SC_OperData.HkPacket.TelemetryHeader.Msg, CFE_SB_ValueToMsgId(SC_HK_TLM_MID), sizeof(SC_HkTlm_t)); + CFE_MSG_Init(CFE_MSG_PTR(SC_OperData.HkPacket.TelemetryHeader), CFE_SB_ValueToMsgId(SC_HK_TLM_MID), + sizeof(SC_HkTlm_t)); /* Select auto-exec RTS to start during first HK request */ if (CFE_ES_GetResetType(NULL) == CFE_PSP_RST_TYPE_POWERON) diff --git a/fsw/src/sc_cmds.c b/fsw/src/sc_cmds.c index 12c2c1d..023217e 100644 --- a/fsw/src/sc_cmds.c +++ b/fsw/src/sc_cmds.c @@ -106,7 +106,7 @@ void SC_ProcessAtpCmd(void) if (!SC_AppData.EnableHeaderUpdate) { /* If header update is NOT enabled, confirm this table entry has a valid checksum already */ - CFE_MSG_ValidateChecksum(&EntryPtr->Msg, &ChecksumValid); + CFE_MSG_ValidateChecksum(CFE_MSG_PTR(EntryPtr->Msg), &ChecksumValid); } if (ChecksumValid) { @@ -128,8 +128,8 @@ void SC_ProcessAtpCmd(void) ** SC immediately executes the switch command. */ - CFE_MSG_GetMsgId(&EntryPtr->Msg, &MessageID); - CFE_MSG_GetFcnCode(&EntryPtr->Msg, &CommandCode); + CFE_MSG_GetMsgId(CFE_MSG_PTR(EntryPtr->Msg), &MessageID); + CFE_MSG_GetFcnCode(CFE_MSG_PTR(EntryPtr->Msg), &CommandCode); if (CommandCode == SC_SWITCH_ATS_CC && CFE_SB_MsgIdToValue(MessageID) == SC_CMD_MID) { @@ -157,7 +157,7 @@ void SC_ProcessAtpCmd(void) } else { - Result = CFE_SB_TransmitMsg(&EntryPtr->Msg, SC_AppData.EnableHeaderUpdate); + Result = CFE_SB_TransmitMsg(CFE_MSG_PTR(EntryPtr->Msg), SC_AppData.EnableHeaderUpdate); if (Result == CFE_SUCCESS) { @@ -339,7 +339,7 @@ void SC_ProcessRtpCommand(void) if (!SC_AppData.EnableHeaderUpdate) { /* If header update is NOT enabled, confirm this table entry has a valid checksum already */ - CFE_MSG_ValidateChecksum(&EntryPtr->Msg, &ChecksumValid); + CFE_MSG_ValidateChecksum(CFE_MSG_PTR(EntryPtr->Msg), &ChecksumValid); } if (ChecksumValid) { @@ -347,7 +347,7 @@ void SC_ProcessRtpCommand(void) ** Try Sending the command on the Software Bus */ - Result = CFE_SB_TransmitMsg(&EntryPtr->Msg, SC_AppData.EnableHeaderUpdate); + Result = CFE_SB_TransmitMsg(CFE_MSG_PTR(EntryPtr->Msg), SC_AppData.EnableHeaderUpdate); if (Result == CFE_SUCCESS) { @@ -474,8 +474,8 @@ void SC_SendHkPacket(void) } /* end for */ /* send the status packet */ - CFE_SB_TimeStampMsg(&SC_OperData.HkPacket.TelemetryHeader.Msg); - CFE_SB_TransmitMsg(&SC_OperData.HkPacket.TelemetryHeader.Msg, true); + CFE_SB_TimeStampMsg(CFE_MSG_PTR(SC_OperData.HkPacket.TelemetryHeader)); + CFE_SB_TransmitMsg(CFE_MSG_PTR(SC_OperData.HkPacket.TelemetryHeader), true); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/fsw/src/sc_loads.c b/fsw/src/sc_loads.c index a725ea8..6ca6711 100644 --- a/fsw/src/sc_loads.c +++ b/fsw/src/sc_loads.c @@ -110,7 +110,7 @@ void SC_LoadAts(uint16 AtsIndex) SC_OperData.AtsCmdStatusTblAddr[AtsIndex][SC_ATS_CMD_NUM_TO_INDEX(AtsCmdNum)] == SC_Status_EMPTY) { /* get message size */ - CFE_MSG_GetSize(&EntryPtr->Msg, &MessageSize); + CFE_MSG_GetSize(CFE_MSG_PTR(EntryPtr->Msg), &MessageSize); /* if the length of the command is valid */ if (MessageSize >= SC_PACKET_MIN_SIZE && MessageSize <= SC_PACKET_MAX_SIZE) @@ -404,12 +404,12 @@ bool SC_ParseRts(uint32 Buffer32[]) */ EntryPtr = (SC_RtsEntry_t *)&Buffer32[i]; - CFE_MSG_GetSize(&EntryPtr->Msg, &CmdSize); + CFE_MSG_GetSize(CFE_MSG_PTR(EntryPtr->Msg), &CmdSize); /* Add header size, round up to boundary, convert to index delta */ IndexDelta = (CmdSize + SC_RTS_HEADER_SIZE + SC_ROUND_UP_BYTES) / sizeof(Buffer32[0]); - CFE_MSG_GetMsgId(&EntryPtr->Msg, &MessageID); + CFE_MSG_GetMsgId(CFE_MSG_PTR(EntryPtr->Msg), &MessageID); if (!CFE_SB_IsValidMsgId(MessageID)) { @@ -557,7 +557,7 @@ void SC_UpdateAppend(void) } else { - CFE_MSG_GetSize(&EntryPtr->Msg, &CommandBytes); + CFE_MSG_GetSize(CFE_MSG_PTR(EntryPtr->Msg), &CommandBytes); CommandWords = (CommandBytes + SC_ROUND_UP_BYTES) / SC_BYTES_IN_WORD; if ((CommandBytes < SC_PACKET_MIN_SIZE) || (CommandBytes > SC_PACKET_MAX_SIZE)) @@ -644,7 +644,7 @@ void SC_ProcessAppend(uint16 AtsIndex) SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] = SC_Status_LOADED; /* update entry index to point to the next entry */ - CFE_MSG_GetSize(&EntryPtr->Msg, &CommandBytes); + CFE_MSG_GetSize(CFE_MSG_PTR(EntryPtr->Msg), &CommandBytes); CommandWords = (CommandBytes + SC_ROUND_UP_BYTES) / SC_BYTES_IN_WORD; EntryIndex += (SC_ATS_HDR_NOPKT_WORDS + CommandWords); } @@ -797,7 +797,7 @@ int32 SC_VerifyAtsEntry(uint32 *Buffer32, int32 EntryIndex, int32 BufferWords) else { /* Start with the byte length of the command packet */ - CFE_MSG_GetSize(&EntryPtr->Msg, &CommandBytes); + CFE_MSG_GetSize(CFE_MSG_PTR(EntryPtr->Msg), &CommandBytes); /* Convert packet byte length to word length (round up odd bytes) */ CommandWords = (CommandBytes + SC_ROUND_UP_BYTES) / SC_BYTES_IN_WORD; diff --git a/fsw/src/sc_rtsrq.c b/fsw/src/sc_rtsrq.c index 0d92572..f9a3106 100644 --- a/fsw/src/sc_rtsrq.c +++ b/fsw/src/sc_rtsrq.c @@ -551,9 +551,9 @@ void SC_AutoStartRts(uint16 RtsNumber) /* ** Format the command packet to start the first RTS */ - CFE_MSG_Init(&CmdPkt.CommandHeader.Msg, CFE_SB_ValueToMsgId(SC_CMD_MID), sizeof(CmdPkt)); + CFE_MSG_Init(CFE_MSG_PTR(CmdPkt.CommandHeader), CFE_SB_ValueToMsgId(SC_CMD_MID), sizeof(CmdPkt)); - CFE_MSG_SetFcnCode(&CmdPkt.CommandHeader.Msg, SC_START_RTS_CC); + CFE_MSG_SetFcnCode(CFE_MSG_PTR(CmdPkt.CommandHeader), SC_START_RTS_CC); /* ** Get the RTS ID to start. @@ -563,7 +563,7 @@ void SC_AutoStartRts(uint16 RtsNumber) /* ** Now send the command back to SC */ - CFE_SB_TransmitMsg(&CmdPkt.CommandHeader.Msg, true); + CFE_SB_TransmitMsg(CFE_MSG_PTR(CmdPkt.CommandHeader), true); } else { diff --git a/fsw/src/sc_state.c b/fsw/src/sc_state.c index 3ca2d94..50b1576 100644 --- a/fsw/src/sc_state.c +++ b/fsw/src/sc_state.c @@ -168,7 +168,7 @@ void SC_GetNextRtsCommand(void) CmdOffset = SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr; EntryPtr = (SC_RtsEntry_t *)&SC_OperData.RtsTblAddr[RtsIndex][CmdOffset]; - CFE_MSG_GetSize(&EntryPtr->Msg, &CmdLength); + CFE_MSG_GetSize(CFE_MSG_PTR(EntryPtr->Msg), &CmdLength); CmdLength += SC_RTS_HEADER_SIZE; /* @@ -196,7 +196,7 @@ void SC_GetNextRtsCommand(void) /* ** get the length of the new command */ - CFE_MSG_GetSize(&EntryPtr->Msg, &CmdLength); + CFE_MSG_GetSize(CFE_MSG_PTR(EntryPtr->Msg), &CmdLength); CmdLength += SC_RTS_HEADER_SIZE; /* diff --git a/unit-test/sc_dispatch_tests.c b/unit-test/sc_dispatch_tests.c index 5781112..62f8715 100644 --- a/unit-test/sc_dispatch_tests.c +++ b/unit-test/sc_dispatch_tests.c @@ -102,7 +102,7 @@ void SC_VerifyCmdLength_Test_Nominal(void) UT_SC_Dispatch_SetMsgSize(MsgSize); /* Execute the function being tested */ - UtAssert_BOOL_TRUE(SC_VerifyCmdLength(&CmdPacket.CommandHeader.Msg, sizeof(CmdPacket))); + UtAssert_BOOL_TRUE(SC_VerifyCmdLength(CFE_MSG_PTR(CmdPacket.CommandHeader), sizeof(CmdPacket))); /* Verify results */ UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdErrCtr, 0); @@ -122,7 +122,7 @@ void SC_VerifyCmdLength_Test_LenError(void) UT_SC_Dispatch_SetMsgSize(MsgSize); /* Execute the function being tested */ - UtAssert_BOOL_FALSE(SC_VerifyCmdLength(&CmdPacket.CommandHeader.Msg, 999)); + UtAssert_BOOL_FALSE(SC_VerifyCmdLength(CFE_MSG_PTR(CmdPacket.CommandHeader), 999)); /* Verify results */ UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0); @@ -144,7 +144,7 @@ void SC_VerifyCmdLength_Test_LenErrorNotMID(void) UT_SC_Dispatch_SetMsgSize(MsgSize); /* Execute the function being tested */ - UtAssert_BOOL_FALSE(SC_VerifyCmdLength(&CmdPacket.CommandHeader.Msg, 999)); + UtAssert_BOOL_FALSE(SC_VerifyCmdLength(CFE_MSG_PTR(CmdPacket.CommandHeader), 999)); /* Verify results */ UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.CmdCtr, 0);