Skip to content

Commit

Permalink
Fix nasa#113, define proper enumerations for SC constants
Browse files Browse the repository at this point in the history
Create enumerations according to the style documented in CFE.  Existing
symbols are put inside a backward compatibility switch, such that
existing table and message definitions should still work.
  • Loading branch information
jphickey committed Oct 24, 2023
1 parent 05dd449 commit 55fcadc
Show file tree
Hide file tree
Showing 22 changed files with 594 additions and 529 deletions.
6 changes: 3 additions & 3 deletions config/default_sc_internal_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,16 @@
#define SC_ATS_CMD_STAT_TABLE_NAME "ATSCMD_TBL"

/**
* \brief Defnies default state of Continue-Ats-On-Checksum-Failure Flag
* \brief Defines default state of Continue-Ats-On-Checksum-Failure Flag
*
* \par Description:
* This parameter specifies the default state to continue an ATS
* when a command in the ATS fails checksum validation
*
* \par Limits:
* Must be true or false
* Must be SC_AtsCont_TRUE or SC_AtsCont_FALSE
*/
#define SC_CONT_ON_FAILURE_START true
#define SC_CONT_ON_FAILURE_START SC_AtsCont_TRUE

/**
* \brief Defines the TIME SC should use for its commands
Expand Down
118 changes: 92 additions & 26 deletions config/default_sc_msgdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,43 +37,96 @@
#define SC_NUMBER_OF_RTS_IN_UINT16 16 /**< \brief Number of RTS represented in a uint16 */

/**
* \name ATS/RTS Cmd Status macros
* ATS/RTS Cmd Status Enumeratoion
*/
enum SC_Status
{
SC_Status_EMPTY, /**< \brief the object is not loaded */
SC_Status_LOADED, /**< \brief the object is loaded */
SC_Status_IDLE, /**< \brief the object is not executing */
SC_Status_EXECUTED, /**< \brief the object has completed executing */
SC_Status_SKIPPED, /**< \brief the object (ats command) was skipped */
SC_Status_EXECUTING, /**< \brief the object is currently executing */
SC_Status_FAILED_CHECKSUM, /**< \brief the object failed a checksum test */
SC_Status_FAILED_DISTRIB, /**< \brief the object could not be sent on the SWB */
SC_Status_STARTING, /**< \brief used when an inline switch is executed */

SC_Status_MAX /**< Reserved value, not used */
};

typedef uint8 SC_Status_Enum_t;

#ifndef SC_OMIT_DEPRECATED
/**
* \name Old-style ATS/RTS Cmd Status macros
* \{
*/
#define SC_EMPTY 0 /**< \brief the object is not loaded */
#define SC_LOADED 1 /**< \brief the object is loaded */
#define SC_IDLE 2 /**< \brief the object is not executing */
#define SC_EXECUTED 3 /**< \brief the object has completed executing */
#define SC_SKIPPED 4 /**< \brief the object (ats command) was skipped */
#define SC_EXECUTING 5 /**< \brief the object is currently executing */
#define SC_FAILED_CHECKSUM 6 /**< \brief the object failed a checksum test */
#define SC_FAILED_DISTRIB 7 /**< \brief the object could not be sent on the SWB */
#define SC_STARTING 8 /**< \brief used when an inline switch is executed */
#define SC_EMPTY SC_Status_EMPTY
#define SC_LOADED SC_Status_LOADED
#define SC_IDLE SC_Status_IDLE
#define SC_EXECUTED SC_Status_EXECUTED
#define SC_SKIPPED SC_Status_SKIPPED
#define SC_EXECUTING SC_Status_EXECUTING
#define SC_FAILED_CHECKSUM SC_Status_FAILED_CHECKSUM
#define SC_FAILED_DISTRIB SC_Status_FAILED_DISTRIB
#define SC_STARTING SC_Status_STARTING
/**\}*/
#endif

/************************************************************************
* Macro Definitions
************************************************************************/

