Skip to content

Commit

Permalink
Fix nasa#60, Apply consistent Event ID names to common events in SC
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Apr 1, 2023
1 parent 487169b commit 8786971
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 24 deletions.
8 changes: 4 additions & 4 deletions fsw/inc/sc_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* This event message is issued when a command is received, but it is not of the expected
* length
*/
#define SC_LEN_ERR_EID 2
#define SC_CMD_LEN_ERR_EID 2

/**
* \brief SC Create Pipe Failed Event ID
Expand All @@ -61,7 +61,7 @@
* This event message is issued when #CFE_SB_CreatePipe returns an
* error
*/
#define SC_INIT_SB_CREATE_ERR_EID 3
#define SC_CR_PIPE_ERR_EID 3

/**
* \brief SC Housekeeping Request Subscribe Failed Event ID
Expand Down Expand Up @@ -508,7 +508,7 @@
* \par Cause:
* This event message is issued when the #SC_RESET_COUNTERS_CC command was received
*/
#define SC_RESET_DEB_EID 51
#define SC_RESET_INF_EID 51

/**
* \brief SC No-op Command Event ID
Expand Down Expand Up @@ -585,7 +585,7 @@
* This event message is issued when an invalid command code was received in
* the command pipe
*/
#define SC_INVLD_CMD_ERR_EID 64
#define SC_CC_ERR_EID 64

/**
* \brief SC RTS Info Table Get Address Failed Event ID
Expand Down
12 changes: 6 additions & 6 deletions fsw/inc/sc_msgdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #SC_HkTlm_t.CmdErrCtr will increment
* - Error specific event message #SC_LEN_ERR_EID
* - Error specific event message #SC_CMD_LEN_ERR_EID
*
* \par Criticality
* None
Expand Down Expand Up @@ -147,7 +147,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #SC_HkTlm_t.CmdErrCtr will increment
* - Error specific event message #SC_LEN_ERR_EID
* - Error specific event message #SC_CMD_LEN_ERR_EID
*
* \par Criticality
* None
Expand Down Expand Up @@ -537,7 +537,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #SC_HkTlm_t.CmdErrCtr will increment
* - The #SC_LEN_ERR_EID event will indicate invalid command packet length.
* - The #SC_CMD_LEN_ERR_EID event will indicate invalid command packet length.
* - The #SC_STARTRTSGRP_CMD_ERR_EID event will indicate invalid group definition.
*
* \par Criticality
Expand Down Expand Up @@ -577,7 +577,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #SC_HkTlm_t.CmdErrCtr will increment
* - The #SC_LEN_ERR_EID event will indicate invalid command packet length.
* - The #SC_CMD_LEN_ERR_EID event will indicate invalid command packet length.
* - The #SC_STOPRTSGRP_CMD_ERR_EID event will indicate invalid group definition.
*
* \par Criticality
Expand Down Expand Up @@ -615,7 +615,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #SC_HkTlm_t.CmdErrCtr will increment
* - The #SC_LEN_ERR_EID event will indicate invalid command packet length.
* - The #SC_CMD_LEN_ERR_EID event will indicate invalid command packet length.
* - The #SC_DISRTSGRP_CMD_ERR_EID event will indicate invalid group definition.
*
* \par Criticality
Expand Down Expand Up @@ -653,7 +653,7 @@
*
* \par Evidence of failure may be found in the following telemetry:
* - #SC_HkTlm_t.CmdErrCtr will increment
* - The #SC_LEN_ERR_EID event will indicate invalid command packet length.
* - The #SC_CMD_LEN_ERR_EID event will indicate invalid command packet length.
* - The #SC_ENARTSGRP_CMD_ERR_EID event will indicate invalid group definition.
*
* \par Criticality
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/sc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ int32 SC_AppInit(void)
Result = CFE_SB_CreatePipe(&SC_OperData.CmdPipe, SC_PIPE_DEPTH, SC_CMD_PIPE_NAME);
if (Result != CFE_SUCCESS)
{
CFE_EVS_SendEvent(SC_INIT_SB_CREATE_ERR_EID, CFE_EVS_EventType_ERROR,
"Software Bus Create Pipe returned: 0x%08X", (unsigned int)Result);
CFE_EVS_SendEvent(SC_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, "Software Bus Create Pipe returned: 0x%08X",
(unsigned int)Result);
return (Result);
}

Expand Down
5 changes: 2 additions & 3 deletions fsw/src/sc_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ void SC_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr)
{
if (SC_VerifyCmdLength(&BufPtr->Msg, sizeof(SC_NoArgsCmd_t)))
{
CFE_EVS_SendEvent(SC_RESET_DEB_EID, CFE_EVS_EventType_DEBUG, "Reset counters command");
CFE_EVS_SendEvent(SC_RESET_INF_EID, CFE_EVS_EventType_DEBUG, "Reset counters command");

SC_OperData.HkPacket.CmdCtr = 0;
SC_OperData.HkPacket.CmdErrCtr = 0;
Expand Down Expand Up @@ -699,8 +699,7 @@ void SC_ProcessCommand(const CFE_SB_Buffer_t *BufPtr)
#endif

default:
CFE_EVS_SendEvent(SC_INVLD_CMD_ERR_EID, CFE_EVS_EventType_ERROR,
"Invalid Command Code: MID = 0x%08lX CC = %d",
CFE_EVS_SendEvent(SC_CC_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid Command Code: MID = 0x%08lX CC = %d",
(unsigned long)CFE_SB_MsgIdToValue(MessageID), CommandCode);
SC_OperData.HkPacket.CmdErrCtr++;
break;
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/sc_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool SC_VerifyCmdLength(const CFE_MSG_Message_t *Msg, size_t ExpectedLength)
CFE_MSG_GetMsgId(Msg, &MessageID);
CFE_MSG_GetFcnCode(Msg, &CommandCode);

CFE_EVS_SendEvent(SC_LEN_ERR_EID, CFE_EVS_EventType_ERROR,
CFE_EVS_SendEvent(SC_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
4 changes: 2 additions & 2 deletions fsw/src/sc_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ bool SC_CompareAbsTime(SC_AbsTimeTag_t AbsTime1, SC_AbsTimeTag_t AbsTime2);
* \retval true Length matches expected
* \retval false Length does not match expected
*
* \sa #SC_LEN_ERR_EID
* \sa #SC_CMD_LEN_ERR_EID
*/
bool SC_VerifyCmdLength(const CFE_MSG_Message_t *Msg, size_t ExpectedLength);

