From 4a0e4d43553e31bfe2fb8c4e7cd51f18d9dd6216 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Wed, 18 Nov 2026 11:19:26 -0500 Subject: [PATCH 1/9] Issue #153, Move LC command payloads to msgdefs --- config/default_lc_msgdefs.h | 127 ++++++++++++++++++++++++++ config/default_lc_msgstruct.h | 162 +++++----------------------------- 2 files changed, 147 insertions(+), 142 deletions(-) diff --git a/config/default_lc_msgdefs.h b/config/default_lc_msgdefs.h index 085516a..a1ee9e4 100644 --- a/config/default_lc_msgdefs.h +++ b/config/default_lc_msgdefs.h @@ -35,6 +35,8 @@ /************************************************************************ * Includes ************************************************************************/ +#include "common_types.h" + #include "lc_interface_cfg.h" #include "lc_fcncodes.h" @@ -120,4 +122,129 @@ #define LC_ACTION_NOT_USED LC_APSTATE_NOT_USED #endif +/** + * \brief Reset AP (Actionpoint) Statistics Payload + * + * For command details see #LC_RESET_AP_STATS_CC + */ +typedef struct +{ + uint16 APNumber; /**< \brief Which actionpoint(s) to change */ + uint16 Padding; /**< \brief Structure padding */ +} LC_ResetAPStats_Payload_t; + +/** + * \brief Set AP (Actionpoint) Permanently Off Payload + * + * For command details see #LC_SET_AP_PERM_OFF_CC + */ +typedef struct +{ + uint16 APNumber; /**< \brief Which actionpoint to change */ + uint16 Padding; /**< \brief Structure padding */ +} LC_SetAPPermOff_Payload_t; + +/** + * \brief Set AP (Actionpoint) State Payload + * + * For command details see #LC_SET_AP_STATE_CC + */ +typedef struct +{ + uint16 APNumber; /**< \brief Which actionpoint(s) to change */ + uint16 NewAPState; /**< \brief New actionpoint state */ +} LC_SetAPState_Payload_t; + +/** + * \brief Set AP (Actionpoint) State Payload + * + * For command details see #LC_SET_AP_STATE_CC + */ +typedef struct +{ + uint16 APNumber; /**< \brief Which actionpoint(s) to change */ + uint16 NewAPState; /**< \brief New actionpoint state */ +} LC_SetAPState_Payload_t; + +/** + * \brief Set LC Application State Payload + * + * For command details see #LC_SET_LC_STATE_CC + */ +typedef struct +{ + uint16 NewLCState; /**< \brief New LC application state */ + uint16 Padding; /**< \brief Structure padding */ +} LC_SetLCState_Payload_t; + +/** + * \brief Sample AP (Actionpoint) Payload + * + * See #LC_SAMPLE_AP_MID + */ +typedef struct +{ + 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_Payload_t; + +/** + * \brief Reset WP (Watchpoint) Statistics Payload + * + * For command details see #LC_RESET_WP_STATS_CC + */ +typedef struct +{ + uint16 WPNumber; /**< \brief Which watchpoint(s) to change */ + uint16 Padding; /**< \brief Structure padding */ +} LC_ResetWPStats_Payload_t; + +/** + * \brief Payload to Start a Stored Command RTS + */ +typedef struct +{ + uint16 RTSId; /**< \brief RTS Id to start */ + uint16 Padding; /**< \brief Padding */ +} LC_RTSRequest_Payload_t; + +/** + * \defgroup cfslctlm CFS Limit Checker Telemetry + * \{ + */ + +/** + * \brief Housekeeping Payload Structure + */ +typedef struct +{ + uint8 CmdCount; /**< \brief LC Application Command Counter */ + uint8 CmdErrCount; /**< \brief LC Application Command Error Counter */ + uint8 CurrentLCState; /**< \brief Current LC application operating state */ + + uint8 Pad8; /**< \brief Structure padding */ + + uint8 WPResults[LC_HKWR_NUM_BYTES]; /**< \brief Packed watchpoint results data, 2 bits per watchpoint */ + uint8 APResults[LC_HKAR_NUM_BYTES]; /**< \brief Packed actionpoint results data, 4 bits per actionpoint */ + + uint16 PassiveRTSExecCount; /**< \brief Total count of RTS sequences not initiated because the LC state is + * set to #LC_STATE_PASSIVE or the state of the actionpoint that failed + * is set to #LC_APSTATE_PASSIVE + */ + + uint16 WPsInUse; /**< \brief How many watchpoints are currently in effect */ + uint16 ActiveAPs; /**< \brief How many actionpoints are currently active */ + + uint16 Pad16; /**< \brief Structure padding */ + + uint32 APSampleCount; /**< \brief Total count of Actionpoints sampled */ + uint32 MonitoredMsgCount; /**< \brief Total count of messages monitored for watchpoints */ + uint32 RTSExecCount; /**< \brief Total count of RTS sequences initiated */ +} LC_HkTlm_Payload_t; + +/**\}*/ + #endif diff --git a/config/default_lc_msgstruct.h b/config/default_lc_msgstruct.h index 2cdfed1..2fb06f8 100644 --- a/config/default_lc_msgstruct.h +++ b/config/default_lc_msgstruct.h @@ -84,38 +84,26 @@ typedef struct } LC_ResetCountersCmd_t; /** - * \brief Set LC Application State Payload - * - * For command details see #LC_SET_LC_STATE_CC - */ -typedef struct -{ - uint16 NewLCState; /**< \brief New LC application state */ - uint16 Padding; /**< \brief Structure padding */ -} LC_SetLCState_Payload_t; - -/** - * \brief Set LC Application State Command + * \brief Reset AP (Actionpoint) Statistics Command * - * For command details see #LC_SET_LC_STATE_CC + * For command details see #LC_RESET_AP_STATS_CC */ typedef struct { - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ - - LC_SetLCState_Payload_t Payload; -} LC_SetLCStateCmd_t; + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ + LC_ResetAPStats_Payload_t Payload; +} LC_ResetAPStatsCmd_t; /** - * \brief Set AP (Actionpoint) State Payload + * \brief Set AP (Actionpoint) Permanently Off Command * - * For command details see #LC_SET_AP_STATE_CC + * For command details see #LC_SET_AP_PERM_OFF_CC */ typedef struct { - uint16 APNumber; /**< \brief Which actionpoint(s) to change */ - uint16 NewAPState; /**< \brief New actionpoint state */ -} LC_SetAPState_Payload_t; + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ + LC_SetAPPermOff_Payload_t Payload; +} LC_SetAPPermOffCmd_t; /** * \brief Set AP (Actionpoint) State Command @@ -125,66 +113,30 @@ typedef struct typedef struct { CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ - LC_SetAPState_Payload_t Payload; } LC_SetAPStateCmd_t; /** - * \brief Set AP (Actionpoint) Permanently Off Payload - * - * For command details see #LC_SET_AP_PERM_OFF_CC - */ -typedef struct -{ - uint16 APNumber; /**< \brief Which actionpoint to change */ - uint16 Padding; /**< \brief Structure padding */ -} LC_SetAPPermOff_Payload_t; - -/** - * \brief Set AP (Actionpoint) Permanently Off Command + * \brief Set LC Application State Command * - * For command details see #LC_SET_AP_PERM_OFF_CC + * For command details see #LC_SET_LC_STATE_CC */ typedef struct { CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ - - LC_SetAPPermOff_Payload_t Payload; -} LC_SetAPPermOffCmd_t; - -/** - * \brief Reset AP (Actionpoint) Statistics Payload - * - * For command details see #LC_RESET_AP_STATS_CC - */ -typedef struct -{ - uint16 APNumber; /**< \brief Which actionpoint(s) to change */ - uint16 Padding; /**< \brief Structure padding */ -} LC_ResetAPStats_Payload_t; + LC_SetLCState_Payload_t Payload; +} LC_SetLCStateCmd_t; /** - * \brief Reset AP (Actionpoint) Statistics Command + * \brief Sample AP (Actionpoint) Request * - * For command details see #LC_RESET_AP_STATS_CC + * See #LC_SAMPLE_AP_MID */ typedef struct { CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ - - LC_ResetAPStats_Payload_t Payload; -} LC_ResetAPStatsCmd_t; - -/** - * \brief Reset WP (Watchpoint) Statistics Payload - * - * For command details see #LC_RESET_WP_STATS_CC - */ -typedef struct -{ - uint16 WPNumber; /**< \brief Which watchpoint(s) to change */ - uint16 Padding; /**< \brief Structure padding */ -} LC_ResetWPStats_Payload_t; + LC_SampleAP_Payload_t Payload; +} LC_SampleAPCmd_t; /** * \brief Reset WP (Watchpoint) Statistics Command @@ -193,46 +145,10 @@ typedef struct */ typedef struct { - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ - + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ LC_ResetWPStats_Payload_t Payload; } LC_ResetWPStatsCmd_t; -/** - * \brief Sample AP (Actionpoint) Payload - * - * See #LC_SAMPLE_AP_MID - */ -typedef struct -{ - 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_Payload_t; - -/** - * \brief Sample AP (Actionpoint) Request - * - * See #LC_SAMPLE_AP_MID - */ -typedef struct -{ - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ - - LC_SampleAP_Payload_t Payload; -} LC_SampleAPCmd_t; - -/** - * \brief Payload to Start a Stored Command RTS - */ -typedef struct -{ - uint16 RTSId; /**< \brief RTS Id to start */ - uint16 Padding; /**< \brief Padding */ -} LC_RTSRequest_Payload_t; - /** * \brief Send Command to Start a Stored Command RTS * @@ -249,54 +165,16 @@ typedef struct typedef struct { CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ - LC_RTSRequest_Payload_t Payload; } LC_RTSRequestCmd_t; -/**\}*/ - -/** - * \defgroup cfslctlm CFS Limit Checker Telemetry - * \{ - */ - -/** - * \brief Housekeeping Payload Structure - */ -typedef struct -{ - uint8 CmdCount; /**< \brief LC Application Command Counter */ - uint8 CmdErrCount; /**< \brief LC Application Command Error Counter */ - uint8 CurrentLCState; /**< \brief Current LC application operating state */ - - uint8 Pad8; /**< \brief Structure padding */ - - uint8 WPResults[LC_HKWR_NUM_BYTES]; /**< \brief Packed watchpoint results data, 2 bits per watchpoint */ - uint8 APResults[LC_HKAR_NUM_BYTES]; /**< \brief Packed actionpoint results data, 4 bits per actionpoint */ - - uint16 PassiveRTSExecCount; /**< \brief Total count of RTS sequences not initiated because the LC state is - * set to #LC_STATE_PASSIVE or the state of the actionpoint that failed - * is set to #LC_APSTATE_PASSIVE - */ - - uint16 WPsInUse; /**< \brief How many watchpoints are currently in effect */ - uint16 ActiveAPs; /**< \brief How many actionpoints are currently active */ - - uint16 Pad16; /**< \brief Structure padding */ - - uint32 APSampleCount; /**< \brief Total count of Actionpoints sampled */ - uint32 MonitoredMsgCount; /**< \brief Total count of messages monitored for watchpoints */ - uint32 RTSExecCount; /**< \brief Total count of RTS sequences initiated */ -} LC_HkTlm_Payload_t; - /** * \brief Housekeeping Telemetry Structure Structure */ typedef struct { CFE_MSG_TelemetryHeader_t TelemetryHeader; /**< \brief Telemetry Header */ - - LC_HkTlm_Payload_t Payload; + LC_HkTlm_Payload_t Payload; } LC_HkPacket_t; /**\}*/ From 561921764a3c16a42958a34b65fe81823de59308 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Wed, 18 Nov 2026 11:19:55 -0500 Subject: [PATCH 2/9] Issue #153, Standardize command counter names in housekeeping packet --- config/default_lc_msgdefs.h | 6 ++--- eds/LC.xml | 4 +-- fsw/inc/lc_fcncodes.h | 28 +++++++++---------- fsw/src/lc_app.h | 4 +-- fsw/src/lc_cmds.c | 36 ++++++++++++------------- fsw/src/lc_dispatch.c | 4 +-- fsw/src/lc_eds_dispatch.c | 2 +- unit-test/lc_app_tests.c | 4 +-- unit-test/lc_cmds_tests.c | 54 ++++++++++++++++++------------------- 9 files changed, 71 insertions(+), 71 deletions(-) diff --git a/config/default_lc_msgdefs.h b/config/default_lc_msgdefs.h index a1ee9e4..14d7c83 100644 --- a/config/default_lc_msgdefs.h +++ b/config/default_lc_msgdefs.h @@ -221,9 +221,9 @@ typedef struct */ typedef struct { - uint8 CmdCount; /**< \brief LC Application Command Counter */ - uint8 CmdErrCount; /**< \brief LC Application Command Error Counter */ - uint8 CurrentLCState; /**< \brief Current LC application operating state */ + uint8 CommandCounter; /**< \brief LC Application Command Counter */ + uint8 CommandErrCounter; /**< \brief LC Application Command Error Counter */ + uint8 CurrentLCState; /**< \brief Current LC application operating state */ uint8 Pad8; /**< \brief Structure padding */ diff --git a/eds/LC.xml b/eds/LC.xml index 08db008..f0559c1 100644 --- a/eds/LC.xml +++ b/eds/LC.xml @@ -265,8 +265,8 @@ - - + + diff --git a/fsw/inc/lc_fcncodes.h b/fsw/inc/lc_fcncodes.h index e851f68..88c39c9 100644 --- a/fsw/inc/lc_fcncodes.h +++ b/fsw/inc/lc_fcncodes.h @@ -48,7 +48,7 @@ * \par Command Verification * Successful execution of this command may be verified with * the following telemetry: - * - #LC_HkTlm_Payload_t.CmdCount will increment + * - #LC_HkTlm_Payload_t.CommandCounter will increment * - The #LC_NOOP_INF_EID informational event message will be * generated when the command is received * @@ -57,7 +57,7 @@ * - Command packet length not as expected * * \par Evidence of failure may be found in the following telemetry: - * - #LC_HkTlm_Payload_t.CmdErrCount will increment + * - #LC_HkTlm_Payload_t.CommandErrCounter will increment * - Error specific event message #LC_CMD_LEN_ERR_EID * * \par Criticality @@ -79,7 +79,7 @@ * \par Command Verification * Successful execution of this command may be verified with * the following telemetry: - * - #LC_HkTlm_Payload_t.CmdCount will be cleared + * - #LC_HkTlm_Payload_t.CommandCounter will be cleared * - The #LC_RESET_INF_EID debug event message will be * generated when the command is executed * @@ -88,7 +88,7 @@ * - Command packet length not as expected * * \par Evidence of failure may be found in the following telemetry: - * - #LC_HkTlm_Payload_t.CmdErrCount will increment + * - #LC_HkTlm_Payload_t.CommandErrCounter will increment * - Error specific event message #LC_CMD_LEN_ERR_EID * * \par Criticality @@ -110,7 +110,7 @@ * \par Command Verification * Successful execution of this command may be verified with * the following telemetry: - * - #LC_HkTlm_Payload_t.CmdCount will increment + * - #LC_HkTlm_Payload_t.CommandCounter will increment * - #LC_HkTlm_Payload_t.CurrentLCState will be set to the new state * - The #LC_LCSTATE_INF_EID informational event message will be * generated when the command is executed @@ -121,7 +121,7 @@ * - Invalid new state specified in command message * * \par Evidence of failure may be found in the following telemetry: - * - #LC_HkTlm_Payload_t.CmdErrCount will increment + * - #LC_HkTlm_Payload_t.CommandErrCounter will increment * - Error specific event message #LC_CMD_LEN_ERR_EID * - Error specific event message #LC_LCSTATE_ERR_EID * @@ -143,7 +143,7 @@ * \par Command Verification * Successful execution of this command may be verified with * the following telemetry: - * - #LC_HkTlm_Payload_t.CmdCount will increment + * - #LC_HkTlm_Payload_t.CommandCounter will increment * - The #LC_APSTATE_INF_EID informational event message will be * generated when the command is executed * @@ -157,7 +157,7 @@ * or #LC_APSTATE_PERMOFF * * \par Evidence of failure may be found in the following telemetry: - * - #LC_HkTlm_Payload_t.CmdErrCount will increment + * - #LC_HkTlm_Payload_t.CommandErrCounter will increment * - Error specific event message #LC_CMD_LEN_ERR_EID * - Error specific event message #LC_APSTATE_NEW_ERR_EID * - Error specific event message #LC_APSTATE_APNUM_ERR_EID @@ -181,7 +181,7 @@ * \par Command Verification * Successful execution of this command may be verified with * the following telemetry: - * - #LC_HkTlm_Payload_t.CmdCount will increment + * - #LC_HkTlm_Payload_t.CommandCounter will increment * - The #LC_APOFF_INF_EID informational event message will be * generated when the command is executed * @@ -193,7 +193,7 @@ * - Actionpoint current state is not #LC_APSTATE_DISABLED * * \par Evidence of failure may be found in the following telemetry: - * - #LC_HkTlm_Payload_t.CmdErrCount will increment + * - #LC_HkTlm_Payload_t.CommandErrCounter will increment * - Error specific event message #LC_CMD_LEN_ERR_EID * - Error specific event message #LC_APOFF_APNUM_ERR_EID * - Error specific event message #LC_APOFF_CURR_ERR_EID @@ -216,7 +216,7 @@ * \par Command Verification * Successful execution of this command may be verified with * the following telemetry: - * - #LC_HkTlm_Payload_t.CmdCount will increment + * - #LC_HkTlm_Payload_t.CommandCounter will increment * - The #LC_APSTATS_INF_EID informational event message will be * generated when the command is executed * @@ -227,7 +227,7 @@ * out of range * * \par Evidence of failure may be found in the following telemetry: - * - #LC_HkTlm_Payload_t.CmdErrCount will increment + * - #LC_HkTlm_Payload_t.CommandErrCounter will increment * - Error specific event message #LC_CMD_LEN_ERR_EID * - Error specific event message #LC_APSTATS_APNUM_ERR_EID * @@ -250,7 +250,7 @@ * \par Command Verification * Successful execution of this command may be verified with * the following telemetry: - * - #LC_HkTlm_Payload_t.CmdCount will increment + * - #LC_HkTlm_Payload_t.CommandCounter will increment * - The #LC_WPSTATS_INF_EID informational event message will be * generated when the command is executed * @@ -261,7 +261,7 @@ * out of range * * \par Evidence of failure may be found in the following telemetry: - * - #LC_HkTlm_Payload_t.CmdErrCount will increment + * - #LC_HkTlm_Payload_t.CommandErrCounter will increment * - Error specific event message #LC_CMD_LEN_ERR_EID * - Error specific event message #LC_WPSTATS_WPNUM_ERR_EID * diff --git a/fsw/src/lc_app.h b/fsw/src/lc_app.h index cef4a9d..9ee6169 100644 --- a/fsw/src/lc_app.h +++ b/fsw/src/lc_app.h @@ -182,8 +182,8 @@ typedef struct */ typedef struct { - uint16 CmdCount; /**< \brief Command Counter */ - uint16 CmdErrCount; /**< \brief Command Error Counter */ + uint16 CommandCounter; /**< \brief Command Counter */ + uint16 CommandErrCounter; /**< \brief Command Error Counter */ uint32 APSampleCount; /**< \brief Total count of Actionpoints sampled */ uint32 MonitoredMsgCount; /**< \brief Total count of messages monitored */ diff --git a/fsw/src/lc_cmds.c b/fsw/src/lc_cmds.c index 135ad22..98190cd 100644 --- a/fsw/src/lc_cmds.c +++ b/fsw/src/lc_cmds.c @@ -125,8 +125,8 @@ CFE_Status_t LC_SendHkCmd(const LC_SendHkCmd_t *msg) /* Update HK variables */ PayloadPtr = &LC_OperData.HkPacket.Payload; - PayloadPtr->CmdCount = LC_AppData.CmdCount; - PayloadPtr->CmdErrCount = LC_AppData.CmdErrCount; + PayloadPtr->CommandCounter = LC_AppData.CommandCounter; + PayloadPtr->CommandErrCounter = LC_AppData.CommandErrCounter; PayloadPtr->APSampleCount = LC_AppData.APSampleCount; PayloadPtr->MonitoredMsgCount = LC_AppData.MonitoredMsgCount; PayloadPtr->RTSExecCount = LC_AppData.RTSExecCount; @@ -266,7 +266,7 @@ CFE_Status_t LC_SendHkCmd(const LC_SendHkCmd_t *msg) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t LC_NoopCmd(const LC_NoopCmd_t *msg) { - LC_AppData.CmdCount++; + LC_AppData.CommandCounter++; CFE_EVS_SendEvent(LC_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, @@ -300,8 +300,8 @@ CFE_Status_t LC_ResetCountersCmd(const LC_ResetCountersCmd_t *msg) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void LC_ResetCounters(void) { - LC_AppData.CmdCount = 0; - LC_AppData.CmdErrCount = 0; + LC_AppData.CommandCounter = 0; + LC_AppData.CommandErrCounter = 0; LC_AppData.APSampleCount = 0; LC_AppData.MonitoredMsgCount = 0; @@ -324,7 +324,7 @@ CFE_Status_t LC_SetLCStateCmd(const LC_SetLCStateCmd_t *msg) case LC_STATE_PASSIVE: case LC_STATE_DISABLED: LC_AppData.CurrentLCState = CmdPtr->NewLCState; - LC_AppData.CmdCount++; + LC_AppData.CommandCounter++; CFE_EVS_SendEvent(LC_LCSTATE_INF_EID, CFE_EVS_EventType_INFORMATION, @@ -338,7 +338,7 @@ CFE_Status_t LC_SetLCStateCmd(const LC_SetLCStateCmd_t *msg) "Set LC state error: invalid state = %d", CmdPtr->NewLCState); - LC_AppData.CmdErrCount++; + LC_AppData.CommandErrCounter++; break; } @@ -377,7 +377,7 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) CmdPtr->APNumber, CmdPtr->NewAPState); - LC_AppData.CmdErrCount++; + LC_AppData.CommandErrCounter++; break; } @@ -435,7 +435,7 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) CmdPtr->APNumber, CurrentAPState); - LC_AppData.CmdErrCount++; + LC_AppData.CommandErrCounter++; } } else @@ -449,7 +449,7 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) "Set AP state error: Invalid AP number = %d", CmdPtr->APNumber); - LC_AppData.CmdErrCount++; + LC_AppData.CommandErrCounter++; } } @@ -459,7 +459,7 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) */ if (CmdSuccess == true) { - LC_AppData.CmdCount++; + LC_AppData.CommandCounter++; CFE_EVS_SendEvent(LC_APSTATE_INF_EID, CFE_EVS_EventType_INFORMATION, @@ -495,7 +495,7 @@ CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg) "Set AP perm off error: Invalid AP number = %d", CmdPtr->APNumber); - LC_AppData.CmdErrCount++; + LC_AppData.CommandErrCounter++; } else { @@ -514,7 +514,7 @@ CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg) CmdPtr->APNumber, CurrentAPState); - LC_AppData.CmdErrCount++; + LC_AppData.CommandErrCounter++; } else { @@ -523,7 +523,7 @@ CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg) */ LC_OperData.ARTPtr[TableIndex].CurrentState = LC_APSTATE_PERMOFF; - LC_AppData.CmdCount++; + LC_AppData.CommandCounter++; CFE_EVS_SendEvent(LC_APOFF_INF_EID, CFE_EVS_EventType_INFORMATION, @@ -560,7 +560,7 @@ CFE_Status_t LC_ResetAPStatsCmd(const LC_ResetAPStatsCmd_t *msg) else { /* arg is out of range (zero based table index) */ - LC_AppData.CmdErrCount++; + LC_AppData.CommandErrCounter++; CFE_EVS_SendEvent(LC_APSTATS_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, @@ -570,7 +570,7 @@ CFE_Status_t LC_ResetAPStatsCmd(const LC_ResetAPStatsCmd_t *msg) if (CmdSuccess == true) { - LC_AppData.CmdCount++; + LC_AppData.CommandCounter++; CFE_EVS_SendEvent(LC_APSTATS_INF_EID, CFE_EVS_EventType_INFORMATION, @@ -635,7 +635,7 @@ CFE_Status_t LC_ResetWPStatsCmd(const LC_ResetWPStatsCmd_t *msg) else { /* arg is out of range (zero based table index) */ - LC_AppData.CmdErrCount++; + LC_AppData.CommandErrCounter++; CFE_EVS_SendEvent(LC_WPSTATS_WPNUM_ERR_EID, CFE_EVS_EventType_ERROR, @@ -645,7 +645,7 @@ CFE_Status_t LC_ResetWPStatsCmd(const LC_ResetWPStatsCmd_t *msg) if (CmdSuccess == true) { - LC_AppData.CmdCount++; + LC_AppData.CommandCounter++; CFE_EVS_SendEvent(LC_WPSTATS_INF_EID, CFE_EVS_EventType_INFORMATION, diff --git a/fsw/src/lc_dispatch.c b/fsw/src/lc_dispatch.c index 40e5b88..1390270 100644 --- a/fsw/src/lc_dispatch.c +++ b/fsw/src/lc_dispatch.c @@ -104,7 +104,7 @@ bool LC_VerifyMsgLength(const CFE_MSG_Message_t *msgPtr, size_t ExpectedLength) CommandCode, (int)ActualLength, (int)ExpectedLength); - LC_AppData.CmdErrCount++; + LC_AppData.CommandErrCounter++; } result = false; @@ -302,7 +302,7 @@ void LC_AppProcessCmd(const CFE_SB_Buffer_t *BufPtr) "Invalid command code: ID = 0x%08lX, CC = %d", (unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode); - LC_AppData.CmdErrCount++; + LC_AppData.CommandErrCounter++; break; } } diff --git a/fsw/src/lc_eds_dispatch.c b/fsw/src/lc_eds_dispatch.c index 0c89945..6500511 100644 --- a/fsw/src/lc_eds_dispatch.c +++ b/fsw/src/lc_eds_dispatch.c @@ -77,7 +77,7 @@ void LC_AppPipe(const CFE_SB_Buffer_t *BufPtr) CFE_MSG_GetMsgId(&BufPtr->Msg, &MsgId); CFE_MSG_GetSize(&BufPtr->Msg, &MsgSize); CFE_MSG_GetFcnCode(&BufPtr->Msg, &MsgFc); - ++LC_AppData.CmdErrCount; + ++LC_AppData.CommandErrCounter; if (Status == CFE_STATUS_UNKNOWN_MSG_ID) { diff --git a/unit-test/lc_app_tests.c b/unit-test/lc_app_tests.c index abc366f..d503378 100644 --- a/unit-test/lc_app_tests.c +++ b/unit-test/lc_app_tests.c @@ -330,8 +330,8 @@ void LC_AppInit_Test_Nominal(void) /* Note: not testing LC_OperData.WatchPtLinks == 0, because it is modified by a subfunction */ UtAssert_INT32_EQ(LC_OperData.HaveActiveCDS, 0); - UtAssert_INT32_EQ(LC_AppData.CmdCount, 0); - UtAssert_INT32_EQ(LC_AppData.CmdErrCount, 0); + UtAssert_INT32_EQ(LC_AppData.CommandCounter, 0); + UtAssert_INT32_EQ(LC_AppData.CommandErrCounter, 0); UtAssert_INT32_EQ(LC_AppData.APSampleCount, 0); UtAssert_INT32_EQ(LC_AppData.MonitoredMsgCount, 0); UtAssert_INT32_EQ(LC_AppData.RTSExecCount, 0); diff --git a/unit-test/lc_cmds_tests.c b/unit-test/lc_cmds_tests.c index 1ce0b70..8c818f3 100644 --- a/unit-test/lc_cmds_tests.c +++ b/unit-test/lc_cmds_tests.c @@ -831,11 +831,11 @@ void LC_SendHkCmd_Test_ManageTablesError(void) void LC_NoopCmd_Test(void) { - LC_AppData.CmdCount = 1; + LC_AppData.CommandCounter = 1; LC_NoopCmd(&UT_CmdBuf.NoopCmd); - UtAssert_UINT8_EQ(LC_AppData.CmdCount, 2); + UtAssert_UINT8_EQ(LC_AppData.CommandCounter, 2); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } @@ -848,8 +848,8 @@ void LC_ResetCountersCmd_Test(void) void LC_ResetCounters_Test(void) { - LC_AppData.CmdCount = 1; - LC_AppData.CmdErrCount = 2; + LC_AppData.CommandCounter = 1; + LC_AppData.CommandErrCounter = 2; LC_AppData.APSampleCount = 3; LC_AppData.MonitoredMsgCount = 4; @@ -860,8 +860,8 @@ void LC_ResetCounters_Test(void) LC_ResetCounters(); /* Verify results */ - UtAssert_True(LC_AppData.CmdCount == 0, "LC_AppData.CmdCount == 0"); - UtAssert_True(LC_AppData.CmdErrCount == 0, "LC_AppData.CmdErrCount == 0"); + UtAssert_True(LC_AppData.CommandCounter == 0, "LC_AppData.CommandCounter == 0"); + UtAssert_True(LC_AppData.CommandErrCounter == 0, "LC_AppData.CommandErrCounter == 0"); UtAssert_True(LC_AppData.APSampleCount == 0, "LC_AppData.APSampleCount == 0"); UtAssert_True(LC_AppData.MonitoredMsgCount == 0, "LC_AppData.MonitoredMsgCount == 0"); UtAssert_True(LC_AppData.RTSExecCount == 0, "LC_AppData.RTSExecCount == 0"); @@ -890,7 +890,7 @@ void LC_SetLCStateCmd_Test_Active(void) /* Verify results */ UtAssert_True(LC_AppData.CurrentLCState == LC_STATE_ACTIVE, "LC_AppData.CurrentLCState == LC_STATE_ACTIVE"); - UtAssert_True(LC_AppData.CmdCount == 1, "LC_AppData.CmdCount == 1"); + UtAssert_True(LC_AppData.CommandCounter == 1, "LC_AppData.CommandCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -921,7 +921,7 @@ void LC_SetLCStateCmd_Test_Passive(void) /* Verify results */ UtAssert_True(LC_AppData.CurrentLCState == LC_STATE_PASSIVE, "LC_AppData.CurrentLCState == LC_STATE_PASSIVE"); - UtAssert_True(LC_AppData.CmdCount == 1, "LC_AppData.CmdCount == 1"); + UtAssert_True(LC_AppData.CommandCounter == 1, "LC_AppData.CommandCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -952,7 +952,7 @@ void LC_SetLCStateCmd_Test_Disabled(void) /* Verify results */ UtAssert_True(LC_AppData.CurrentLCState == LC_STATE_DISABLED, "LC_AppData.CurrentLCState == LC_STATE_DISABLED"); - UtAssert_True(LC_AppData.CmdCount == 1, "LC_AppData.CmdCount == 1"); + UtAssert_True(LC_AppData.CommandCounter == 1, "LC_AppData.CommandCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -982,7 +982,7 @@ void LC_SetLCStateCmd_Test_Default(void) LC_SetLCStateCmd(&UT_CmdBuf.SetLCStateCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1015,7 +1015,7 @@ void LC_SetAPStateCmd_Test_Default(void) LC_SetAPStateCmd(&UT_CmdBuf.SetAPStateCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1461,7 +1461,7 @@ void LC_SetAPStateCmd_Test_InvalidCurrentAPStateActive(void) LC_SetAPStateCmd(&UT_CmdBuf.SetAPStateCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1496,7 +1496,7 @@ void LC_SetAPStateCmd_Test_InvalidCurrentAPStatePassive(void) LC_SetAPStateCmd(&UT_CmdBuf.SetAPStateCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1531,7 +1531,7 @@ void LC_SetAPStateCmd_Test_InvalidCurrentAPStateDisabled(void) LC_SetAPStateCmd(&UT_CmdBuf.SetAPStateCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1563,7 +1563,7 @@ void LC_SetAPStateCmd_Test_InvalidAPNumberActive(void) LC_SetAPStateCmd(&UT_CmdBuf.SetAPStateCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1594,7 +1594,7 @@ void LC_SetAPStateCmd_Test_InvalidAPNumberPassive(void) LC_SetAPStateCmd(&UT_CmdBuf.SetAPStateCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1624,7 +1624,7 @@ void LC_SetAPStateCmd_Test_InvalidAPNumberDisabled(void) LC_SetAPStateCmd(&UT_CmdBuf.SetAPStateCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_APSTATE_APNUM_ERR_EID); @@ -1652,7 +1652,7 @@ void LC_SetAPPermOffCmd_Test_InvalidAPNumberMaxActionpoints(void) LC_SetAPPermOffCmd(&UT_CmdBuf.SetAPPermOffCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1681,7 +1681,7 @@ void LC_SetAPPermOffCmd_Test_InvalidAPNumberAllActionpoints(void) LC_SetAPPermOffCmd(&UT_CmdBuf.SetAPPermOffCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1714,7 +1714,7 @@ void LC_SetAPPermOffCmd_Test_APNotDisabled(void) LC_SetAPPermOffCmd(&UT_CmdBuf.SetAPPermOffCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1747,7 +1747,7 @@ void LC_SetAPPermOffCmd_Test_Nominal(void) /* Verify results */ UtAssert_True(LC_OperData.ARTPtr[PayloadPtr->APNumber].CurrentState == 4, "LC_OperData.ARTPtr[PayloadPtr->APNumber].CurrentState == 4"); - UtAssert_True(LC_AppData.CmdCount == 1, "LC_AppData.CmdCount == 1"); + UtAssert_True(LC_AppData.CommandCounter == 1, "LC_AppData.CommandCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1776,7 +1776,7 @@ void LC_ResetAPStatsCmd_Test_AllActionPoints(void) LC_ResetAPStatsCmd(&UT_CmdBuf.ResetAPStatsCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdCount == 1, "LC_AppData.CmdCount == 1"); + UtAssert_True(LC_AppData.CommandCounter == 1, "LC_AppData.CommandCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1805,7 +1805,7 @@ void LC_ResetAPStatsCmd_Test_SingleActionPoint(void) LC_ResetAPStatsCmd(&UT_CmdBuf.ResetAPStatsCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdCount == 1, "LC_AppData.CmdCount == 1"); + UtAssert_True(LC_AppData.CommandCounter == 1, "LC_AppData.CommandCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1834,7 +1834,7 @@ void LC_ResetAPStatsCmd_Test_InvalidAPNumber(void) LC_ResetAPStatsCmd(&UT_CmdBuf.ResetAPStatsCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1964,7 +1964,7 @@ void LC_ResetWPStatsCmd_Test_AllWatchPoints(void) LC_ResetWPStatsCmd(&UT_CmdBuf.ResetWPStatsCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdCount == 1, "LC_AppData.CmdCount == 1"); + UtAssert_True(LC_AppData.CommandCounter == 1, "LC_AppData.CommandCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -1993,7 +1993,7 @@ void LC_ResetWPStatsCmd_Test_SingleWatchPoint(void) LC_ResetWPStatsCmd(&UT_CmdBuf.ResetWPStatsCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdCount == 1, "LC_AppData.CmdCount == 1"); + UtAssert_True(LC_AppData.CommandCounter == 1, "LC_AppData.CommandCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_WPSTATS_INF_EID); @@ -2021,7 +2021,7 @@ void LC_ResetWPStatsCmd_Test_InvalidWPNumber(void) LC_ResetWPStatsCmd(&UT_CmdBuf.ResetWPStatsCmd); /* Verify results */ - UtAssert_True(LC_AppData.CmdErrCount == 1, "LC_AppData.CmdErrCount == 1"); + UtAssert_True(LC_AppData.CommandErrCounter == 1, "LC_AppData.CommandErrCounter == 1"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); From 75ac430db8e7d69f74fd2f79d2f2a8ce9a879341 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Wed, 18 Nov 2026 11:20:54 -0500 Subject: [PATCH 3/9] Issue #153, Consolidate payload structs --- config/default_lc_msgdefs.h | 35 +++++----------------- config/default_lc_msgstruct.h | 8 ++--- fsw/src/lc_cmds.c | 10 +++---- unit-test/lc_cmds_tests.c | 56 +++++++++++++++++------------------ 4 files changed, 44 insertions(+), 65 deletions(-) diff --git a/config/default_lc_msgdefs.h b/config/default_lc_msgdefs.h index 14d7c83..8dc95fb 100644 --- a/config/default_lc_msgdefs.h +++ b/config/default_lc_msgdefs.h @@ -125,35 +125,14 @@ /** * \brief Reset AP (Actionpoint) Statistics Payload * - * For command details see #LC_RESET_AP_STATS_CC + * For command details see #LC_RESET_AP_STATS_CC, + * #LC_SET_AP_PERM_OFF_CC */ typedef struct { uint16 APNumber; /**< \brief Which actionpoint(s) to change */ - uint16 Padding; /**< \brief Structure padding */ -} LC_ResetAPStats_Payload_t; - -/** - * \brief Set AP (Actionpoint) Permanently Off Payload - * - * For command details see #LC_SET_AP_PERM_OFF_CC - */ -typedef struct -{ - uint16 APNumber; /**< \brief Which actionpoint to change */ - uint16 Padding; /**< \brief Structure padding */ -} LC_SetAPPermOff_Payload_t; - -/** - * \brief Set AP (Actionpoint) State Payload - * - * For command details see #LC_SET_AP_STATE_CC - */ -typedef struct -{ - uint16 APNumber; /**< \brief Which actionpoint(s) to change */ - uint16 NewAPState; /**< \brief New actionpoint state */ -} LC_SetAPState_Payload_t; + uint16 Padding; /**< \brief Structure padding */ +} LC_APNumber_Payload_t; /** * \brief Set AP (Actionpoint) State Payload @@ -173,8 +152,8 @@ typedef struct */ typedef struct { - uint16 NewLCState; /**< \brief New LC application state */ - uint16 Padding; /**< \brief Structure padding */ + uint16 NewLCState; /**< \brief New LC application state */ + uint16 Padding; /**< \brief Structure padding */ } LC_SetLCState_Payload_t; /** @@ -199,7 +178,7 @@ typedef struct typedef struct { uint16 WPNumber; /**< \brief Which watchpoint(s) to change */ - uint16 Padding; /**< \brief Structure padding */ + uint16 Padding; /**< \brief Structure padding */ } LC_ResetWPStats_Payload_t; /** diff --git a/config/default_lc_msgstruct.h b/config/default_lc_msgstruct.h index 2fb06f8..d0ad7b1 100644 --- a/config/default_lc_msgstruct.h +++ b/config/default_lc_msgstruct.h @@ -90,8 +90,8 @@ typedef struct */ typedef struct { - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ - LC_ResetAPStats_Payload_t Payload; + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ + LC_APNumber_Payload_t Payload; } LC_ResetAPStatsCmd_t; /** @@ -101,8 +101,8 @@ typedef struct */ typedef struct { - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ - LC_SetAPPermOff_Payload_t Payload; + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */ + LC_APNumber_Payload_t Payload; } LC_SetAPPermOffCmd_t; /** diff --git a/fsw/src/lc_cmds.c b/fsw/src/lc_cmds.c index 98190cd..accc23d 100644 --- a/fsw/src/lc_cmds.c +++ b/fsw/src/lc_cmds.c @@ -480,9 +480,9 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg) { - const LC_SetAPPermOff_Payload_t *CmdPtr = &msg->Payload; - uint32 TableIndex; - uint8 CurrentAPState; + const LC_APNumber_Payload_t *CmdPtr = &msg->Payload; + uint32 TableIndex; + uint8 CurrentAPState; if (((CmdPtr->APNumber) == LC_ALL_ACTIONPOINTS) || ((CmdPtr->APNumber) >= LC_MAX_ACTIONPOINTS)) { @@ -543,8 +543,8 @@ CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t LC_ResetAPStatsCmd(const LC_ResetAPStatsCmd_t *msg) { - const LC_ResetAPStats_Payload_t *CmdPtr = &msg->Payload; - bool CmdSuccess = false; + const LC_APNumber_Payload_t *CmdPtr = &msg->Payload; + bool CmdSuccess = false; /* arg may be one or all AP's */ if (CmdPtr->APNumber == LC_ALL_ACTIONPOINTS) diff --git a/unit-test/lc_cmds_tests.c b/unit-test/lc_cmds_tests.c index 8c818f3..2d6ed39 100644 --- a/unit-test/lc_cmds_tests.c +++ b/unit-test/lc_cmds_tests.c @@ -1636,10 +1636,10 @@ void LC_SetAPStateCmd_Test_InvalidAPNumberDisabled(void) void LC_SetAPPermOffCmd_Test_InvalidAPNumberMaxActionpoints(void) { - CFE_SB_MsgId_t TestMsgId; - LC_SetAPPermOff_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPPermOffCmd.Payload; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + CFE_SB_MsgId_t TestMsgId; + LC_APNumber_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPPermOffCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); @@ -1665,10 +1665,10 @@ void LC_SetAPPermOffCmd_Test_InvalidAPNumberMaxActionpoints(void) void LC_SetAPPermOffCmd_Test_InvalidAPNumberAllActionpoints(void) { - CFE_SB_MsgId_t TestMsgId; - LC_SetAPPermOff_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPPermOffCmd.Payload; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + CFE_SB_MsgId_t TestMsgId; + LC_APNumber_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPPermOffCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); @@ -1694,10 +1694,10 @@ void LC_SetAPPermOffCmd_Test_InvalidAPNumberAllActionpoints(void) void LC_SetAPPermOffCmd_Test_APNotDisabled(void) { - CFE_SB_MsgId_t TestMsgId; - LC_SetAPPermOff_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPPermOffCmd.Payload; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + CFE_SB_MsgId_t TestMsgId; + LC_APNumber_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPPermOffCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); @@ -1727,10 +1727,10 @@ void LC_SetAPPermOffCmd_Test_APNotDisabled(void) void LC_SetAPPermOffCmd_Test_Nominal(void) { - CFE_SB_MsgId_t TestMsgId; - LC_SetAPPermOff_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPPermOffCmd.Payload; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + CFE_SB_MsgId_t TestMsgId; + LC_APNumber_Payload_t *PayloadPtr = &UT_CmdBuf.SetAPPermOffCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); @@ -1760,10 +1760,10 @@ void LC_SetAPPermOffCmd_Test_Nominal(void) void LC_ResetAPStatsCmd_Test_AllActionPoints(void) { - CFE_SB_MsgId_t TestMsgId; - LC_ResetAPStats_Payload_t *PayloadPtr = &UT_CmdBuf.ResetAPStatsCmd.Payload; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + CFE_SB_MsgId_t TestMsgId; + LC_APNumber_Payload_t *PayloadPtr = &UT_CmdBuf.ResetAPStatsCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); @@ -1789,10 +1789,10 @@ void LC_ResetAPStatsCmd_Test_AllActionPoints(void) void LC_ResetAPStatsCmd_Test_SingleActionPoint(void) { - CFE_SB_MsgId_t TestMsgId; - LC_ResetAPStats_Payload_t *PayloadPtr = &UT_CmdBuf.ResetAPStatsCmd.Payload; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + CFE_SB_MsgId_t TestMsgId; + LC_APNumber_Payload_t *PayloadPtr = &UT_CmdBuf.ResetAPStatsCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); @@ -1818,10 +1818,10 @@ void LC_ResetAPStatsCmd_Test_SingleActionPoint(void) void LC_ResetAPStatsCmd_Test_InvalidAPNumber(void) { - CFE_SB_MsgId_t TestMsgId; - LC_ResetAPStats_Payload_t *PayloadPtr = &UT_CmdBuf.ResetAPStatsCmd.Payload; - int32 strCmpResult; - char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + CFE_SB_MsgId_t TestMsgId; + LC_APNumber_Payload_t *PayloadPtr = &UT_CmdBuf.ResetAPStatsCmd.Payload; + int32 strCmpResult; + char ExpectedEventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; TestMsgId = CFE_SB_ValueToMsgId(LC_CMD_MID); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); From e233e6ae94949e7a31b739177432c927829f53ed Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Wed, 18 Nov 2026 11:21:22 -0500 Subject: [PATCH 4/9] Issue #153, Update EDS XML --- eds/LC.xml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/eds/LC.xml b/eds/LC.xml index f0559c1..a4875c2 100644 --- a/eds/LC.xml +++ b/eds/LC.xml @@ -268,13 +268,13 @@ - + - + @@ -295,14 +295,7 @@ - - - - - - - - + @@ -321,6 +314,7 @@ + @@ -339,6 +333,7 @@ + @@ -388,7 +383,7 @@ - + @@ -397,7 +392,7 @@ - + From fe8b9468af6a2c92621e0727a4271ce45a61a023 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Wed, 18 Nov 2026 11:21:51 -0500 Subject: [PATCH 5/9] Issue #153, Clean up commands --- fsw/src/lc_cmds.c | 172 ++++++++++++++++++++++------------------------ fsw/src/lc_cmds.h | 13 ---- 2 files changed, 84 insertions(+), 101 deletions(-) diff --git a/fsw/src/lc_cmds.c b/fsw/src/lc_cmds.c index accc23d..62a3f28 100644 --- a/fsw/src/lc_cmds.c +++ b/fsw/src/lc_cmds.c @@ -33,21 +33,20 @@ #include "lc_watch.h" #include "lc_platform_cfg.h" #include "lc_utils.h" - -#define LC_GET_CMD_PAYLOAD(ptr, type) (&((const type *)(ptr))->Payload) +#include "lc_msgdefs.h" /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* Sample Actionpoints Request */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr) +void LC_SampleAPReq(const LC_SampleAPCmd_t *Msg) { - const LC_SampleAP_Payload_t *LC_SampleAP; - uint16 WatchIndex; - bool ValidSampleCmd = false; + uint16 WatchIndex; + bool ValidSampleCmd; - LC_SampleAP = LC_GET_CMD_PAYLOAD(BufPtr, LC_SampleAPCmd_t); + ValidSampleCmd = false; + const LC_SampleAP_Payload_t *Payload = &(Msg->Payload); /* ** Ignore AP sample requests if disabled at the application level @@ -57,7 +56,7 @@ void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr) /* ** Range check the actionpoint array index arguments */ - if ((LC_SampleAP->StartIndex == LC_ALL_ACTIONPOINTS) && (LC_SampleAP->EndIndex == LC_ALL_ACTIONPOINTS)) + if ((Payload->StartIndex == LC_ALL_ACTIONPOINTS) && (Payload->EndIndex == LC_ALL_ACTIONPOINTS)) { /* ** Allow special "sample all" heritage values @@ -65,12 +64,12 @@ void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr) LC_SampleAPs(0, LC_MAX_ACTIONPOINTS - 1); ValidSampleCmd = true; } - else if ((LC_SampleAP->StartIndex <= LC_SampleAP->EndIndex) && (LC_SampleAP->EndIndex < LC_MAX_ACTIONPOINTS)) + else if ((Payload->StartIndex <= Payload->EndIndex) && (Payload->EndIndex < LC_MAX_ACTIONPOINTS)) { /* ** Start is less or equal to end, and end is within the array */ - LC_SampleAPs(LC_SampleAP->StartIndex, LC_SampleAP->EndIndex); + LC_SampleAPs(Payload->StartIndex, Payload->EndIndex); ValidSampleCmd = true; } else @@ -81,14 +80,14 @@ void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr) CFE_EVS_SendEvent(LC_APSAMPLE_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, "Sample AP error: invalid AP number, start = %d, end = %d", - LC_SampleAP->StartIndex, - LC_SampleAP->EndIndex); + Payload->StartIndex, + Payload->EndIndex); } /* ** Optionally update the age of watchpoint results */ - if ((LC_SampleAP->UpdateAge != 0) && (ValidSampleCmd)) + if ((Payload->UpdateAge != 0) && (ValidSampleCmd)) { for (WatchIndex = 0; WatchIndex < LC_MAX_WATCHPOINTS; WatchIndex++) { @@ -111,19 +110,18 @@ void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr) /* Housekeeping request */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -CFE_Status_t LC_SendHkCmd(const LC_SendHkCmd_t *msg) +CFE_Status_t LC_SendHkCmd(const LC_SendHkCmd_t *Msg) { - uint16 TableIndex; - uint16 HKIndex; - uint8 ByteData = 0; - uint8 Shift; - uint8 TempByteData; - uint8 i; - + uint16 TableIndex; + uint16 HKIndex; + uint8 ByteData; + uint8 Shift; + uint8 TempByteData; + uint8 i; LC_HkTlm_Payload_t *PayloadPtr; - /* Update HK variables */ PayloadPtr = &LC_OperData.HkPacket.Payload; + ByteData = 0; PayloadPtr->CommandCounter = LC_AppData.CommandCounter; PayloadPtr->CommandErrCounter = LC_AppData.CommandErrCounter; @@ -264,7 +262,7 @@ CFE_Status_t LC_SendHkCmd(const LC_SendHkCmd_t *msg) /* Noop command */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -CFE_Status_t LC_NoopCmd(const LC_NoopCmd_t *msg) +CFE_Status_t LC_NoopCmd(const LC_NoopCmd_t *Msg) { LC_AppData.CommandCounter++; @@ -284,21 +282,7 @@ CFE_Status_t LC_NoopCmd(const LC_NoopCmd_t *msg) /* Reset counters command */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -CFE_Status_t LC_ResetCountersCmd(const LC_ResetCountersCmd_t *msg) -{ - LC_ResetCounters(); - - CFE_EVS_SendEvent(LC_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset counters command"); - - return CFE_SUCCESS; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Reset housekeeping counters */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void LC_ResetCounters(void) +CFE_Status_t LC_ResetCountersCmd(const LC_ResetCountersCmd_t *Msg) { LC_AppData.CommandCounter = 0; LC_AppData.CommandErrCounter = 0; @@ -307,6 +291,10 @@ void LC_ResetCounters(void) LC_AppData.MonitoredMsgCount = 0; LC_AppData.RTSExecCount = 0; LC_AppData.PassiveRTSExecCount = 0; + + CFE_EVS_SendEvent(LC_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset counters command"); + + return CFE_SUCCESS; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -314,29 +302,29 @@ void LC_ResetCounters(void) /* Set LC state command */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -CFE_Status_t LC_SetLCStateCmd(const LC_SetLCStateCmd_t *msg) +CFE_Status_t LC_SetLCStateCmd(const LC_SetLCStateCmd_t *Msg) { - const LC_SetLCState_Payload_t *CmdPtr = &msg->Payload; + const LC_SetLCState_Payload_t *Payload = &(Msg->Payload); - switch (CmdPtr->NewLCState) + switch (Payload->NewLCState) { case LC_STATE_ACTIVE: case LC_STATE_PASSIVE: case LC_STATE_DISABLED: - LC_AppData.CurrentLCState = CmdPtr->NewLCState; + LC_AppData.CurrentLCState = Payload->NewLCState; LC_AppData.CommandCounter++; CFE_EVS_SendEvent(LC_LCSTATE_INF_EID, CFE_EVS_EventType_INFORMATION, "Set LC state command: new state = %d", - CmdPtr->NewLCState); + Payload->NewLCState); break; default: CFE_EVS_SendEvent(LC_LCSTATE_ERR_EID, CFE_EVS_EventType_ERROR, "Set LC state error: invalid state = %d", - CmdPtr->NewLCState); + Payload->NewLCState); LC_AppData.CommandErrCounter++; break; @@ -350,19 +338,22 @@ CFE_Status_t LC_SetLCStateCmd(const LC_SetLCStateCmd_t *msg) /* Set actionpoint state command */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) +CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *Msg) { - const LC_SetAPState_Payload_t *CmdPtr = &msg->Payload; - uint32 TableIndex; - uint8 CurrentAPState; - bool ValidState = true; - bool CmdSuccess = false; + uint32 TableIndex; + uint8 CurrentAPState; + bool ValidState; + bool CmdSuccess; + + const LC_SetAPState_Payload_t *Payload = &(Msg->Payload); + ValidState = true; + CmdSuccess = false; /* ** Do a sanity check on the new actionpoint state ** specified. */ - switch (CmdPtr->NewAPState) + switch (Payload->NewAPState) { case LC_APSTATE_ACTIVE: case LC_APSTATE_PASSIVE: @@ -374,8 +365,8 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) CFE_EVS_SendEvent(LC_APSTATE_NEW_ERR_EID, CFE_EVS_EventType_ERROR, "Set AP state error: AP = %d, Invalid new state = %d", - CmdPtr->APNumber, - CmdPtr->NewAPState); + Payload->APNumber, + Payload->NewAPState); LC_AppData.CommandErrCounter++; break; @@ -386,7 +377,7 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) */ if (ValidState == true) { - if ((CmdPtr->APNumber) == LC_ALL_ACTIONPOINTS) + if ((Payload->APNumber) == LC_ALL_ACTIONPOINTS) { /* ** Set all actionpoints to the new state except those that are not @@ -398,7 +389,7 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) if ((CurrentAPState != LC_APSTATE_NOT_USED) && (CurrentAPState != LC_APSTATE_PERMOFF)) { - LC_OperData.ARTPtr[TableIndex].CurrentState = CmdPtr->NewAPState; + LC_OperData.ARTPtr[TableIndex].CurrentState = Payload->NewAPState; } } @@ -409,9 +400,9 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) } else { - if ((CmdPtr->APNumber) < LC_MAX_ACTIONPOINTS) + if ((Payload->APNumber) < LC_MAX_ACTIONPOINTS) { - TableIndex = CmdPtr->APNumber; + TableIndex = Payload->APNumber; CurrentAPState = LC_OperData.ARTPtr[TableIndex].CurrentState; if ((CurrentAPState != LC_APSTATE_NOT_USED) && (CurrentAPState != LC_APSTATE_PERMOFF)) @@ -419,7 +410,7 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) /* ** Update state for single actionpoint specified */ - LC_OperData.ARTPtr[TableIndex].CurrentState = CmdPtr->NewAPState; + LC_OperData.ARTPtr[TableIndex].CurrentState = Payload->NewAPState; CmdSuccess = true; } @@ -432,7 +423,7 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) CFE_EVS_SendEvent(LC_APSTATE_CURR_ERR_EID, CFE_EVS_EventType_ERROR, "Set AP state error: AP = %d, Invalid current AP state = %d", - CmdPtr->APNumber, + Payload->APNumber, CurrentAPState); LC_AppData.CommandErrCounter++; @@ -447,7 +438,7 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) CFE_EVS_SendEvent(LC_APSTATE_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, "Set AP state error: Invalid AP number = %d", - CmdPtr->APNumber); + Payload->APNumber); LC_AppData.CommandErrCounter++; } @@ -464,8 +455,8 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) CFE_EVS_SendEvent(LC_APSTATE_INF_EID, CFE_EVS_EventType_INFORMATION, "Set AP state command: AP = %d, New state = %d", - CmdPtr->APNumber, - CmdPtr->NewAPState); + Payload->APNumber, + Payload->NewAPState); } } /* end ValidState if */ @@ -478,13 +469,14 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) /* Set actionpoint permanently off command */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg) +CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *Msg) { - const LC_APNumber_Payload_t *CmdPtr = &msg->Payload; - uint32 TableIndex; - uint8 CurrentAPState; + uint32 TableIndex; + uint8 CurrentAPState; + + const LC_APNumber_Payload_t *Payload = &(Msg->Payload); - if (((CmdPtr->APNumber) == LC_ALL_ACTIONPOINTS) || ((CmdPtr->APNumber) >= LC_MAX_ACTIONPOINTS)) + if (((Payload->APNumber) == LC_ALL_ACTIONPOINTS) || ((Payload->APNumber) >= LC_MAX_ACTIONPOINTS)) { /* ** Invalid actionpoint number @@ -493,13 +485,13 @@ CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg) CFE_EVS_SendEvent(LC_APOFF_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, "Set AP perm off error: Invalid AP number = %d", - CmdPtr->APNumber); + Payload->APNumber); LC_AppData.CommandErrCounter++; } else { - TableIndex = CmdPtr->APNumber; + TableIndex = Payload->APNumber; CurrentAPState = LC_OperData.ARTPtr[TableIndex].CurrentState; if (CurrentAPState != LC_APSTATE_DISABLED) @@ -511,7 +503,7 @@ CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg) CFE_EVS_SendEvent(LC_APOFF_CURR_ERR_EID, CFE_EVS_EventType_ERROR, "Set AP perm off error, AP NOT Disabled: AP = %d, Current state = %d", - CmdPtr->APNumber, + Payload->APNumber, CurrentAPState); LC_AppData.CommandErrCounter++; @@ -528,10 +520,10 @@ CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg) CFE_EVS_SendEvent(LC_APOFF_INF_EID, CFE_EVS_EventType_INFORMATION, "Set AP permanently off command: AP = %d", - CmdPtr->APNumber); + Payload->APNumber); } - } /* end CmdPtr -> APNumber else */ + } /* end Payload -> APNumber else */ return CFE_SUCCESS; } @@ -541,20 +533,22 @@ CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg) /* Reset actionpoint statistics command */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -CFE_Status_t LC_ResetAPStatsCmd(const LC_ResetAPStatsCmd_t *msg) +CFE_Status_t LC_ResetAPStatsCmd(const LC_ResetAPStatsCmd_t *Msg) { - const LC_APNumber_Payload_t *CmdPtr = &msg->Payload; - bool CmdSuccess = false; + bool CmdSuccess; + + const LC_APNumber_Payload_t *Payload = &(Msg->Payload); + CmdSuccess = false; /* arg may be one or all AP's */ - if (CmdPtr->APNumber == LC_ALL_ACTIONPOINTS) + if (Payload->APNumber == LC_ALL_ACTIONPOINTS) { LC_ResetResultsAP(0, LC_MAX_ACTIONPOINTS - 1, true); CmdSuccess = true; } - else if (CmdPtr->APNumber < LC_MAX_ACTIONPOINTS) + else if (Payload->APNumber < LC_MAX_ACTIONPOINTS) { - LC_ResetResultsAP(CmdPtr->APNumber, CmdPtr->APNumber, true); + LC_ResetResultsAP(Payload->APNumber, Payload->APNumber, true); CmdSuccess = true; } else @@ -565,7 +559,7 @@ CFE_Status_t LC_ResetAPStatsCmd(const LC_ResetAPStatsCmd_t *msg) CFE_EVS_SendEvent(LC_APSTATS_APNUM_ERR_EID, CFE_EVS_EventType_ERROR, "Reset AP stats error: invalid AP number = %d", - CmdPtr->APNumber); + Payload->APNumber); } if (CmdSuccess == true) @@ -575,7 +569,7 @@ CFE_Status_t LC_ResetAPStatsCmd(const LC_ResetAPStatsCmd_t *msg) CFE_EVS_SendEvent(LC_APSTATS_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset AP stats command: AP = %d", - CmdPtr->APNumber); + Payload->APNumber); } return CFE_SUCCESS; @@ -616,20 +610,22 @@ void LC_ResetResultsAP(uint32 StartIndex, uint32 EndIndex, bool ResetStatsCmd) /* Reset watchpoint statistics command */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -CFE_Status_t LC_ResetWPStatsCmd(const LC_ResetWPStatsCmd_t *msg) +CFE_Status_t LC_ResetWPStatsCmd(const LC_ResetWPStatsCmd_t *Msg) { - const LC_ResetWPStats_Payload_t *CmdPtr = &msg->Payload; - bool CmdSuccess = false; + bool CmdSuccess; + + const LC_ResetWPStats_Payload_t *Payload = &(Msg->Payload); + CmdSuccess = false; /* arg may be one or all WP's */ - if (CmdPtr->WPNumber == LC_ALL_WATCHPOINTS) + if (Payload->WPNumber == LC_ALL_WATCHPOINTS) { LC_ResetResultsWP(0, LC_MAX_WATCHPOINTS - 1, true); CmdSuccess = true; } - else if (CmdPtr->WPNumber < LC_MAX_WATCHPOINTS) + else if (Payload->WPNumber < LC_MAX_WATCHPOINTS) { - LC_ResetResultsWP(CmdPtr->WPNumber, CmdPtr->WPNumber, true); + LC_ResetResultsWP(Payload->WPNumber, Payload->WPNumber, true); CmdSuccess = true; } else @@ -640,7 +636,7 @@ CFE_Status_t LC_ResetWPStatsCmd(const LC_ResetWPStatsCmd_t *msg) CFE_EVS_SendEvent(LC_WPSTATS_WPNUM_ERR_EID, CFE_EVS_EventType_ERROR, "Reset WP stats error: invalid WP number = %d", - CmdPtr->WPNumber); + Payload->WPNumber); } if (CmdSuccess == true) @@ -650,7 +646,7 @@ CFE_Status_t LC_ResetWPStatsCmd(const LC_ResetWPStatsCmd_t *msg) CFE_EVS_SendEvent(LC_WPSTATS_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset WP stats command: WP = %d", - CmdPtr->WPNumber); + Payload->WPNumber); } return CFE_SUCCESS; diff --git a/fsw/src/lc_cmds.h b/fsw/src/lc_cmds.h index 0d6bde6..5f3a4de 100644 --- a/fsw/src/lc_cmds.h +++ b/fsw/src/lc_cmds.h @@ -34,19 +34,6 @@ * Exported Functions *************************************************************************/ -/** - * \brief Reset HK counters - * - * \par Description - * Utility function that resets housekeeping counters to zero - * - * \par Assumptions, External Events, and Notes: - * None - * - * \sa #LC_ResetCountersCmd - */ -void LC_ResetCounters(void); - /** * \brief Reset AP results * From f3860c6cd7d268421e1e1a676564f5f37b9e4fd1 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Wed, 18 Nov 2026 11:23:48 -0500 Subject: [PATCH 6/9] Issue #153, ResetCounters() isn't significant enough to warrant --- fsw/src/lc_app.c | 8 +++++++- unit-test/lc_app_tests.c | 7 ------- unit-test/lc_cmds_tests.c | 13 ++----------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index 13e99cd..4ff38da 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -1002,7 +1002,13 @@ CFE_Status_t LC_LoadDefaultTables(void) /* ** Reset application data counters reported in housekeeping */ - LC_ResetCounters(); + LC_AppData.CommandCounter = 0; + LC_AppData.CommandErrCounter = 0; + + LC_AppData.APSampleCount = 0; + LC_AppData.MonitoredMsgCount = 0; + LC_AppData.RTSExecCount = 0; + LC_AppData.PassiveRTSExecCount = 0; /* ** Set LC operational state to configured startup value diff --git a/unit-test/lc_app_tests.c b/unit-test/lc_app_tests.c index d503378..7bfa404 100644 --- a/unit-test/lc_app_tests.c +++ b/unit-test/lc_app_tests.c @@ -575,14 +575,12 @@ void LC_TableInit_Test_LoadDefaultTables(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CDS_UPDATED_INF_EID); - UtAssert_STUB_COUNT(LC_ResetCounters, 1); /* HK data is not stale */ UtAssert_STUB_COUNT(LC_ResetResultsWP, 1); /* Result Table is not stale */ UtAssert_STUB_COUNT(LC_ResetResultsAP, 1); /* AP Result Table is not stale */ UtAssert_UINT8_EQ(LC_AppData.CurrentLCState, LC_STATE_POWER_ON_RESET); /* CurrentState reset back to default */ /* Reset SendEvent and don't recover WDT */ UT_ResetState(UT_KEY(CFE_EVS_SendEvent)); - UT_ResetState(UT_KEY(LC_ResetCounters)); UT_ResetState(UT_KEY(LC_ResetResultsWP)); UT_ResetState(UT_KEY(LC_ResetResultsAP)); LC_OperData.TableResults = 0; @@ -599,14 +597,12 @@ void LC_TableInit_Test_LoadDefaultTables(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CDS_UPDATED_INF_EID); - UtAssert_STUB_COUNT(LC_ResetCounters, 1); /* HK data is not stale */ UtAssert_STUB_COUNT(LC_ResetResultsWP, 1); /* Result Table is not stale */ UtAssert_STUB_COUNT(LC_ResetResultsAP, 1); /* AP Result Table is not stale */ UtAssert_UINT8_EQ(LC_AppData.CurrentLCState, LC_STATE_POWER_ON_RESET); /* CurrentState reset back to default */ /* Reset all states and only restore WRT and ART CDS */ UT_ResetState(0); - UT_ResetState(UT_KEY(LC_ResetCounters)); UT_ResetState(UT_KEY(LC_ResetResultsWP)); UT_ResetState(UT_KEY(LC_ResetResultsAP)); LC_AppData.CurrentLCState = 0x99; @@ -626,14 +622,12 @@ void LC_TableInit_Test_LoadDefaultTables(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CDS_UPDATED_INF_EID); - UtAssert_STUB_COUNT(LC_ResetCounters, 1); /* HK data is not stale */ UtAssert_STUB_COUNT(LC_ResetResultsWP, 1); /* Result Table is not stale */ UtAssert_STUB_COUNT(LC_ResetResultsAP, 1); /* AP Result Table is not stale */ UtAssert_UINT8_EQ(LC_AppData.CurrentLCState, LC_STATE_POWER_ON_RESET); /* CurrentState reset back to default */ /* Reset all states and only restore WRT */ UT_ResetState(0); - UT_ResetState(UT_KEY(LC_ResetCounters)); UT_ResetState(UT_KEY(LC_ResetResultsWP)); UT_ResetState(UT_KEY(LC_ResetResultsAP)); LC_AppData.CurrentLCState = 0x99; @@ -652,7 +646,6 @@ void LC_TableInit_Test_LoadDefaultTables(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CDS_UPDATED_INF_EID); - UtAssert_STUB_COUNT(LC_ResetCounters, 1); /* HK data is not stale */ UtAssert_STUB_COUNT(LC_ResetResultsWP, 1); /* Result Table is not stale */ UtAssert_STUB_COUNT(LC_ResetResultsAP, 1); /* AP Result Table is not stale */ UtAssert_UINT8_EQ(LC_AppData.CurrentLCState, LC_STATE_POWER_ON_RESET); /* CurrentState reset back to default */ diff --git a/unit-test/lc_cmds_tests.c b/unit-test/lc_cmds_tests.c index 2d6ed39..b00d50b 100644 --- a/unit-test/lc_cmds_tests.c +++ b/unit-test/lc_cmds_tests.c @@ -840,13 +840,6 @@ void LC_NoopCmd_Test(void) } void LC_ResetCountersCmd_Test(void) -{ - LC_ResetCountersCmd(&UT_CmdBuf.ResetCountersCmd); - - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); -} - -void LC_ResetCounters_Test(void) { LC_AppData.CommandCounter = 1; LC_AppData.CommandErrCounter = 2; @@ -857,7 +850,7 @@ void LC_ResetCounters_Test(void) LC_AppData.PassiveRTSExecCount = 6; /* Execute the function being tested */ - LC_ResetCounters(); + LC_ResetCountersCmd(&UT_CmdBuf.ResetCountersCmd); /* Verify results */ UtAssert_True(LC_AppData.CommandCounter == 0, "LC_AppData.CommandCounter == 0"); @@ -868,7 +861,7 @@ void LC_ResetCounters_Test(void) UtAssert_True(LC_AppData.PassiveRTSExecCount == 0, "LC_AppData.PassiveRTSExecCount == 0"); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); + UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); } void LC_SetLCStateCmd_Test_Active(void) @@ -2233,8 +2226,6 @@ void UtTest_Setup(void) UtTest_Add(LC_NoopCmd_Test, LC_Test_Setup, LC_Test_TearDown, "LC_NoopCmd_Test"); UtTest_Add(LC_ResetCountersCmd_Test, LC_Test_Setup, LC_Test_TearDown, "LC_ResetCountersCmd_Test"); - UtTest_Add(LC_ResetCounters_Test, LC_Test_Setup, LC_Test_TearDown, "LC_ResetCounters_Test"); - UtTest_Add(LC_SetLCStateCmd_Test_Active, LC_Test_Setup, LC_Test_TearDown, "LC_SetLCStateCmd_Test_Active"); UtTest_Add(LC_SetLCStateCmd_Test_Passive, LC_Test_Setup, LC_Test_TearDown, "LC_SetLCStateCmd_Test_Passive"); UtTest_Add(LC_SetLCStateCmd_Test_Disabled, LC_Test_Setup, LC_Test_TearDown, "LC_SetLCStateCmd_Test_Disabled"); From b07259750348e7476eebea52334820e8d71d8614 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Wed, 18 Nov 2026 11:24:26 -0500 Subject: [PATCH 7/9] Issue #153, Standardize format of command variables --- fsw/src/lc_cmds.h | 36 ++++++++++++++++----------------- unit-test/stubs/lc_cmds_stubs.c | 36 ++++++++++++++++----------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/fsw/src/lc_cmds.h b/fsw/src/lc_cmds.h index 5f3a4de..01f4856 100644 --- a/fsw/src/lc_cmds.h +++ b/fsw/src/lc_cmds.h @@ -77,9 +77,9 @@ void LC_ResetResultsWP(uint32 StartIndex, uint32 EndIndex, bool ResetStatsCmd); * \par Assumptions, External Events, and Notes: * This message does not affect the command execution counter * - * \param[in] BufPtr Pointer to Software Bus buffer + * \param[in] Msg Pointer to command header */ -void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr); +void LC_SampleAPReq(const LC_SampleAPCmd_t *Msg); /** * \brief Housekeeping request @@ -90,10 +90,10 @@ void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr); * \par Assumptions, External Events, and Notes: * This message does not affect the command execution counter * - * \param[in] msg Pointer to command header + * \param[in] Msg Pointer to command header * */ -CFE_Status_t LC_SendHkCmd(const LC_SendHkCmd_t *msg); +CFE_Status_t LC_SendHkCmd(const LC_SendHkCmd_t *Msg); /** * \brief Noop command @@ -104,11 +104,11 @@ CFE_Status_t LC_SendHkCmd(const LC_SendHkCmd_t *msg); * \par Assumptions, External Events, and Notes: * None * - * \param[in] msg Pointer to command message + * \param[in] Msg Pointer to command message * * \sa #LC_NOOP_CC */ -CFE_Status_t LC_NoopCmd(const LC_NoopCmd_t *msg); +CFE_Status_t LC_NoopCmd(const LC_NoopCmd_t *Msg); /** * \brief Reset counters command @@ -126,11 +126,11 @@ CFE_Status_t LC_NoopCmd(const LC_NoopCmd_t *msg); * \par Assumptions, External Events, and Notes: * None * - * \param[in] msg Pointer to command message + * \param[in] Msg Pointer to command message * * \sa #LC_RESET_CC */ -CFE_Status_t LC_ResetCountersCmd(const LC_ResetCountersCmd_t *msg); +CFE_Status_t LC_ResetCountersCmd(const LC_ResetCountersCmd_t *Msg); /** * \brief Set LC state command @@ -141,11 +141,11 @@ CFE_Status_t LC_ResetCountersCmd(const LC_ResetCountersCmd_t *msg); * \par Assumptions, External Events, and Notes: * None * - * \param[in] msg Pointer to command message + * \param[in] Msg Pointer to command message * * \sa #LC_SET_LC_STATE_CC */ -CFE_Status_t LC_SetLCStateCmd(const LC_SetLCStateCmd_t *msg); +CFE_Status_t LC_SetLCStateCmd(const LC_SetLCStateCmd_t *Msg); /** * \brief Set AP state command @@ -156,11 +156,11 @@ CFE_Status_t LC_SetLCStateCmd(const LC_SetLCStateCmd_t *msg); * \par Assumptions, External Events, and Notes: * None * - * \param[in] msg Pointer to command message + * \param[in] Msg Pointer to command message * * \sa #LC_SET_AP_STATE_CC */ -CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg); +CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *Msg); /** * \brief Set AP permanently off command @@ -171,11 +171,11 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg); * \par Assumptions, External Events, and Notes: * None * - * \param[in] msg Pointer to command message + * \param[in] Msg Pointer to command message * * \sa #LC_SET_AP_PERM_OFF_CC */ -CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg); +CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *Msg); /** * \brief Reset AP statistics command @@ -186,11 +186,11 @@ CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg); * \par Assumptions, External Events, and Notes: * None * - * \param[in] msg Pointer to command message + * \param[in] Msg Pointer to command message * * \sa #LC_RESET_AP_STATS_CC */ -CFE_Status_t LC_ResetAPStatsCmd(const LC_ResetAPStatsCmd_t *msg); +CFE_Status_t LC_ResetAPStatsCmd(const LC_ResetAPStatsCmd_t *Msg); /** * \brief Reset WP statistics command @@ -201,10 +201,10 @@ CFE_Status_t LC_ResetAPStatsCmd(const LC_ResetAPStatsCmd_t *msg); * \par Assumptions, External Events, and Notes: * None * - * \param[in] msg Pointer to command message + * \param[in] Msg Pointer to command message * * \sa #LC_RESET_WP_STATS_CC */ -CFE_Status_t LC_ResetWPStatsCmd(const LC_ResetWPStatsCmd_t *msg); +CFE_Status_t LC_ResetWPStatsCmd(const LC_ResetWPStatsCmd_t *Msg); #endif diff --git a/unit-test/stubs/lc_cmds_stubs.c b/unit-test/stubs/lc_cmds_stubs.c index 5771cc4..b6047a4 100644 --- a/unit-test/stubs/lc_cmds_stubs.c +++ b/unit-test/stubs/lc_cmds_stubs.c @@ -30,11 +30,11 @@ * Generated stub function for LC_NoopCmd() * ---------------------------------------------------- */ -CFE_Status_t LC_NoopCmd(const LC_NoopCmd_t *msg) +CFE_Status_t LC_NoopCmd(const LC_NoopCmd_t *Msg) { UT_GenStub_SetupReturnBuffer(LC_NoopCmd, CFE_Status_t); - UT_GenStub_AddParam(LC_NoopCmd, const LC_NoopCmd_t *, msg); + UT_GenStub_AddParam(LC_NoopCmd, const LC_NoopCmd_t *, Msg); UT_GenStub_Execute(LC_NoopCmd, Basic, NULL); @@ -46,11 +46,11 @@ CFE_Status_t LC_NoopCmd(const LC_NoopCmd_t *msg) * Generated stub function for LC_ResetAPStatsCmd() * ---------------------------------------------------- */ -CFE_Status_t LC_ResetAPStatsCmd(const LC_ResetAPStatsCmd_t *msg) +CFE_Status_t LC_ResetAPStatsCmd(const LC_ResetAPStatsCmd_t *Msg) { UT_GenStub_SetupReturnBuffer(LC_ResetAPStatsCmd, CFE_Status_t); - UT_GenStub_AddParam(LC_ResetAPStatsCmd, const LC_ResetAPStatsCmd_t *, msg); + UT_GenStub_AddParam(LC_ResetAPStatsCmd, const LC_ResetAPStatsCmd_t *, Msg); UT_GenStub_Execute(LC_ResetAPStatsCmd, Basic, NULL); @@ -72,11 +72,11 @@ void LC_ResetCounters(void) * Generated stub function for LC_ResetCountersCmd() * ---------------------------------------------------- */ -CFE_Status_t LC_ResetCountersCmd(const LC_ResetCountersCmd_t *msg) +CFE_Status_t LC_ResetCountersCmd(const LC_ResetCountersCmd_t *Msg) { UT_GenStub_SetupReturnBuffer(LC_ResetCountersCmd, CFE_Status_t); - UT_GenStub_AddParam(LC_ResetCountersCmd, const LC_ResetCountersCmd_t *, msg); + UT_GenStub_AddParam(LC_ResetCountersCmd, const LC_ResetCountersCmd_t *, Msg); UT_GenStub_Execute(LC_ResetCountersCmd, Basic, NULL); @@ -116,11 +116,11 @@ void LC_ResetResultsWP(uint32 StartIndex, uint32 EndIndex, bool ResetStatsCmd) * Generated stub function for LC_ResetWPStatsCmd() * ---------------------------------------------------- */ -CFE_Status_t LC_ResetWPStatsCmd(const LC_ResetWPStatsCmd_t *msg) +CFE_Status_t LC_ResetWPStatsCmd(const LC_ResetWPStatsCmd_t *Msg) { UT_GenStub_SetupReturnBuffer(LC_ResetWPStatsCmd, CFE_Status_t); - UT_GenStub_AddParam(LC_ResetWPStatsCmd, const LC_ResetWPStatsCmd_t *, msg); + UT_GenStub_AddParam(LC_ResetWPStatsCmd, const LC_ResetWPStatsCmd_t *, Msg); UT_GenStub_Execute(LC_ResetWPStatsCmd, Basic, NULL); @@ -132,9 +132,9 @@ CFE_Status_t LC_ResetWPStatsCmd(const LC_ResetWPStatsCmd_t *msg) * Generated stub function for LC_SampleAPReq() * ---------------------------------------------------- */ -void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr) +void LC_SampleAPReq(const LC_SampleAPCmd_t *Msg) { - UT_GenStub_AddParam(LC_SampleAPReq, const CFE_SB_Buffer_t *, BufPtr); + UT_GenStub_AddParam(LC_SampleAPReq, const LC_SampleAPCmd_t *, Msg); UT_GenStub_Execute(LC_SampleAPReq, Basic, NULL); } @@ -144,11 +144,11 @@ void LC_SampleAPReq(const CFE_SB_Buffer_t *BufPtr) * Generated stub function for LC_SendHkCmd() * ---------------------------------------------------- */ -CFE_Status_t LC_SendHkCmd(const LC_SendHkCmd_t *msg) +CFE_Status_t LC_SendHkCmd(const LC_SendHkCmd_t *Msg) { UT_GenStub_SetupReturnBuffer(LC_SendHkCmd, CFE_Status_t); - UT_GenStub_AddParam(LC_SendHkCmd, const LC_SendHkCmd_t *, msg); + UT_GenStub_AddParam(LC_SendHkCmd, const LC_SendHkCmd_t *, Msg); UT_GenStub_Execute(LC_SendHkCmd, Basic, NULL); @@ -160,11 +160,11 @@ CFE_Status_t LC_SendHkCmd(const LC_SendHkCmd_t *msg) * Generated stub function for LC_SetAPPermOffCmd() * ---------------------------------------------------- */ -CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg) +CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *Msg) { UT_GenStub_SetupReturnBuffer(LC_SetAPPermOffCmd, CFE_Status_t); - UT_GenStub_AddParam(LC_SetAPPermOffCmd, const LC_SetAPPermOffCmd_t *, msg); + UT_GenStub_AddParam(LC_SetAPPermOffCmd, const LC_SetAPPermOffCmd_t *, Msg); UT_GenStub_Execute(LC_SetAPPermOffCmd, Basic, NULL); @@ -176,11 +176,11 @@ CFE_Status_t LC_SetAPPermOffCmd(const LC_SetAPPermOffCmd_t *msg) * Generated stub function for LC_SetAPStateCmd() * ---------------------------------------------------- */ -CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) +CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *Msg) { UT_GenStub_SetupReturnBuffer(LC_SetAPStateCmd, CFE_Status_t); - UT_GenStub_AddParam(LC_SetAPStateCmd, const LC_SetAPStateCmd_t *, msg); + UT_GenStub_AddParam(LC_SetAPStateCmd, const LC_SetAPStateCmd_t *, Msg); UT_GenStub_Execute(LC_SetAPStateCmd, Basic, NULL); @@ -192,11 +192,11 @@ CFE_Status_t LC_SetAPStateCmd(const LC_SetAPStateCmd_t *msg) * Generated stub function for LC_SetLCStateCmd() * ---------------------------------------------------- */ -CFE_Status_t LC_SetLCStateCmd(const LC_SetLCStateCmd_t *msg) +CFE_Status_t LC_SetLCStateCmd(const LC_SetLCStateCmd_t *Msg) { UT_GenStub_SetupReturnBuffer(LC_SetLCStateCmd, CFE_Status_t); - UT_GenStub_AddParam(LC_SetLCStateCmd, const LC_SetLCStateCmd_t *, msg); + UT_GenStub_AddParam(LC_SetLCStateCmd, const LC_SetLCStateCmd_t *, Msg); UT_GenStub_Execute(LC_SetLCStateCmd, Basic, NULL); From 302e016aa8ee4643b96a021768bee9b904980890 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Wed, 18 Nov 2026 11:25:00 -0500 Subject: [PATCH 8/9] Issue #153, Make sure buffer is cast to appropriate struct --- fsw/src/lc_dispatch.c | 2 +- unit-test/lc_cmds_tests.c | 40 +++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/fsw/src/lc_dispatch.c b/fsw/src/lc_dispatch.c index 1390270..240ba54 100644 --- a/fsw/src/lc_dispatch.c +++ b/fsw/src/lc_dispatch.c @@ -127,7 +127,7 @@ void LC_SampleAPVerifyDispatch(const CFE_SB_Buffer_t *BufPtr) */ if (LC_VerifyMsgLength(&BufPtr->Msg, ExpectedLength)) { - LC_SampleAPReq(BufPtr); + LC_SampleAPReq((LC_SampleAPCmd_t *)BufPtr); } } diff --git a/unit-test/lc_cmds_tests.c b/unit-test/lc_cmds_tests.c index b00d50b..0002613 100644 --- a/unit-test/lc_cmds_tests.c +++ b/unit-test/lc_cmds_tests.c @@ -50,7 +50,7 @@ void LC_SampleAPReq_Test_StateDisabled(void) { LC_AppData.CurrentLCState = LC_STATE_DISABLED; - LC_SampleAPReq(&UT_CmdBuf.Buf); + LC_SampleAPReq((LC_SampleAPCmd_t *)&UT_CmdBuf.Buf); } void LC_SampleAPReq_Test_AllowSampleAllWatchStale(void) @@ -69,7 +69,7 @@ void LC_SampleAPReq_Test_AllowSampleAllWatchStale(void) LC_OperData.WRTPtr[0].CountdownToStale = 1; /* Execute the function being tested */ - LC_SampleAPReq(&UT_CmdBuf.Buf); + LC_SampleAPReq((LC_SampleAPCmd_t *)&UT_CmdBuf.Buf); /* Verify results */ UtAssert_True(LC_OperData.WRTPtr[0].WatchResult == LC_WATCH_STALE, @@ -94,7 +94,7 @@ void LC_SampleAPReq_Test_AllowSampleAllWatchNotStale(void) LC_OperData.WRTPtr[0].CountdownToStale = 2; /* Execute the function being tested */ - LC_SampleAPReq(&UT_CmdBuf.Buf); + LC_SampleAPReq((LC_SampleAPCmd_t *)&UT_CmdBuf.Buf); /* Verify results */ call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); @@ -116,7 +116,7 @@ void LC_SampleAPReq_Test_StartLessOrEqualToEndAndEndWithinArrayWatchStale(void) LC_OperData.WRTPtr[0].CountdownToStale = 1; /* Execute the function being tested */ - LC_SampleAPReq(&UT_CmdBuf.Buf); + LC_SampleAPReq((LC_SampleAPCmd_t *)&UT_CmdBuf.Buf); /* Verify results */ UtAssert_True(LC_OperData.WRTPtr[0].WatchResult == LC_WATCH_STALE, @@ -145,7 +145,7 @@ void LC_SampleAPReq_Test_ArrayIndexOutOfRange(void) "Sample AP error: invalid AP number, start = %%d, end = %%d"); /* Execute the function being tested */ - LC_SampleAPReq(&UT_CmdBuf.Buf); + LC_SampleAPReq((LC_SampleAPCmd_t *)&UT_CmdBuf.Buf); /* Verify results */ call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); @@ -179,7 +179,7 @@ void LC_SampleAPReq_Test_BadSampleAllArgs(void) LC_OperData.WRTPtr[0].CountdownToStale = 1; /* Execute the function being tested */ - LC_SampleAPReq(&UT_CmdBuf.Buf); + LC_SampleAPReq((LC_SampleAPCmd_t *)&UT_CmdBuf.Buf); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -212,7 +212,7 @@ void LC_SampleAPReq_Test_ArrayEndIndexTooHigh(void) LC_OperData.WRTPtr[0].CountdownToStale = 1; /* Execute the function being tested */ - LC_SampleAPReq(&UT_CmdBuf.Buf); + LC_SampleAPReq((LC_SampleAPCmd_t *)&UT_CmdBuf.Buf); call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 1); @@ -239,7 +239,7 @@ void LC_SampleAPReq_Test_SampleAllUpdateAgeZero(void) LC_OperData.WRTPtr[0].CountdownToStale = 1; /* Execute the function being tested */ - LC_SampleAPReq(&UT_CmdBuf.Buf); + LC_SampleAPReq((LC_SampleAPCmd_t *)&UT_CmdBuf.Buf); /* Verify results */ @@ -268,7 +268,7 @@ void LC_SendHkCmd_Test_WatchStale(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd); + Result = LC_SendHkCmd((LC_SendHkCmd_t *)&UT_CmdBuf.SendHkCmd); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -318,7 +318,7 @@ void LC_SendHkCmd_Test_WatchFalse(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd); + Result = LC_SendHkCmd((LC_SendHkCmd_t *)&UT_CmdBuf.SendHkCmd); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -368,7 +368,7 @@ void LC_SendHkCmd_Test_WatchTrue(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd); + Result = LC_SendHkCmd((LC_SendHkCmd_t *)&UT_CmdBuf.SendHkCmd); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -419,7 +419,7 @@ void LC_SendHkCmd_Test_WatchError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd); + Result = LC_SendHkCmd((LC_SendHkCmd_t *)&UT_CmdBuf.SendHkCmd); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -469,7 +469,7 @@ void LC_SendHkCmd_Test_DefaultWatchResult(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd); + Result = LC_SendHkCmd((LC_SendHkCmd_t *)&UT_CmdBuf.SendHkCmd); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -520,7 +520,7 @@ void LC_SendHkCmd_Test_ActionNotUsedStale(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd); + Result = LC_SendHkCmd((LC_SendHkCmd_t *)&UT_CmdBuf.SendHkCmd); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -571,7 +571,7 @@ void LC_SendHkCmd_Test_APStateActiveActionPass(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd); + Result = LC_SendHkCmd((LC_SendHkCmd_t *)&UT_CmdBuf.SendHkCmd); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -624,7 +624,7 @@ void LC_SendHkCmd_Test_APStatePassiveActionFail(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd); + Result = LC_SendHkCmd((LC_SendHkCmd_t *)&UT_CmdBuf.SendHkCmd); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -675,7 +675,7 @@ void LC_SendHkCmd_Test_APStateDisabledActionError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd); + Result = LC_SendHkCmd((LC_SendHkCmd_t *)&UT_CmdBuf.SendHkCmd); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -726,7 +726,7 @@ void LC_SendHkCmd_Test_APStatePermOffActionError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd); + Result = LC_SendHkCmd((LC_SendHkCmd_t *)&UT_CmdBuf.SendHkCmd); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -777,7 +777,7 @@ void LC_SendHkCmd_Test_DefaultCurrentStateAndActionResult(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); /* Execute the function being tested */ - Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd); + Result = LC_SendHkCmd((LC_SendHkCmd_t *)&UT_CmdBuf.SendHkCmd); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -820,7 +820,7 @@ void LC_SendHkCmd_Test_ManageTablesError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), -1); /* Execute the function being tested */ - Result = LC_SendHkCmd(&UT_CmdBuf.SendHkCmd); + Result = LC_SendHkCmd((LC_SendHkCmd_t *)&UT_CmdBuf.SendHkCmd); /* Verify results */ UtAssert_True(Result == -1, "Result == -1"); From 16430600b5d72c79dc9dcd99927301322da70ba6 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Wed, 18 Nov 2026 11:25:26 -0500 Subject: [PATCH 9/9] Issue #153, Padding packets have a standardized name --- config/default_lc_msgdefs.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/config/default_lc_msgdefs.h b/config/default_lc_msgdefs.h index 8dc95fb..f65e65b 100644 --- a/config/default_lc_msgdefs.h +++ b/config/default_lc_msgdefs.h @@ -130,8 +130,8 @@ */ typedef struct { - uint16 APNumber; /**< \brief Which actionpoint(s) to change */ - uint16 Padding; /**< \brief Structure padding */ + uint16 APNumber; /**< \brief Which actionpoint(s) to change */ + uint8 Padding[2]; /**< \brief Structure padding */ } LC_APNumber_Payload_t; /** @@ -153,7 +153,7 @@ typedef struct typedef struct { uint16 NewLCState; /**< \brief New LC application state */ - uint16 Padding; /**< \brief Structure padding */ + uint8 Padding[2]; /**< \brief Structure padding */ } LC_SetLCState_Payload_t; /** @@ -166,8 +166,8 @@ typedef struct 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 */ + uint16 UpdateAge; /**< \brief Update WP results age (T or F) */ + uint8 Padding[2]; /**< \brief Structure padding */ } LC_SampleAP_Payload_t; /** @@ -177,8 +177,8 @@ typedef struct */ typedef struct { - uint16 WPNumber; /**< \brief Which watchpoint(s) to change */ - uint16 Padding; /**< \brief Structure padding */ + uint16 WPNumber; /**< \brief Which watchpoint(s) to change */ + uint8 Padding[2]; /**< \brief Structure padding */ } LC_ResetWPStats_Payload_t; /** @@ -186,8 +186,8 @@ typedef struct */ typedef struct { - uint16 RTSId; /**< \brief RTS Id to start */ - uint16 Padding; /**< \brief Padding */ + uint16 RTSId; /**< \brief RTS Id to start */ + uint8 Padding[2]; /**< \brief Padding */ } LC_RTSRequest_Payload_t; /** @@ -204,7 +204,7 @@ typedef struct uint8 CommandErrCounter; /**< \brief LC Application Command Error Counter */ uint8 CurrentLCState; /**< \brief Current LC application operating state */ - uint8 Pad8; /**< \brief Structure padding */ + uint8 Padding1; /**< \brief Structure padding */ uint8 WPResults[LC_HKWR_NUM_BYTES]; /**< \brief Packed watchpoint results data, 2 bits per watchpoint */ uint8 APResults[LC_HKAR_NUM_BYTES]; /**< \brief Packed actionpoint results data, 4 bits per actionpoint */ @@ -217,7 +217,7 @@ typedef struct uint16 WPsInUse; /**< \brief How many watchpoints are currently in effect */ uint16 ActiveAPs; /**< \brief How many actionpoints are currently active */ - uint16 Pad16; /**< \brief Structure padding */ + uint8 Padding2[2]; /**< \brief Structure padding */ uint32 APSampleCount; /**< \brief Total count of Actionpoints sampled */ uint32 MonitoredMsgCount; /**< \brief Total count of messages monitored for watchpoints */