/**
* \name Which processor runs next
* Enumeration for SC processes
* This specifies which process runs next
*/
enum SC_ProcessNum
{
SC_Process_ATP = 0, /**< \brief ATP process next */
SC_Process_RTP = 1, /**< \brief RTP process next */
SC_Process_NONE = 0xFF /**< \brief No pending process */
};

typedef uint8 SC_Process_Enum_t;

#ifndef SC_OMIT_DEPRECATED
/**
* \name Old-style defines for which process runs next
* \{
*/
#define SC_ATP 0 /**< \brief ATP process next */
#define SC_RTP 1 /**< \brief RTP process next */
#define SC_NONE 0xFF /**< \brief No pending process */
#define SC_ATP SC_Process_ATP
#define SC_RTP SC_Process_RTP
#define SC_NONE SC_Process_NONE
/**\}*/
#endif

#define SC_MAX_TIME 0xFFFFFFFF /**< \brief Maximum time in SC */

/**
* \name Defines for each ATS
* Enumeration for ATS identifiers
*
* ATS identifiers are alphabetic letters that correspond to ATS numbers
*/
enum SC_AtsId
{
SC_AtsId_NO_ATS, /**<\ brief No ATS */
SC_AtsId_ATSA, /**< \brief ATS A */
SC_AtsId_ATSB /**< \brief ATS B */
};

typedef uint8 SC_AtsId_Enum_t;

#ifndef SC_OMIT_DEPRECATED
/**
* \name Old-style defines for each ATS
* \{
*/
#define SC_NO_ATS 0 /**<\ brief No ATS */
#define SC_ATSA 1 /**< \brief ATS A */
#define SC_ATSB 2 /**< \brief ATS B */
#define SC_NO_ATS SC_AtsId_NO_ATS
#define SC_ATSA SC_AtsId_ATSA
#define SC_ATSB SC_AtsId_ATSB
/**\}*/
#endif

/**
* \name constants for config parameters for which TIME to use
Expand All @@ -87,12 +140,24 @@
#define SC_INVALID_RTS_NUMBER 0 /**< \brief Invalid RTS number */

/**
* \name SC Continue Flags
* SC Continue After Failure Enumeration
*/
enum SC_AtsCont
{
SC_AtsCont_FALSE = false, /**< \brief Do not continue on failure */
SC_AtsCont_TRUE = true /**< \brief Continue on failure */
};
typedef uint8 SC_AtsCont_Enum_t;

#ifndef SC_OMIT_DEPRECATED
/**
* \name Old-style SC Continue Flags
* \{
*/
#define SC_CONTINUE_TRUE 1 /**< \brief Continue on failure */
#define SC_CONTINUE_FALSE 0 /**< \brief Do not continue on failure */
#define SC_CONTINUE_TRUE SC_AtsCont_TRUE
#define SC_CONTINUE_FALSE SC_AtsCont_FALSE
/**\}*/
#endif