Expand All @@ -128,7 +128,7 @@ bool SC_VerifyCmdLength(const CFE_MSG_Message_t *Msg, size_t ExpectedLength);
* \retval 0 When current ATS index is 1
* \retval 1 When current ATS index is 0
*
* \sa #SC_LEN_ERR_EID
* \sa #SC_CMD_LEN_ERR_EID
*/
uint16 SC_ToggleAtsIndex(void);

Expand Down
4 changes: 2 additions & 2 deletions unit-test/sc_app_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ void SC_AppInit_Test_SBCreatePipeError(void)

snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Software Bus Create Pipe returned: 0x%%08X");

/* Set CFE_SB_CreatePipe to return -1 in order to generate error message SC_INIT_SB_CREATE_ERR_EID */
/* Set CFE_SB_CreatePipe to return -1 in order to generate error message SC_CR_PIPE_ERR_EID */
UT_SetDeferredRetcode(UT_KEY(CFE_SB_CreatePipe), 1, -1);

/* Execute the function being tested */
Expand All @@ -438,7 +438,7 @@ void SC_AppInit_Test_SBCreatePipeError(void)
/* Verify results */
UtAssert_True(ReturnValue == -1, "ReturnValue == -1");

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_INIT_SB_CREATE_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_CR_PIPE_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR);

strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);
Expand Down
4 changes: 2 additions & 2 deletions unit-test/sc_cmds_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@ void SC_ProcessCommand_Test_ResetCounters(void)
UtAssert_True(SC_OperData.HkPacket.RtsActiveCtr == 0, "RtsActiveCtr == 0");
UtAssert_True(SC_OperData.HkPacket.RtsActiveErrCtr == 0, "RtsActiveErrCtr == 0");

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_RESET_DEB_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_RESET_INF_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_DEBUG);

strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);
Expand Down Expand Up @@ -3210,7 +3210,7 @@ void SC_ProcessCommand_Test_InvalidCmdError(void)
UtAssert_True(SC_OperData.HkPacket.CmdCtr == 0, "CmdCtr == 0");
UtAssert_True(SC_OperData.HkPacket.CmdErrCtr == 1, "CmdErrCtr == 1");

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_INVLD_CMD_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_CC_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR);

strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);
Expand Down
4 changes: 2 additions & 2 deletions unit-test/sc_utils_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void SC_VerifyCmdLength_Test_LenError(void)
UtAssert_True(SC_OperData.HkPacket.CmdCtr == 0, "SC_OperData.HkPacket.CmdCtr == 0");
UtAssert_True(SC_OperData.HkPacket.CmdErrCtr == 1, "SC_OperData.HkPacket.CmdErrCtr == 1");

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_CMD_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR);

strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);
Expand Down Expand Up @@ -197,7 +197,7 @@ void SC_VerifyCmdLength_Test_LenErrorNotMID(void)
UtAssert_True(Result == false, "Result == false");
UtAssert_True(SC_OperData.HkPacket.CmdCtr == 0, "SC_OperData.HkPacket.CmdCtr == 0");

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_CMD_LEN_ERR_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR);

strCmpResult = strncmp(ExpectedEventString, context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);
Expand Down

0 comments on commit 8786971

Please sign in to comment.