Skip to content

Commit

Permalink
Standardize command responses
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Jun 6, 2024
1 parent 1805d10 commit d4c5154
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 27 deletions.
7 changes: 4 additions & 3 deletions config/default_sc_fcncodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
* Successful execution of this command may be verified with
* the following telemetry:
* - #SC_HkTlm_Payload_t.CmdCtr will increment
* - The #SC_DISABLE_RTS_DEB_EID will be sent
* - The #SC_DISABLE_RTS_INF_EID will be sent
*
* \par Error Conditions
* This command may fail for the following reason(s):
Expand Down Expand Up @@ -269,7 +269,7 @@
* Successful execution of this command may be verified with
* the following telemetry:
* - #SC_HkTlm_Payload_t.CmdCtr will increment
* - The #SC_ENABLE_RTS_DEB_EID will be sent
* - The #SC_ENABLE_RTS_INF_EID will be sent
*
* \par Error Conditions
* This command may fail for the following reason(s):
Expand Down Expand Up @@ -362,7 +362,7 @@
* Successful execution of this command may be verified with
* the following telemetry:
* - #SC_HkTlm_Payload_t.CmdCtr will increment
* - The #SC_CONT_CMD_DEB_EID will be sent
* - The #SC_CONT_CMD_INF_EID will be sent
*
* \par Error Conditions
* This command may fail for the following reason(s):
Expand Down Expand Up @@ -430,6 +430,7 @@
* \par Command Verification
* Successful execution of this command may be verified via:
* - cFE Table Services housekeeping telemetry
* - The #SC_MANAGE_TABLE_INF_EID will be sent
*
* \par Error Conditions
* This command may fail for the following reason(s):
Expand Down
35 changes: 24 additions & 11 deletions fsw/inc/sc_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,13 @@
/**
* \brief SC Continue ATS On Failure Command Event ID
*
* \par Type: DEBUG
* \par Type: INFORMATIONAL
*
* \par Cause:
* This event message is issued when the #SC_CONTINUE_ATS_ON_FAILURE_CC command was received and
* the state was changed successfully
*/
#define SC_CONT_CMD_DEB_EID 43
#define SC_CONT_CMD_INF_EID 43

/**
* \brief SC ATS Command Skipped Checksum Failed Event ID
Expand Down Expand Up @@ -503,12 +503,13 @@
/**
* \brief SC Reset Counters Command Event ID
*
* \par Type: DEBUG
* \par Type: INFORMATIONAL
*
* \par Cause:
* This event message is issued when the #SC_RESET_COUNTERS_CC command was received
* 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 @@ -751,12 +752,13 @@
/**
* \brief SC Disable RTS Command Event ID
*
* \par Type: DEBUG
* \par Type: INFORMATIONAL
*
* \par Cause:
* This event message is issued when a #SC_DISABLE_RTS_CC command was received, and executed successfully
* This event message is issued when a #SC_DISABLE_RTS_CC command was received,
* and executed successfully
*/
#define SC_DISABLE_RTS_DEB_EID 80
#define SC_DISABLE_RTS_INF_EID 80

/**
* \brief SC Disable RTS Rejected RTS ID Invalid Event ID
Expand All @@ -772,12 +774,13 @@
/**
* \brief SC Enable RTS Command ID Event ID
*
* \par Type: DEBUG
* \par Type: INFORMATIONAL
*
* \par Cause:
* This event message is issued when a #SC_ENABLE_RTS_CC command was received, and executed successfully
* This event message is issued when a #SC_ENABLE_RTS_CC command was received,
* and executed successfully
*/
#define SC_ENABLE_RTS_DEB_EID 82
#define SC_ENABLE_RTS_INF_EID 82

/**
* \brief SC Enable RTS Rejected RTS ID Invalid Event ID
Expand Down Expand Up @@ -1351,6 +1354,16 @@
*/
#define SC_AUTOSTART_RTS_INV_ID_ERR_EID 138

/**
* \brief SC Table Manage Request Table ID Invalid Event ID
*
* \par Type: INFORMATION
*
* \par Cause:
* This event message is issued when a #SC_MANAGE_TABLE_CC command was received and executed successfully
*/
#define SC_MANAGE_TABLE_INF_EID 111
/**\}*/

#endif
3 changes: 2 additions & 1 deletion fsw/src/sc_atsrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,8 @@ void SC_ContinueAtsOnFailureCmd(const SC_ContinueAtsOnFailureCmd_t *Cmd)

SC_OperData.HkPacket.Payload.CmdCtr++;

CFE_EVS_SendEvent(SC_CONT_CMD_DEB_EID, CFE_EVS_EventType_DEBUG, "Continue-ATS-On-Failure command, State: %lu",
CFE_EVS_SendEvent(SC_CONT_CMD_INF_EID, CFE_EVS_EventType_INFORMATION,
"Continue-ATS-On-Failure command, State: %lu",
(unsigned long)State);
}
}
Expand Down
20 changes: 16 additions & 4 deletions fsw/src/sc_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ void SC_SendHkCmd(const SC_SendHkCmd_t *Cmd)

