Skip to content

Commit

Permalink
Fix #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 1f40c79
Show file tree
Hide file tree
Showing 26 changed files with 647 additions and 583 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
115 changes: 89 additions & 26 deletions config/default_sc_msgdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,43 +37,94 @@
#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 */
};

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 +138,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 +171,9 @@
*/
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 */
SC_AtsId_Enum_t CurrAtsId; /**< \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 +255,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
44 changes: 22 additions & 22 deletions config/default_sc_msgstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
*/
typedef struct
{
CFE_MSG_TelemetryHeader_t TlmHeader;
CFE_MSG_TelemetryHeader_t TelemetryHeader;
SC_HkTlm_Payload_t Payload;
} SC_HkTlm_t;

Expand All @@ -74,7 +74,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_StartAtsCmd_Payload_t Payload;
} SC_StartAtsCmd_t;

Expand All @@ -85,7 +85,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_JumpAtsCmd_Payload_t Payload;
} SC_JumpAtsCmd_t;

Expand All @@ -96,7 +96,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_SetContinueAtsOnFailureCmd_Payload_t Payload;
} SC_SetContinueAtsOnFailureCmd_t;

Expand All @@ -107,7 +107,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_AppendAtsCmd_Payload_t Payload;
} SC_AppendAtsCmd_t;

Expand All @@ -118,17 +118,17 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
} SC_SendHkCmd_t;

/**
* \brief 1Hz Wakeup Command
*
* For command details see #SC_1HZ_WAKEUP_MID
* For command details see #SC_ONEHZ_WAKEUP_MID
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
} SC_OneHzWakeupCmd_t;

/**
Expand All @@ -138,7 +138,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
} SC_NoopCmd_t;

/**
Expand All @@ -148,7 +148,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
} SC_ResetCountersCmd_t;

/**
Expand All @@ -158,7 +158,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
} SC_StopAtsCmd_t;

/**
Expand All @@ -168,7 +168,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
} SC_SwitchAtsCmd_t;

/**
Expand All @@ -178,7 +178,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_RtsCmd_Payload_t Payload;
} SC_StartRtsCmd_t;

Expand All @@ -189,7 +189,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_RtsCmd_Payload_t Payload;
} SC_StopRtsCmd_t;

Expand All @@ -200,7 +200,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_RtsCmd_Payload_t Payload;
} SC_DisableRtsCmd_t;

Expand All @@ -211,7 +211,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_RtsCmd_Payload_t Payload;
} SC_EnableRtsCmd_t;

Expand All @@ -222,7 +222,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_SetContinueAtsOnFailureCmd_Payload_t Payload;
} SC_ContinueAtsOnFailureCmd_t;

Expand All @@ -233,7 +233,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
CFE_TBL_NotifyCmd_Payload_t Payload;
} SC_ManageTableCmd_t;

Expand All @@ -244,7 +244,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_RtsGrpCmd_Payload_t Payload;
} SC_StartRtsGrpCmd_t;

Expand All @@ -255,7 +255,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_RtsGrpCmd_Payload_t Payload;
} SC_StopRtsGrpCmd_t;

Expand All @@ -266,7 +266,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_RtsGrpCmd_Payload_t Payload;
} SC_DisableRtsGrpCmd_t;

Expand All @@ -277,7 +277,7 @@ typedef struct
*/
typedef struct
{
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command Header */
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command Header */
SC_RtsGrpCmd_Payload_t Payload;
} SC_EnableRtsGrpCmd_t;

Expand Down
Loading

0 comments on commit 1f40c79

Please sign in to comment.