Skip to content

Commit

Permalink
Merge remote-tracking branch 'github-nasa/main' into jph-eds-prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
jphickey committed Aug 7, 2024
2 parents fa5b83f + 776ef63 commit 5464f95
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
16 changes: 8 additions & 8 deletions config/default_lc_fcncodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #LC_HkTlm_Payload_t.CmdErrCount will increment
* - Error specific event message #LC_LEN_ERR_EID
* - Error specific event message #LC_CMD_LEN_ERR_EID
*
* \par Criticality
* None
Expand All @@ -79,7 +79,7 @@
* Successful execution of this command may be verified with
* the following telemetry:
* - #LC_HkTlm_Payload_t.CmdCount will be cleared
* - The #LC_RESET_DBG_EID debug event message will be
* - The #LC_RESET_INF_EID debug event message will be
* generated when the command is executed
*
* \par Error Conditions
Expand All @@ -88,7 +88,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #LC_HkTlm_Payload_t.CmdErrCount will increment
* - Error specific event message #LC_LEN_ERR_EID
* - Error specific event message #LC_CMD_LEN_ERR_EID
*
* \par Criticality
* None
Expand Down Expand Up @@ -121,7 +121,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #LC_HkTlm_Payload_t.CmdErrCount will increment
* - Error specific event message #LC_LEN_ERR_EID
* - Error specific event message #LC_CMD_LEN_ERR_EID
* - Error specific event message #LC_LCSTATE_ERR_EID
*
* \par Criticality
Expand Down Expand Up @@ -157,7 +157,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #LC_HkTlm_Payload_t.CmdErrCount will increment
* - Error specific event message #LC_LEN_ERR_EID
* - 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
* - Error specific event message #LC_APSTATE_CURR_ERR_EID
Expand Down Expand Up @@ -193,7 +193,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #LC_HkTlm_Payload_t.CmdErrCount will increment
* - Error specific event message #LC_LEN_ERR_EID
* - 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
*
Expand Down Expand Up @@ -227,7 +227,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #LC_HkTlm_Payload_t.CmdErrCount will increment
* - Error specific event message #LC_LEN_ERR_EID
* - Error specific event message #LC_CMD_LEN_ERR_EID
* - Error specific event message #LC_APSTATS_APNUM_ERR_EID
*
* \par Criticality
Expand Down Expand Up @@ -261,7 +261,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #LC_HkTlm_Payload_t.CmdErrCount will increment
* - Error specific event message #LC_LEN_ERR_EID
* - Error specific event message #LC_CMD_LEN_ERR_EID
* - Error specific event message #LC_WPSTATS_WPNUM_ERR_EID
*
* \par Criticality
Expand Down
6 changes: 3 additions & 3 deletions fsw/inc/lc_eventids.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,14 @@
/**
* \brief LC Reset Counters Command Event ID
*
* \par Type: DEBUG
* \par Type: INFORMATION
*
* \par Cause:
*
* This event message is issued when a reset counters command has
* been received.
*/
#define LC_RESET_DBG_EID 27
#define LC_RESET_INF_EID 27

/**
* \brief LC Set Limit Checker State Command Event ID
Expand Down Expand Up @@ -596,7 +596,7 @@
* This event message is issued when a ground command message is received
* with a message length that doesn't match the expected value.
*/
#define LC_LEN_ERR_EID 43
#define LC_CMD_LEN_ERR_EID 43

/**
* \brief LC Watchpoint Message Unsubscribe Failed Event ID
Expand Down
4 changes: 3 additions & 1 deletion fsw/src/lc_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ CFE_Status_t LC_SendHkCmd(const CFE_MSG_CommandHeader_t *MsgPtr)
}

/* Update houskeeping watch results array */
/* SAD: HKIndex is derived from TableIndex, ensuring it stays within the bounds of the WPResults array */
PayloadPtr->WPResults[HKIndex] = ByteData;
}

Expand Down Expand Up @@ -248,6 +249,7 @@ CFE_Status_t LC_SendHkCmd(const CFE_MSG_CommandHeader_t *MsgPtr)
}

/* Update houskeeping action results array */
/* SAD: HKIndex is derived from TableIndex, ensuring it stays within the bounds of the APResults array */
PayloadPtr->APResults[HKIndex] = ByteData;
}