void SC_ResetCountersCmd(const SC_ResetCountersCmd_t *Cmd)
{
CFE_EVS_SendEvent(SC_RESET_DEB_EID, CFE_EVS_EventType_DEBUG, "Reset counters command");
CFE_EVS_SendEvent(SC_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "Reset counters command");

SC_OperData.HkPacket.Payload.CmdCtr = 0;
SC_OperData.HkPacket.Payload.CmdErrCtr = 0;
Expand Down Expand Up @@ -608,6 +608,7 @@ void SC_ManageTableCmd(const SC_ManageTableCmd_t *Cmd)
{
int32 ArrayIndex;
int32 TableID = Cmd->Payload.Parameter;
CFE_Status_t Status = CFE_SUCCESS;

/* Manage selected table as appropriate for each table type */
if ((TableID >= SC_TBL_ID_ATS_0) && (TableID < (SC_TBL_ID_ATS_0 + SC_NUMBER_OF_ATS)))
Expand Down Expand Up @@ -652,9 +653,20 @@ void SC_ManageTableCmd(const SC_ManageTableCmd_t *Cmd)
}
else
{
/* Invalid table ID */
CFE_EVS_SendEvent(SC_TABLE_MANAGE_ID_ERR_EID, CFE_EVS_EventType_ERROR,
"Table manage command packet error: table ID = %d", (int)TableID);
/* Invalid table ID */
Status = SC_ERROR;
}

if (Status == CFE_SUCCESS)
{
CFE_EVS_SendEvent(SC_MANAGE_TABLE_INF_EID, CFE_EVS_EventType_INFORMATION,
"Table manage command.");
}
else
{
CFE_EVS_SendEvent(SC_TABLE_MANAGE_ID_ERR_EID, CFE_EVS_EventType_ERROR,
"Table manage command packet error: table ID = %d",
(int)TableID);
}
}

Expand Down
7 changes: 4 additions & 3 deletions fsw/src/sc_rtsrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ void SC_DisableRtsCmd(const SC_DisableRtsCmd_t *Cmd)
/* update the command status */
SC_OperData.HkPacket.Payload.CmdCtr++;

CFE_EVS_SendEvent(SC_DISABLE_RTS_DEB_EID, CFE_EVS_EventType_DEBUG, "Disabled RTS %03u",
SC_IDNUM_AS_UINT(RtsNum));
CFE_EVS_SendEvent(SC_DISABLE_RTS_INF_EID, CFE_EVS_EventType_INFORMATION,
"Disabled RTS %03u", SC_IDNUM_AS_UINT(RtsNum));
}
else
{ /* it is not a valid RTS id */
Expand Down Expand Up @@ -458,7 +458,8 @@ void SC_EnableRtsCmd(const SC_EnableRtsCmd_t *Cmd)
/* update the command status */
SC_OperData.HkPacket.Payload.CmdCtr++;

CFE_EVS_SendEvent(SC_ENABLE_RTS_DEB_EID, CFE_EVS_EventType_DEBUG, "Enabled RTS %03u", SC_IDNUM_AS_UINT(RtsNum));
CFE_EVS_SendEvent(SC_ENABLE_RTS_INF_EID, CFE_EVS_EventType_INFORMATION,
"Enabled RTS %03u", SC_IDNUM_AS_UINT(RtsNum));
}
else
{ /* it is not a valid RTS id */
Expand Down
6 changes: 4 additions & 2 deletions unit-test/sc_atsrq_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,8 @@ void ContinueAtsOnFailureCmd_Test_Nominal(void)
UtAssert_BOOL_TRUE(SC_OperData.HkPacket.Payload.ContinueAtsOnFailureFlag);
UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 1, "SC_OperData.HkPacket.Payload.CmdCtr == 1");

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_CONT_CMD_DEB_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID,
SC_CONT_CMD_INF_EID);
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
}

Expand All @@ -974,7 +975,8 @@ void ContinueAtsOnFailureCmd_Test_FalseState(void)
"SC_OperData.HkPacket.Payload.ContinueAtsOnFailureFlag == false");
UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 1, "SC_OperData.HkPacket.Payload.CmdCtr == 1");

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_CONT_CMD_DEB_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID,
SC_CONT_CMD_INF_EID);
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
}

Expand Down
2 changes: 1 addition & 1 deletion unit-test/sc_cmds_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ void SC_ProcessCommand_Test_ResetCounters(void)
UtAssert_True(SC_OperData.HkPacket.Payload.RtsActiveCtr == 0, "RtsActiveCtr == 0");
UtAssert_True(SC_OperData.HkPacket.Payload.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_STUB_COUNT(CFE_EVS_SendEvent, 1);
}

Expand Down
6 changes: 4 additions & 2 deletions unit-test/sc_rtsrq_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ void SC_DisableRtsCmd_Test_Nominal(void)
UtAssert_True(RtsInfoPtr->DisabledFlag == true, "RtsInfoPtr->DisabledFlag == true");
UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 1, "SC_OperData.HkPacket.Payload.CmdCtr == 1");

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_DISABLE_RTS_DEB_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID,
SC_DISABLE_RTS_INF_EID);
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
}

Expand Down Expand Up @@ -802,7 +803,8 @@ void SC_EnableRtsCmd_Test_Nominal(void)
UtAssert_True(RtsInfoPtr->DisabledFlag == false, "RtsInfoPtr->DisabledFlag == false");
UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 1, "SC_OperData.HkPacket.Payload.CmdCtr == 1");

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_ENABLE_RTS_DEB_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID,
SC_ENABLE_RTS_INF_EID);
UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1);
}

Expand Down

0 comments on commit d4c5154

Please sign in to comment.