/************************************************************************
* Type Definitions
Expand All @@ -108,9 +173,10 @@
*/
typedef struct
{
uint8 AtsNumber; /**< \brief Current ATS number: 1 = ATS A, 2 = ATS B */
uint8 AtpState; /**< \brief Current ATP state: 2 = IDLE, 5 = EXECUTING */
uint8 ContinueAtsOnFailureFlag; /**< \brief Continue ATS execution on failure flag */
uint8 AtsNumber; /**< \brief Current ATS number: 1 = ATS A, 2 = ATS B */

SC_Status_Enum_t AtpState; /**< \brief Current ATP state: 2 = IDLE, 5 = EXECUTING */
SC_AtsCont_Enum_t ContinueAtsOnFailureFlag; /**< \brief Continue ATS execution on failure flag */

uint8 CmdErrCtr; /**< \brief Counts Request Errors */
uint8 CmdCtr; /**< \brief Counts Ground Requests */
Expand Down Expand Up @@ -192,8 +258,8 @@ typedef struct
*/
typedef struct
{
uint16 ContinueState; /**< \brief true or false, to continue ATS after a failure */
uint16 Padding; /**< \brief Structure Padding */
SC_AtsCont_Enum_t ContinueState; /**< \brief true or false, to continue ATS after a failure */
uint16 Padding; /**< \brief Structure Padding */
} SC_SetContinueAtsOnFailureCmd_Payload_t;

/**
Expand Down
6 changes: 3 additions & 3 deletions config/default_sc_msgids.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
* \{
*/

#define SC_CMD_MID (0x18A9) /**< \brief Msg ID for cmds to SC */
#define SC_SEND_HK_MID (0x18AA) /**< \brief Msg ID to request SC HK */
#define SC_1HZ_WAKEUP_MID (0x18AB) /**< \brief Msg ID to receive the 1Hz */
#define SC_CMD_MID (0x18A9) /**< \brief Msg ID for cmds to SC */
#define SC_SEND_HK_MID (0x18AA) /**< \brief Msg ID to request SC HK */
#define SC_ONEHZ_WAKEUP_MID (0x18AB) /**< \brief Msg ID to receive the 1Hz */

/**\}*/

Expand Down
2 changes: 1 addition & 1 deletion config/default_sc_msgstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ typedef struct
/**
* \brief 1Hz Wakeup Command
*
* For command details see #SC_1HZ_WAKEUP_MID
* For command details see #SC_ONEHZ_WAKEUP_MID
*/
typedef struct
{
Expand Down
2 changes: 1 addition & 1 deletion docs/dox_src/cfs_sc.dox
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
CFS Stored Command requires that two message ID's be put in the CFS Scheduler
table for proper operation. Those message ID's are #SC_SEND_HK_MID, which
should be sent out at the housekeeping request interval, and
#SC_1HZ_WAKEUP_MID, which needs to be sent out every second.
#SC_ONEHZ_WAKEUP_MID, which needs to be sent out every second.

CFS Stored Command generates telemetry when it receives the housekeeping
request. Its telemetry message ID is #SC_HK_TLM_MID.
Expand Down
8 changes: 4 additions & 4 deletions fsw/inc/sc_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
* This event message is issued when #CFE_SB_Subscribe to the 1 Hz
* Request packet fails
*/
#define SC_INIT_SB_SUBSCRIBE_1HZ_ERR_EID 5
#define SC_INIT_SB_SUBSCRIBE_ONEHZ_ERR_EID 5

/**
* \brief HS Command Message Subscribe Failed Event ID
Expand Down Expand Up @@ -474,7 +474,7 @@
*
* \par Cause:
* This event message is issued when an ATS command is about to be send out,
* but the command isn't marked as '#SC_LOADED'
* but the command isn't marked as '#SC_Status_LOADED'
*/
#define SC_ATS_SKP_ERR_EID 48

Expand Down Expand Up @@ -701,7 +701,7 @@
*
* \par Cause:
* This event message is issued when an RTS is tried to be started, but the RTS is not
* marked as #SC_LOADED
* marked as #SC_Status_LOADED
*/
#define SC_STARTRTS_CMD_NOT_LDED_ERR_EID 75

Expand Down Expand Up @@ -1225,7 +1225,7 @@
*
* \par Cause:
* This event message is issued when a #SC_START_RTS_GRP_CC command was received, but an
* RTS is marked as #SC_LOADED
* RTS is marked as #SC_Status_LOADED
*/
#define SC_STARTRTSGRP_CMD_NOT_LDED_ERR_EID 126

Expand Down
18 changes: 9 additions & 9 deletions fsw/src/sc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ CFE_Status_t SC_AppInit(void)
SC_AppData.EnableHeaderUpdate = SC_PLATFORM_ENABLE_HEADER_UPDATE;

/* Make sure nothing is running */
SC_AppData.NextProcNumber = SC_NONE;
SC_AppData.NextCmdTime[SC_ATP] = SC_MAX_TIME;
SC_AppData.NextCmdTime[SC_RTP] = SC_MAX_TIME;
SC_AppData.NextProcNumber = SC_Process_NONE;
SC_AppData.NextCmdTime[SC_Process_ATP] = SC_MAX_TIME;
SC_AppData.NextCmdTime[SC_Process_RTP] = SC_MAX_TIME;

/* Initialize the SC housekeeping packet */
CFE_MSG_Init(&SC_OperData.HkPacket.TlmHeader.Msg, CFE_SB_ValueToMsgId(SC_HK_TLM_MID), sizeof(SC_HkTlm_t));
Expand Down Expand Up @@ -196,10 +196,10 @@ CFE_Status_t SC_AppInit(void)
}

/* Must be able to subscribe to 1Hz wakeup command */
Result = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(SC_1HZ_WAKEUP_MID), SC_OperData.CmdPipe);
Result = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(SC_ONEHZ_WAKEUP_MID), SC_OperData.CmdPipe);
if (Result != CFE_SUCCESS)
{
CFE_EVS_SendEvent(SC_INIT_SB_SUBSCRIBE_1HZ_ERR_EID, CFE_EVS_EventType_ERROR,
CFE_EVS_SendEvent(SC_INIT_SB_SUBSCRIBE_ONEHZ_ERR_EID, CFE_EVS_EventType_ERROR,
"Software Bus subscribe to 1 Hz cycle returned: 0x%08X", (unsigned int)Result);
return (Result);
}
Expand Down Expand Up @@ -254,8 +254,8 @@ CFE_Status_t SC_InitTables(void)
}