Expand Down Expand Up @@ -280,7 +282,7 @@ void LC_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr)
{
LC_ResetCounters();

CFE_EVS_SendEvent(LC_RESET_DBG_EID, CFE_EVS_EventType_DEBUG, "Reset counters command");
CFE_EVS_SendEvent(LC_RESET_INF_EID, CFE_EVS_EventType_DEBUG, "Reset counters command");
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/lc_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool LC_VerifyMsgLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength)
/*
** All other cases, increment error counter
*/
CFE_EVS_SendEvent(LC_LEN_ERR_EID, CFE_EVS_EventType_ERROR,
CFE_EVS_SendEvent(LC_CMD_LEN_ERR_EID, CFE_EVS_EventType_ERROR,
"Invalid msg length: ID = 0x%08lX, CC = %d, Len = %d, Expected = %d",
(unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode, (int)ActualLength,
(int)ExpectedLength);
Expand Down
10 changes: 10 additions & 0 deletions fsw/src/lc_watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ uint8 LC_OperatorCompare(uint16 WatchIndex, uint32 ProcessedWPData)
WatchpointValue.Unsigned32 = ProcessedWPData;
break;
}
/* SAD: Using memcpy to safely copy the float value from LC_MultiType_t to ComparisonValue, preserving bitwise
* representation */
memcpy(&ComparisonValue, &LC_OperData.WDTPtr[WatchIndex].ComparisonValue, sizeof(LC_MultiType_t));

/*
Expand Down Expand Up @@ -681,7 +683,11 @@ uint8 LC_FloatCompare(uint16 WatchIndex, LC_MultiType_t *WPMultiType, LC_MultiTy

OperatorID = LC_OperData.WDTPtr[WatchIndex].OperatorID;

/* SAD: Using memcpy to safely copy the float value from LC_MultiType_t to WPFloat, preserving bitwise
* representation */
memcpy(&WPFloat, WPMultiType, sizeof(float));
/* SAD: Using memcpy to safely copy the float value from LC_MultiType_t to CompareFloat, preserving bitwise
* representation */
memcpy(&CompareFloat, CompareMultiType, sizeof(float));

/*
Expand Down Expand Up @@ -1021,6 +1027,8 @@ int32 LC_ValidateWDT(void *TableData)
}
else if ((DataType == LC_DATA_WATCH_FLOAT_BE) || (DataType == LC_DATA_WATCH_FLOAT_LE))
{
/* SAD: Using memcpy to safely copy the float value from LC_MultiType_t to FloatValue, preserving bitwise
* representation */
memcpy(&FloatValue, &TableArray[TableIndex].ComparisonValue, sizeof(FloatValue));

/*
Expand Down Expand Up @@ -1060,6 +1068,8 @@ int32 LC_ValidateWDT(void *TableData)
{
if ((EntryResult == LC_WDTVAL_ERR_FPNAN) || (EntryResult == LC_WDTVAL_ERR_FPINF))
{
/* SAD: Using memcpy to safely copy the uint32 value from LC_MultiType_t to PrintableBits, preserving
* bitwise representation */
memcpy(&PrintableBits, &TableArray[TableIndex].ComparisonValue, sizeof(PrintableBits));
CFE_EVS_SendEvent(LC_WDTVAL_FPERR_EID, CFE_EVS_EventType_ERROR,
"WDT verify float err: WP = %d, Err = %d, ComparisonValue = 0x%08X", (int)TableIndex,
Expand Down
14 changes: 7 additions & 7 deletions unit-test/lc_dispatch_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void LC_AppPipe_Test_Noop(void)
/* Verify handler NOT called again */
UtAssert_STUB_COUNT(LC_NoopCmd, 1);
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CMD_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR);
}

Expand All @@ -157,7 +157,7 @@ void LC_AppPipe_Test_Reset(void)
/* Verify handler NOT called again */
UtAssert_STUB_COUNT(LC_ResetCountersCmd, 1);
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CMD_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR);
}

Expand All @@ -181,7 +181,7 @@ void LC_AppPipe_Test_SetLCState(void)
/* Verify handler NOT called again */
UtAssert_STUB_COUNT(LC_SetLCStateCmd, 1);
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CMD_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR);
}

Expand All @@ -207,7 +207,7 @@ void LC_AppPipe_Test_SetAPState(void)
/* Verify handler NOT called again */
UtAssert_STUB_COUNT(LC_SetAPStateCmd, 1);
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CMD_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR);
}

Expand All @@ -231,7 +231,7 @@ void LC_AppPipe_Test_SetAPPermOff(void)
/* Verify handler NOT called again */
UtAssert_STUB_COUNT(LC_SetAPPermOffCmd, 1);
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CMD_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR);
}

Expand All @@ -255,7 +255,7 @@ void LC_AppPipe_Test_ResetAPStats(void)
/* Verify handler NOT called again */
UtAssert_STUB_COUNT(LC_ResetAPStatsCmd, 1);
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CMD_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR);
}

Expand All @@ -279,7 +279,7 @@ void LC_AppPipe_Test_ResetWPStats(void)
/* Verify handler NOT called again */
UtAssert_STUB_COUNT(LC_ResetWPStatsCmd, 1);
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, LC_CMD_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR);
}

Expand Down

0 comments on commit 5464f95

Please sign in to comment.