diff --git a/fsw/inc/lc_msg.h b/fsw/inc/lc_msg.h index 1359e16..9a84e57 100644 --- a/fsw/inc/lc_msg.h +++ b/fsw/inc/lc_msg.h @@ -48,15 +48,34 @@ */ /** - * \brief No Arguments Command + * \brief Send HK Command * - * For command details see #LC_NOOP_CC, #LC_RESET_CC - * Also see #LC_SEND_HK_MID + * For command details see #LC_SEND_HK_MID */ typedef struct { - CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */ -} LC_NoArgsCmd_t; + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ +} LC_SendHkCmd_t; + +/** + * \brief No-op Command + * + * For command details see #LC_NOOP_CC + */ +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ +} LC_NoopCmd_t; + +/** + * \brief Reset Counters Command + * + * For command details see #LC_RESET_CC + */ +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ +} LC_ResetCountersCmd_t; /** * \brief Set LC Application State Command @@ -65,11 +84,11 @@ typedef struct */ typedef struct { - CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ uint16 NewLCState; /**< \brief New LC application state */ uint16 Padding; /**< \brief Structure padding */ -} LC_SetLCState_t; +} LC_SetLCStateCmd_t; /** * \brief Set AP (Actionpoint) State Command @@ -78,11 +97,11 @@ typedef struct */ typedef struct { - CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ uint16 APNumber; /**< \brief Which actionpoint(s) to change */ uint16 NewAPState; /**< \brief New actionpoint state */ -} LC_SetAPState_t; +} LC_SetAPStateCmd_t; /** * \brief Set AP (Actionpoint) Permanently Off @@ -91,11 +110,11 @@ typedef struct */ typedef struct { - CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ uint16 APNumber; /**< \brief Which actionpoint to change */ uint16 Padding; /**< \brief Structure padding */ -} LC_SetAPPermOff_t; +} LC_SetAPPermOffCmd_t; /** * \brief Reset AP (Actionpoint) Statistics @@ -104,11 +123,11 @@ typedef struct */ typedef struct { - CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ uint16 APNumber; /**< \brief Which actionpoint(s) to change */ uint16 Padding; /**< \brief Structure padding */ -} LC_ResetAPStats_t; +} LC_ResetAPStatsCmd_t; /** * \brief Reset WP (Watchpoint) Statistics @@ -117,11 +136,11 @@ typedef struct */ typedef struct { - CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ uint16 WPNumber; /**< \brief Which watchpoint(s) to change */ uint16 Padding; /**< \brief Structure padding */ -} LC_ResetWPStats_t; +} LC_ResetWPStatsCmd_t; /** * \brief Sample AP (Actionpoint) Request @@ -130,14 +149,14 @@ typedef struct */ typedef struct { - CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ uint16 StartIndex; /**< \brief Start actionpoint to sample */ uint16 EndIndex; /**< \brief End actionpoint to sample */ uint16 UpdateAge; /**< \brief Update WP results age (T or F) */ uint16 Padding; /**< \brief Structure padding */ -} LC_SampleAP_t; +} LC_SampleAPCmd_t; /** * \brief Send Command to Start a Stored Command RTS @@ -154,10 +173,10 @@ typedef struct */ typedef struct { - CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ uint16 RTSId; /**< \brief RTS Id to start */ -} LC_RTSRequest_t; +} LC_RTSRequestCmd_t; /**\}*/ @@ -171,7 +190,7 @@ typedef struct */ typedef struct { - CFE_MSG_TelemetryHeader_t TlmHeader; /**< \brief Telemetry Header */ + CFE_MSG_TelemetryHeader_t TelemetryHeader; /**< \brief Telemetry Header */ uint8 CmdCount; /**< \brief LC Application Command Counter */ uint8 CmdErrCount; /**< \brief LC Application Command Error Counter */ diff --git a/fsw/inc/lc_msgdefs.h b/fsw/inc/lc_msgdefs.h index e16b37f..db21df1 100644 --- a/fsw/inc/lc_msgdefs.h +++ b/fsw/inc/lc_msgdefs.h @@ -128,7 +128,7 @@ * Implements the Noop command that insures the LC task is alive * * \par Command Structure - * #LC_NoArgsCmd_t + * #LC_NoopCmd_t * * \par Command Verification * Successful execution of this command may be verified with @@ -159,7 +159,7 @@ * Resets the LC housekeeping counters * * \par Command Structure - * #LC_NoArgsCmd_t + * #LC_ResetCountersCmd_t * * \par Command Verification * Successful execution of this command may be verified with @@ -190,7 +190,7 @@ * Sets the operational state of the LC application * * \par Command Structure - * #LC_SetLCState_t + * #LC_SetLCStateCmd_t * * \par Command Verification * Successful execution of this command may be verified with @@ -223,7 +223,7 @@ * Set actionpoint state * * \par Command Structure - * #LC_SetAPState_t + * #LC_SetAPStateCmd_t * * \par Command Verification * Successful execution of this command may be verified with @@ -261,7 +261,7 @@ * Set the specified actionpoint's state to #LC_APSTATE_PERMOFF * * \par Command Structure - * #LC_SetAPPermOff_t + * #LC_SetAPPermOffCmd_t * * \par Command Verification * Successful execution of this command may be verified with @@ -296,7 +296,7 @@ * Resets actionpoint statistics * * \par Command Structure - * #LC_ResetAPStats_t + * #LC_ResetAPStatsCmd_t * * \par Command Verification * Successful execution of this command may be verified with @@ -330,7 +330,7 @@ * Resets watchpoint statistics * * \par Command Structure - * #LC_ResetWPStats_t + * #LC_ResetWPStatsCmd_t * * \par Command Verification * Successful execution of this command may be verified with diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index a8b9307..b6a8df9 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -263,7 +263,8 @@ int32 LC_SbInit(void) /* ** Initialize housekeeping packet... */ - CFE_MSG_Init(&LC_OperData.HkPacket.TlmHeader.Msg, CFE_SB_ValueToMsgId(LC_HK_TLM_MID), sizeof(LC_HkPacket_t)); + CFE_MSG_Init(CFE_MSG_PTR(LC_OperData.HkPacket.TelemetryHeader), CFE_SB_ValueToMsgId(LC_HK_TLM_MID), + sizeof(LC_HkPacket_t)); /* ** Create Software Bus message pipe... diff --git a/fsw/src/lc_cmds.c b/fsw/src/lc_cmds.c index 0acd6a0..a3c81c3 100644 --- a/fsw/src/lc_cmds.c +++ b/fsw/src/lc_cmds.c @@ -35,6 +35,8 @@ #include "lc_platform_cfg.h" #include "lc_utils.h" +#define LC_GET_CMD_PAYLOAD(ptr, type) ((const type *)(ptr)) + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* Process a command pipe message */ @@ -132,16 +134,18 @@ int32 LC_AppPipe(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr) { - LC_SampleAP_t *LC_SampleAP = (LC_SampleAP_t *)BufPtr; - size_t ExpectedLength = sizeof(LC_SampleAP_t); - uint16 WatchIndex; - bool ValidSampleCmd = false; + const LC_SampleAPCmd_t *LC_SampleAP; + size_t ExpectedLength = sizeof(LC_SampleAPCmd_t); + uint16 WatchIndex; + bool ValidSampleCmd = false; /* ** Verify message packet length */ if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) { + LC_SampleAP = LC_GET_CMD_PAYLOAD(BufPtr, LC_SampleAPCmd_t); + /* ** Ignore AP sample requests if disabled at the application level */ @@ -209,7 +213,7 @@ void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr) int32 LC_HousekeepingReq(const CFE_MSG_CommandHeader_t *MsgPtr) { int32 Result; - size_t ExpectedLength = sizeof(LC_NoArgsCmd_t); + size_t ExpectedLength = sizeof(LC_SendHkCmd_t); uint16 TableIndex; uint16 HKIndex; uint8 ByteData; @@ -477,8 +481,8 @@ int32 LC_HousekeepingReq(const CFE_MSG_CommandHeader_t *MsgPtr) /* ** Timestamp and send housekeeping packet */ - CFE_SB_TimeStampMsg(&LC_OperData.HkPacket.TlmHeader.Msg); - CFE_SB_TransmitMsg(&LC_OperData.HkPacket.TlmHeader.Msg, true); + CFE_SB_TimeStampMsg(CFE_MSG_PTR(LC_OperData.HkPacket.TelemetryHeader)); + CFE_SB_TransmitMsg(CFE_MSG_PTR(LC_OperData.HkPacket.TelemetryHeader), true); } /* end LC_VerifyMsgLength if */ @@ -494,7 +498,7 @@ int32 LC_HousekeepingReq(const CFE_MSG_CommandHeader_t *MsgPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_NoopCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_NoArgsCmd_t); + size_t ExpectedLength = sizeof(LC_NoopCmd_t); /* ** Verify message packet length @@ -517,7 +521,7 @@ void LC_NoopCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_ResetCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_NoArgsCmd_t); + size_t ExpectedLength = sizeof(LC_ResetCountersCmd_t); /* ** Verify message packet length @@ -557,15 +561,15 @@ void LC_ResetCounters(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_SetLCStateCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_SetLCState_t); - LC_SetLCState_t *CmdPtr; + size_t ExpectedLength = sizeof(LC_SetLCStateCmd_t); + const LC_SetLCStateCmd_t *CmdPtr; /* ** Verify message packet length */ if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) { - CmdPtr = ((LC_SetLCState_t *)BufPtr); + CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_SetLCStateCmd_t); switch (CmdPtr->NewLCState) { @@ -598,19 +602,19 @@ void LC_SetLCStateCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_SetAPStateCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_SetAPState_t); - LC_SetAPState_t *CmdPtr; - uint32 TableIndex; - uint8 CurrentAPState; - bool ValidState = true; - bool CmdSuccess = false; + size_t ExpectedLength = sizeof(LC_SetAPStateCmd_t); + const LC_SetAPStateCmd_t *CmdPtr; + uint32 TableIndex; + uint8 CurrentAPState; + bool ValidState = true; + bool CmdSuccess = false; /* ** Verify message packet length */ if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) { - CmdPtr = ((LC_SetAPState_t *)BufPtr); + CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_SetAPStateCmd_t); /* ** Do a sanity check on the new actionpoint state @@ -728,17 +732,17 @@ void LC_SetAPStateCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_SetAPPermOffCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_SetAPPermOff_t); - LC_SetAPPermOff_t *CmdPtr; - uint32 TableIndex; - uint8 CurrentAPState; + size_t ExpectedLength = sizeof(LC_SetAPPermOffCmd_t); + const LC_SetAPPermOffCmd_t *CmdPtr; + uint32 TableIndex; + uint8 CurrentAPState; /* ** Verify message packet length */ if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) { - CmdPtr = ((LC_SetAPPermOff_t *)BufPtr); + CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_SetAPPermOffCmd_t); if (((CmdPtr->APNumber) == LC_ALL_ACTIONPOINTS) || ((CmdPtr->APNumber) >= LC_MAX_ACTIONPOINTS)) { @@ -795,13 +799,15 @@ void LC_SetAPPermOffCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_ResetAPStatsCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_ResetAPStats_t); - LC_ResetAPStats_t *CmdPtr = (LC_ResetAPStats_t *)BufPtr; - bool CmdSuccess = false; + size_t ExpectedLength = sizeof(LC_ResetAPStatsCmd_t); + const LC_ResetAPStatsCmd_t *CmdPtr; + bool CmdSuccess = false; /* verify message packet length */ if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) { + CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_ResetAPStatsCmd_t); + /* arg may be one or all AP's */ if (CmdPtr->APNumber == LC_ALL_ACTIONPOINTS) { @@ -873,13 +879,15 @@ void LC_ResetResultsAP(uint32 StartIndex, uint32 EndIndex, bool ResetStatsCmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_ResetWPStatsCmd(const CFE_SB_Buffer_t *BufPtr) { - size_t ExpectedLength = sizeof(LC_ResetWPStats_t); - LC_ResetWPStats_t *CmdPtr = (LC_ResetWPStats_t *)BufPtr; - bool CmdSuccess = false; + size_t ExpectedLength = sizeof(LC_ResetWPStatsCmd_t); + const LC_ResetWPStatsCmd_t *CmdPtr; + bool CmdSuccess = false; /* verify message packet length */ if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) { + CmdPtr = LC_GET_CMD_PAYLOAD(BufPtr, LC_ResetWPStatsCmd_t); + /* arg may be one or all WP's */ if (CmdPtr->WPNumber == LC_ALL_WATCHPOINTS) { diff --git a/fsw/src/lc_custom.c b/fsw/src/lc_custom.c index 09b4f5a..34c1034 100644 --- a/fsw/src/lc_custom.c +++ b/fsw/src/lc_custom.c @@ -41,17 +41,16 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_ExecuteRTS(uint16 RTSId) { - LC_RTSRequest_t RTSRequest; + LC_RTSRequestCmd_t RTSRequest; memset(&RTSRequest, 0, sizeof(RTSRequest)); - CFE_MSG_Init(&RTSRequest.CmdHeader.Msg, CFE_SB_ValueToMsgId(LC_RTS_REQ_MID), sizeof(LC_RTSRequest_t)); - - CFE_MSG_SetFcnCode(&RTSRequest.CmdHeader.Msg, LC_RTS_REQ_CC); + CFE_MSG_Init(CFE_MSG_PTR(RTSRequest.CommandHeader), CFE_SB_ValueToMsgId(LC_RTS_REQ_MID), sizeof(RTSRequest)); + CFE_MSG_SetFcnCode(CFE_MSG_PTR(RTSRequest.CommandHeader), LC_RTS_REQ_CC); RTSRequest.RTSId = RTSId; - CFE_SB_TransmitMsg(&RTSRequest.CmdHeader.Msg, true); + CFE_SB_TransmitMsg(CFE_MSG_PTR(RTSRequest.CommandHeader), true); return; } diff --git a/unit-test/lc_cmds_tests.c b/unit-test/lc_cmds_tests.c index 76db891..21a9017 100644 --- a/unit-test/lc_cmds_tests.c +++ b/unit-test/lc_cmds_tests.c @@ -575,7 +575,7 @@ void LC_HousekeepingReq_Test_WatchStale(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.NoArgsCmd.CmdHeader); + Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -626,7 +626,7 @@ void LC_HousekeepingReq_Test_WatchFalse(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.NoArgsCmd.CmdHeader); + Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -677,7 +677,7 @@ void LC_HousekeepingReq_Test_WatchTrue(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.NoArgsCmd.CmdHeader); + Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -729,7 +729,7 @@ void LC_HousekeepingReq_Test_WatchError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.NoArgsCmd.CmdHeader); + Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -780,7 +780,7 @@ void LC_HousekeepingReq_Test_DefaultWatchResult(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.NoArgsCmd.CmdHeader); + Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -832,7 +832,7 @@ void LC_HousekeepingReq_Test_ActionNotUsedStale(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.NoArgsCmd.CmdHeader); + Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -884,7 +884,7 @@ void LC_HousekeepingReq_Test_APStateActiveActionPass(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.NoArgsCmd.CmdHeader); + Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -939,7 +939,7 @@ void LC_HousekeepingReq_Test_APStatePassiveActionFail(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.NoArgsCmd.CmdHeader); + Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -991,7 +991,7 @@ void LC_HousekeepingReq_Test_APStateDisabledActionError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.NoArgsCmd.CmdHeader); + Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -1043,7 +1043,7 @@ void LC_HousekeepingReq_Test_APStatePermOffActionError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.NoArgsCmd.CmdHeader); + Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -1095,7 +1095,7 @@ void LC_HousekeepingReq_Test_DefaultCurrentStateAndActionResult(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.NoArgsCmd.CmdHeader); + Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -1139,7 +1139,7 @@ void LC_HousekeepingReq_Test_ManageTablesError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), -1); /* Execute the function being tested */ - Result = LC_HousekeepingReq(&UT_CmdBuf.NoArgsCmd.CmdHeader); + Result = LC_HousekeepingReq(&UT_CmdBuf.SendHkCmd.CommandHeader); /* Verify results */ UtAssert_True(Result == -1, "Result == -1"); diff --git a/unit-test/lc_utils_tests.c b/unit-test/lc_utils_tests.c index 62a0695..2175cb8 100644 --- a/unit-test/lc_utils_tests.c +++ b/unit-test/lc_utils_tests.c @@ -40,7 +40,7 @@ uint8 call_count_CFE_EVS_SendEvent; void LC_VerifyMsgLength_Test_HKRequestLengthError(void) { bool Result; - LC_NoArgsCmd_t CmdPacket; + LC_SendHkCmd_t CmdPacket; CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; size_t MsgSize; @@ -52,7 +52,7 @@ void LC_VerifyMsgLength_Test_HKRequestLengthError(void) TestMsgId = CFE_SB_ValueToMsgId(LC_SEND_HK_MID); FcnCode = LC_NOOP_CC; - MsgSize = sizeof(LC_NoArgsCmd_t) + 1; + MsgSize = sizeof(CmdPacket) + 1; 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); @@ -75,7 +75,7 @@ void LC_VerifyMsgLength_Test_HKRequestLengthError(void) void LC_VerifyMsgLength_Test_APSampleLengthError(void) { bool Result; - LC_NoArgsCmd_t CmdPacket; + LC_SampleAPCmd_t CmdPacket; CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; size_t MsgSize; @@ -110,7 +110,7 @@ void LC_VerifyMsgLength_Test_APSampleLengthError(void) void LC_VerifyMsgLength_Test_GenericLengthError(void) { bool Result; - LC_NoArgsCmd_t CmdPacket; + LC_NoopCmd_t CmdPacket; CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; size_t MsgSize; @@ -147,14 +147,14 @@ void LC_VerifyMsgLength_Test_GenericLengthError(void) void LC_VerifyMsgLength_Test_Nominal(void) { bool Result; - LC_NoArgsCmd_t CmdPacket; + LC_NoopCmd_t CmdPacket; CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; size_t MsgSize; TestMsgId = LC_UT_MID_1; FcnCode = LC_NOOP_CC; - MsgSize = sizeof(LC_NoArgsCmd_t); + MsgSize = sizeof(CmdPacket); 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); diff --git a/unit-test/lc_watch_tests.c b/unit-test/lc_watch_tests.c index 211fa73..d67eeba 100644 --- a/unit-test/lc_watch_tests.c +++ b/unit-test/lc_watch_tests.c @@ -202,7 +202,7 @@ void LC_CheckMsgForWPs_Test_Nominal(void) { uint16 WatchIndex = 0; CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; - size_t MsgSize = sizeof(UT_CmdBuf.NoArgsCmd); + size_t MsgSize = sizeof(UT_CmdBuf); CFE_TIME_SysTime_t Timestamp = {.Seconds = 0, .Subseconds = 0}; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgTime), &Timestamp, sizeof(Timestamp), false); @@ -237,7 +237,7 @@ void LC_CheckMsgForWPs_Test_Nominal(void) void LC_CheckMsgForWPs_Test_NominalMsgTime1(void) { CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; - size_t MsgSize = sizeof(UT_CmdBuf.NoArgsCmd); + size_t MsgSize = sizeof(UT_CmdBuf); CFE_TIME_SysTime_t Timestamp = {.Seconds = 1, .Subseconds = 0}; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgTime), &Timestamp, sizeof(Timestamp), false); @@ -266,7 +266,7 @@ void LC_CheckMsgForWPs_Test_NominalMsgTime2(void) { uint16 WatchIndex = 0; CFE_SB_MsgId_t TestMsgId = LC_UT_MID_1; - size_t MsgSize = sizeof(UT_CmdBuf.NoArgsCmd); + size_t MsgSize = sizeof(UT_CmdBuf); CFE_TIME_SysTime_t Timestamp = {.Seconds = 0, .Subseconds = 1}; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgTime), &Timestamp, sizeof(Timestamp), false); @@ -1567,7 +1567,7 @@ void LC_WPOffsetValid_Test_OffsetError(void) "WP offset error: MID = 0x%%08lX, WP = %%d, Offset = %%d, DataSize = %%d, MsgLen = %%d"); LC_OperData.WDTPtr[WatchIndex].DataType = LC_DATA_WATCH_UBYTE; - LC_OperData.WDTPtr[WatchIndex].WatchpointOffset = sizeof(LC_NoArgsCmd_t); + LC_OperData.WDTPtr[WatchIndex].WatchpointOffset = sizeof(LC_NoopCmd_t) - 1; /* Execute the function being tested */ Result = LC_WPOffsetValid(WatchIndex, &UT_CmdBuf.Buf); @@ -2399,4 +2399,4 @@ void UtTest_Setup(void) "LC_ValidateWDT_Test_AllOperatorIDs"); UtTest_Add(LC_ValidateWDT_Test_FloatBE, LC_Test_Setup, LC_Test_TearDown, "LC_ValidateWDT_Test_FloatBE"); -} \ No newline at end of file +} diff --git a/unit-test/utilities/lc_test_utils.h b/unit-test/utilities/lc_test_utils.h index d5c851a..b9d7911 100644 --- a/unit-test/utilities/lc_test_utils.h +++ b/unit-test/utilities/lc_test_utils.h @@ -62,15 +62,18 @@ extern CFE_ES_WriteToSysLog_context_t context_CFE_ES_WriteToSysLog; /* Command buffer typedef for any handler */ typedef union { - CFE_SB_Buffer_t Buf; - LC_NoArgsCmd_t NoArgsCmd; - LC_SetLCState_t SetLCStateCmd; - LC_SetAPState_t SetAPStateCmd; - LC_SetAPPermOff_t SetAPPermOffCmd; - LC_ResetAPStats_t ResetAPStatsCmd; - LC_ResetWPStats_t ResetWPStatsCmd; - LC_SampleAP_t SampleAPCmd; - LC_RTSRequest_t RTSRequestCmd; + CFE_SB_Buffer_t Buf; + + LC_SendHkCmd_t SendHkCmd; + LC_NoopCmd_t NoopCmd; + LC_ResetCountersCmd_t ResetCountersCmd; + LC_SetLCStateCmd_t SetLCStateCmd; + LC_SetAPStateCmd_t SetAPStateCmd; + LC_SetAPPermOffCmd_t SetAPPermOffCmd; + LC_ResetAPStatsCmd_t ResetAPStatsCmd; + LC_ResetWPStatsCmd_t ResetWPStatsCmd; + LC_SampleAPCmd_t SampleAPCmd; + LC_RTSRequestCmd_t RTSRequestCmd; } UT_CmdBuf_t; extern UT_CmdBuf_t UT_CmdBuf;