/* ATP control block status table */
SC_OperData.AtsCtrlBlckAddr->AtpState = SC_IDLE;
SC_OperData.AtsCtrlBlckAddr->AtsNumber = SC_NO_ATS;
SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_IDLE;
SC_OperData.AtsCtrlBlckAddr->AtsNumber = SC_AtsId_NO_ATS;
SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_INVALID_CMD_NUMBER;

/* RTP control block status table */
Expand All @@ -267,7 +267,7 @@ CFE_Status_t SC_InitTables(void)
{
for (j = 0; j < SC_MAX_ATS_CMDS; j++)
{
SC_OperData.AtsCmdStatusTblAddr[i][j] = SC_EMPTY;
SC_OperData.AtsCmdStatusTblAddr[i][j] = SC_Status_EMPTY;
}
}

Expand All @@ -276,7 +276,7 @@ CFE_Status_t SC_InitTables(void)
{
SC_OperData.RtsInfoTblAddr[i].NextCommandTime = SC_MAX_TIME;
SC_OperData.RtsInfoTblAddr[i].NextCommandPtr = 0;
SC_OperData.RtsInfoTblAddr[i].RtsStatus = SC_EMPTY;
SC_OperData.RtsInfoTblAddr[i].RtsStatus = SC_Status_EMPTY;
SC_OperData.RtsInfoTblAddr[i].DisabledFlag = true;
}

Expand Down
10 changes: 5 additions & 5 deletions fsw/src/sc_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ typedef struct

bool EnableHeaderUpdate; /**< \brief whether to update headers in outgoing messages */

uint8 NextProcNumber; /**< \brief the next command processor number */
SC_AbsTimeTag_t NextCmdTime[2]; /**< \brief The overall next command time 0 - ATP, 1- RTP*/
SC_AbsTimeTag_t CurrentTime; /**< \brief this is the current time for SC */
uint16 AutoStartRTS; /**< \brief Start selected auto-exec RTS after init */
uint16 AppendWordCount; /**< \brief Size of cmd entries in current Append ATS table */
SC_Process_Enum_t NextProcNumber; /**< \brief the next command processor number */
SC_AbsTimeTag_t NextCmdTime[2]; /**< \brief The overall next command time 0 - ATP, 1- RTP*/
SC_AbsTimeTag_t CurrentTime; /**< \brief this is the current time for SC */
uint16 AutoStartRTS; /**< \brief Start selected auto-exec RTS after init */
uint16 AppendWordCount; /**< \brief Size of cmd entries in current Append ATS table */
} SC_AppData_t;

/************************************************************************
Expand Down
Loading

0 comments on commit 55fcadc

Please sign in to comment.