From 99467c4751c2af5577ec72d1a65c66621beb499c Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 12 Oct 2023 09:48:37 -0400 Subject: [PATCH] Fix #117, change local array refs to object pointer This changes all "info" table access to go through an object pointer that is obtained via an accessor method. --- fsw/src/sc_app.c | 22 +- fsw/src/sc_app.h | 126 +++++++- fsw/src/sc_atsrq.c | 128 ++++---- fsw/src/sc_cmds.c | 106 +++--- fsw/src/sc_loads.c | 189 ++++++----- fsw/src/sc_rtsrq.c | 157 +++++---- fsw/src/sc_state.c | 75 +++-- unit-test/sc_atsrq_tests.c | 386 +++++++++++++--------- unit-test/sc_cmds_tests.c | 483 ++++++++++++++++------------ unit-test/sc_loads_tests.c | 317 ++++++++++++------ unit-test/sc_rtsrq_tests.c | 258 ++++++++------- unit-test/sc_state_tests.c | 384 +++++++++++++--------- unit-test/utilities/sc_test_utils.c | 16 +- unit-test/utilities/sc_test_utils.h | 4 + 14 files changed, 1641 insertions(+), 1010 deletions(-) diff --git a/fsw/src/sc_app.c b/fsw/src/sc_app.c index ae4d648..0fc2567 100644 --- a/fsw/src/sc_app.c +++ b/fsw/src/sc_app.c @@ -240,9 +240,11 @@ CFE_Status_t SC_AppInit(void) CFE_Status_t SC_InitTables(void) { - CFE_Status_t Result; - int32 i; - int32 j; + CFE_Status_t Result; + int32 i; + int32 j; + SC_RtsInfoEntry_t * RtsInfoPtr; + SC_AtsCmdStatusEntry_t *StatusEntryPtr; /* Must be able to register all tables with cFE Table Services */ Result = SC_RegisterAllTables(); @@ -272,17 +274,21 @@ CFE_Status_t SC_InitTables(void) { for (j = 0; j < SC_MAX_ATS_CMDS; j++) { - SC_OperData.AtsCmdStatusTblAddr[i][j] = SC_Status_EMPTY; + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(SC_ATS_IDX_C(i), SC_COMMAND_IDX_C(j)); + + StatusEntryPtr->Status = SC_Status_EMPTY; } } /* RTS information table */ for (i = 0; i < SC_NUMBER_OF_RTS; i++) { - SC_OperData.RtsInfoTblAddr[i].NextCommandTime = SC_MAX_TIME; - SC_OperData.RtsInfoTblAddr[i].NextCommandPtr = SC_ENTRY_OFFSET_FIRST; - SC_OperData.RtsInfoTblAddr[i].RtsStatus = SC_Status_EMPTY; - SC_OperData.RtsInfoTblAddr[i].DisabledFlag = true; + RtsInfoPtr = SC_GetRtsInfoObject(SC_RTS_IDX_C(i)); + + RtsInfoPtr->NextCommandTime = SC_MAX_TIME; + RtsInfoPtr->NextCommandPtr = SC_ENTRY_OFFSET_FIRST; + RtsInfoPtr->RtsStatus = SC_Status_EMPTY; + RtsInfoPtr->DisabledFlag = true; } /* Load default RTS tables */ diff --git a/fsw/src/sc_app.h b/fsw/src/sc_app.h index a887edc..3e54bf3 100644 --- a/fsw/src/sc_app.h +++ b/fsw/src/sc_app.h @@ -276,6 +276,16 @@ void SC_RegisterManageCmds(void); #define SC_BYTES_IN_ATS_APPEND_ENTRY 2 /**< \brief Bytes in an ATS append table entry */ +/** + * @brief Entry definition for the command status table + * + * This table stores the status of commands executed in an ATS + */ +typedef struct SC_AtsCmdStatusEntry +{ + SC_Status_Enum_t Status; +} SC_AtsCmdStatusEntry_t; + /** * \brief SC Operational Data Structure * @@ -307,8 +317,8 @@ typedef struct CFE_TBL_Handle_t AtsCtrlBlckHandle; /**< \brief Table handle for the ATP ctrl block */ SC_AtpControlBlock_t *AtsCtrlBlckAddr; /**< \brief Table address for the ATP ctrl block*/ - CFE_TBL_Handle_t AtsCmdStatusHandle[SC_NUMBER_OF_ATS]; /**< \brief ATS Cmd Status table handle */ - SC_Status_Enum_t *AtsCmdStatusTblAddr[SC_NUMBER_OF_ATS]; /**< \brief ATS Cmd Status table address */ + CFE_TBL_Handle_t AtsCmdStatusHandle[SC_NUMBER_OF_ATS]; /**< \brief ATS Cmd Status table handle */ + SC_AtsCmdStatusEntry_t *AtsCmdStatusTblAddr[SC_NUMBER_OF_ATS]; /**< \brief ATS Cmd Status table address */ int32 AtsDupTestArray[SC_MAX_ATS_CMDS]; /**< \brief ATS test for duplicate cmd numbers */ @@ -317,19 +327,39 @@ typedef struct SC_HkTlm_t HkPacket; /**< \brief SC Housekeeping structure */ } SC_OperData_t; +/** + * @brief Entry definition for the command entry offset table + * + * This table stores the offset of commands within in an ATS + */ +typedef struct SC_AtsCmdEntryOffsetRecord +{ + SC_EntryOffset_t Offset; +} SC_AtsCmdEntryOffsetRecord_t; + +/** + * @brief Entry definition for the command number table + * + * This table maps the sequence numbers to command numbers in an ATS + */ +typedef struct SC_AtsCmdNumRecord +{ + SC_CommandNum_t CmdNum; +} SC_AtsCmdNumRecord_t; + /** * \brief SC Application Data Structure * This structure is used by the application to process time ordered commands. */ typedef struct { - SC_CommandNum_t AtsTimeIndexBuffer[SC_NUMBER_OF_ATS][SC_MAX_ATS_CMDS]; + SC_AtsCmdNumRecord_t AtsTimeIndexBuffer[SC_NUMBER_OF_ATS][SC_MAX_ATS_CMDS]; /**< \brief This table is used to keep a time ordered listing of ATS command indexes (0 based). The first entry in this table holds the command index of the command that will execute first, the second entry has the index of the 2nd cmd, etc.. */ - SC_EntryOffset_t AtsCmdIndexBuffer[SC_NUMBER_OF_ATS][SC_MAX_ATS_CMDS]; + SC_AtsCmdEntryOffsetRecord_t AtsCmdIndexBuffer[SC_NUMBER_OF_ATS][SC_MAX_ATS_CMDS]; /**< \brief This table is used to keep a list of ATS table command offsets. These offsets correspond to the addresses of ATS commands located in the ATS table. The index used is the ATS command index with values from 0 to SC_MAX_ATS_CMDS-1 */ @@ -351,4 +381,92 @@ typedef struct extern SC_AppData_t SC_AppData; extern SC_OperData_t SC_OperData; +/** + * @brief Locates the Info object associated with the given RTS index + * + * @param RtsIndex The RTS index + * @returns The info object for the given RTS + */ +static inline SC_RtsInfoEntry_t *SC_GetRtsInfoObject(SC_RtsIndex_t RtsIndex) +{ + return &SC_OperData.RtsInfoTblAddr[SC_IDX_AS_UINT(RtsIndex)]; +} + +/** + * @brief Locates the Info object associated with the given ATS index + * + * @param AtsIndex The ATS index + * @returns The info object for the given ATS + */ +static inline SC_AtsInfoTable_t *SC_GetAtsInfoObject(SC_AtsIndex_t AtsIndex) +{ + return &SC_OperData.AtsInfoTblAddr[SC_IDX_AS_UINT(AtsIndex)]; +} + +/** + * @brief Locates a specific entry within an RTS + * + * The entry is specified via its offset (in words) from the start of the RTS + * + * @param RtsIndex The RTS index + * @param EntryOffset The offset from the start of the RTS, in words + * @returns Pointer to the entry within the RTS + */ +static inline SC_RtsEntry_t *SC_GetRtsEntryAtOffset(SC_RtsIndex_t RtsIndex, SC_EntryOffset_t EntryOffset) +{ + return (SC_RtsEntry_t *)&SC_OperData.RtsTblAddr[SC_IDX_AS_UINT(RtsIndex)][SC_IDX_AS_UINT(EntryOffset)]; +} + +/** + * @brief Locates a specific entry within an ATS + * + * The entry is specified via its offset (in words) from the start of the ATS + * + * @param AtsIndex The ATS index + * @param EntryOffset The offset from the start of the ATS, in words + * @returns Pointer to the entry within the ATS + */ +static inline SC_AtsEntry_t *SC_GetAtsEntryAtOffset(SC_AtsIndex_t AtsIndex, SC_EntryOffset_t EntryOffset) +{ + return (SC_AtsEntry_t *)&SC_OperData.AtsTblAddr[SC_IDX_AS_UINT(AtsIndex)][SC_IDX_AS_UINT(EntryOffset)]; +} + +/** + * @brief Locates the record that maps the command index to an ATS entry offset + * + * @param AtsIndex The ATS index + * @param CommandIndex The command index + * @returns Pointer to the SC_AtsCmdEntryOffsetRecord_t object + */ +static inline SC_AtsCmdEntryOffsetRecord_t *SC_GetAtsEntryOffsetForCmd(SC_AtsIndex_t AtsIndex, + SC_CommandIndex_t CommandIndex) +{ + return &SC_AppData.AtsCmdIndexBuffer[SC_IDX_AS_UINT(AtsIndex)][SC_IDX_AS_UINT(CommandIndex)]; +} + +/** + * @brief Locates the record that maps the sequence index to an ATS command number + * + * @param AtsIndex The ATS index + * @param SeqIndex The sequence index + * @returns Pointer to the SC_AtsCmdNumRecord_t object + */ +static inline SC_AtsCmdNumRecord_t *SC_GetAtsCommandNumAtSeq(SC_AtsIndex_t AtsIndex, SC_SeqIndex_t SeqIndex) +{ + return &SC_AppData.AtsTimeIndexBuffer[SC_IDX_AS_UINT(AtsIndex)][SC_IDX_AS_UINT(SeqIndex)]; +} + +/** + * @brief Locates the record that holds the status of an ATS command + * + * @param AtsIndex The ATS index + * @param CommandIndex The command index + * @returns Pointer to the SC_AtsCmdStatusEntry_t object + */ +static inline SC_AtsCmdStatusEntry_t *SC_GetAtsStatusEntryForCommand(SC_AtsIndex_t AtsIndex, + SC_CommandIndex_t CommandIndex) +{ + return &SC_OperData.AtsCmdStatusTblAddr[SC_IDX_AS_UINT(AtsIndex)][SC_IDX_AS_UINT(CommandIndex)]; +} + #endif diff --git a/fsw/src/sc_atsrq.c b/fsw/src/sc_atsrq.c index 78015b8..6976511 100644 --- a/fsw/src/sc_atsrq.c +++ b/fsw/src/sc_atsrq.c @@ -49,8 +49,9 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_StartAtsCmd(const SC_StartAtsCmd_t *Cmd) { - SC_AtsNum_t AtsNum; /* ATS ID */ - SC_AtsIndex_t AtsIndex; /* ATS array index */ + SC_AtsNum_t AtsNum; /* ATS ID */ + SC_AtsIndex_t AtsIndex; /* ATS array index */ + SC_AtsInfoTable_t *AtsInfoPtr; AtsNum = Cmd->Payload.AtsNum; @@ -58,13 +59,14 @@ void SC_StartAtsCmd(const SC_StartAtsCmd_t *Cmd) if ((AtsNum > 0) && (AtsNum <= SC_NUMBER_OF_ATS)) { /* convert ATS ID to array index */ - AtsIndex = SC_AtsNumToIndex(AtsNum); + AtsIndex = SC_AtsNumToIndex(AtsNum); + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); /* make sure that there is no ATS running on the ATP */ if (SC_OperData.AtsCtrlBlckAddr->AtpState == SC_Status_IDLE) { /* make sure the specified ATS is ready */ - if (SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands > 0) + if (AtsInfoPtr->NumberOfCommands > 0) { /* start the ats */ if (SC_BeginAts(AtsIndex, 0)) @@ -172,14 +174,16 @@ void SC_StopAtsCmd(const SC_StopAtsCmd_t *Cmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bool SC_BeginAts(SC_AtsIndex_t AtsIndex, uint16 TimeOffset) { - SC_AtsEntryHeader_t *Entry; /* ATS table entry pointer */ - SC_EntryOffset_t EntryIndex; /* ATS entry location in table */ - SC_AbsTimeTag_t ListCmdTime = 0; /* list entry execution time */ - SC_SeqIndex_t TimeIndex; /* the current time buffer index */ - SC_CommandIndex_t CmdIndex; /* ATS command index */ - bool ReturnCode; - SC_AbsTimeTag_t TimeToStartAts; /* the REAL time to start the ATS */ - uint16 CmdsSkipped = 0; + SC_AtsEntryHeader_t * Entry; /* ATS table entry pointer */ + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; /* ATS entry location in table */ + SC_AbsTimeTag_t ListCmdTime = 0; /* list entry execution time */ + SC_SeqIndex_t TimeIndex; /* the current time buffer index */ + SC_CommandIndex_t CmdIndex; /* ATS command index */ + bool ReturnCode; + SC_AbsTimeTag_t TimeToStartAts; /* the REAL time to start the ATS */ + uint16 CmdsSkipped = 0; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; /* validate ATS array index */ if (AtsIndex >= SC_NUMBER_OF_ATS) @@ -189,6 +193,7 @@ bool SC_BeginAts(SC_AtsIndex_t AtsIndex, uint16 TimeOffset) return false; } + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); TimeToStartAts = SC_ComputeAbsTime(TimeOffset); /* @@ -198,14 +203,14 @@ bool SC_BeginAts(SC_AtsIndex_t AtsIndex, uint16 TimeOffset) */ TimeIndex = SC_SEQUENCE_IDX_FIRST; /* pointer into the time index table */ - while (TimeIndex < SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands) + while (TimeIndex < AtsInfoPtr->NumberOfCommands) { /* first get the cmd index at this list entry */ - CmdIndex = SC_CommandNumToIndex(SC_AppData.AtsTimeIndexBuffer[AtsIndex][TimeIndex]); + CmdIndex = SC_CommandNumToIndex(SC_GetAtsCommandNumAtSeq(AtsIndex, TimeIndex)->CmdNum); /* then get the entry index from the cmd index table */ - EntryIndex = SC_AppData.AtsCmdIndexBuffer[AtsIndex][CmdIndex]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, CmdIndex); /* then get a pointer to the ATS entry data */ - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][EntryIndex]; + Entry = &SC_GetAtsEntryAtOffset(AtsIndex, CmdOffsetRec->Offset)->Header; /* then get cmd execution time from the ATS entry */ ListCmdTime = SC_GetAtsEntryTime(Entry); @@ -213,8 +218,9 @@ bool SC_BeginAts(SC_AtsIndex_t AtsIndex, uint16 TimeOffset) if (SC_CompareAbsTime(TimeToStartAts, ListCmdTime)) { /* start time is greater than this list entry time */ + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, CmdIndex); - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] = SC_Status_SKIPPED; + StatusEntryPtr->Status = SC_Status_SKIPPED; CmdsSkipped++; TimeIndex++; } @@ -228,7 +234,7 @@ bool SC_BeginAts(SC_AtsIndex_t AtsIndex, uint16 TimeOffset) /* ** Check to see if the whole ATS was skipped */ - if (TimeIndex == SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands) + if (TimeIndex == AtsInfoPtr->NumberOfCommands) { CFE_EVS_SendEvent(SC_ATS_SKP_ALL_ERR_EID, CFE_EVS_EventType_ERROR, "All ATS commands were skipped, ATS stopped"); @@ -271,7 +277,8 @@ bool SC_BeginAts(SC_AtsIndex_t AtsIndex, uint16 TimeOffset) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_KillAts(void) { - SC_AtsIndex_t AtsIndex; + SC_AtsIndex_t AtsIndex; + SC_AtsInfoTable_t *AtsInfoPtr; /* * Check if the ATS ID is valid @@ -280,7 +287,9 @@ void SC_KillAts(void) if (SC_AtsIndexIsValid(AtsIndex) && SC_OperData.AtsCtrlBlckAddr->AtpState != SC_Status_IDLE) { /* Increment the ats use counter */ - SC_OperData.AtsInfoTblAddr[AtsIndex].AtsUseCtr++; + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + + AtsInfoPtr->AtsUseCtr++; } /* ** Reset the state in the atp control block @@ -298,16 +307,18 @@ void SC_KillAts(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_SwitchAtsCmd(const SC_SwitchAtsCmd_t *Cmd) { - SC_AtsIndex_t NewAtsIndex; /* the index of the ats to switch to*/ + SC_AtsIndex_t NewAtsIndex; /* the index of the ats to switch to*/ + SC_AtsInfoTable_t *AtsInfoPtr; /* make sure that an ATS is running on the ATP */ if (SC_OperData.AtsCtrlBlckAddr->AtpState == SC_Status_EXECUTING) { /* get the ATS to switch to */ NewAtsIndex = SC_ToggleAtsIndex(); + AtsInfoPtr = SC_GetAtsInfoObject(NewAtsIndex); /* Now check to see if the new ATS has commands in it */ - if (SC_OperData.AtsInfoTblAddr[NewAtsIndex].NumberOfCommands > 0) + if (AtsInfoPtr->NumberOfCommands > 0) { /* set the global switch pend flag */ SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = true; @@ -351,8 +362,9 @@ void SC_SwitchAtsCmd(const SC_SwitchAtsCmd_t *Cmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_ServiceSwitchPend(void) { - SC_AtsIndex_t NewAtsIndex; /* the ats index that we are switching to */ - SC_AtsIndex_t OldAtsIndex; /* the ats index we are switching from */ + SC_AtsIndex_t NewAtsIndex; /* the ats index that we are switching to */ + SC_AtsIndex_t OldAtsIndex; /* the ats index we are switching from */ + SC_AtsInfoTable_t *AtsInfoPtr; /* ** See if it is time to switch the ATS @@ -365,9 +377,10 @@ void SC_ServiceSwitchPend(void) /* get the ATS number to switch to and from */ OldAtsIndex = SC_AtsNumToIndex(SC_OperData.AtsCtrlBlckAddr->CurrAtsNum); NewAtsIndex = SC_ToggleAtsIndex(); + AtsInfoPtr = SC_GetAtsInfoObject(NewAtsIndex); /* Now check to see if the new ATS has commands in it */ - if (SC_OperData.AtsInfoTblAddr[NewAtsIndex].NumberOfCommands > 0) + if (AtsInfoPtr->NumberOfCommands > 0) { /* stop the current ATS */ SC_KillAts(); @@ -418,9 +431,10 @@ void SC_ServiceSwitchPend(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ bool SC_InlineSwitch(void) { - SC_AtsIndex_t NewAtsIndex; /* the index of the ats to switch to*/ - SC_AtsIndex_t OldAtsIndex; /* the index of the ats to switch from*/ - bool ReturnCode; /* return code for function */ + SC_AtsIndex_t NewAtsIndex; /* the index of the ats to switch to*/ + SC_AtsIndex_t OldAtsIndex; /* the index of the ats to switch from*/ + bool ReturnCode; /* return code for function */ + SC_AtsInfoTable_t *AtsInfoPtr; /* figure out which ATS to switch to */ NewAtsIndex = SC_ToggleAtsIndex(); @@ -429,7 +443,8 @@ bool SC_InlineSwitch(void) OldAtsIndex = SC_AtsNumToIndex(SC_OperData.AtsCtrlBlckAddr->CurrAtsNum); /* Now check to see if the new ATS has commands in it */ - if (SC_OperData.AtsInfoTblAddr[NewAtsIndex].NumberOfCommands > 0) + AtsInfoPtr = SC_GetAtsInfoObject(NewAtsIndex); + if (AtsInfoPtr->NumberOfCommands > 0) { /* ** Stop the current ATS @@ -488,21 +503,24 @@ bool SC_InlineSwitch(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_JumpAtsCmd(const SC_JumpAtsCmd_t *Cmd) { - SC_AtsEntryHeader_t *Entry; /* ATS table entry pointer */ - SC_EntryOffset_t EntryIndex; /* ATS entry location in table */ - SC_AbsTimeTag_t JumpTime; /* the time to jump to in the ATS */ - SC_AbsTimeTag_t ListCmdTime; /* list entry execution time */ - SC_AtsIndex_t AtsIndex; /* index of the ATS that is running */ - SC_SeqIndex_t TimeIndex; /* the current time buffer index */ - SC_CommandIndex_t CmdIndex; /* ATS command index (cmd num - 1) */ - char TimeBuffer[CFE_TIME_PRINTED_STRING_SIZE]; - CFE_TIME_SysTime_t NewTime; - uint16 NumSkipped; + SC_AtsEntryHeader_t * Entry; /* ATS table entry pointer */ + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; /* ATS entry location in table */ + SC_AbsTimeTag_t JumpTime; /* the time to jump to in the ATS */ + SC_AbsTimeTag_t ListCmdTime; /* list entry execution time */ + SC_AtsIndex_t AtsIndex; /* index of the ATS that is running */ + SC_SeqIndex_t TimeIndex; /* the current time buffer index */ + SC_CommandIndex_t CmdIndex; /* ATS command index (cmd num - 1) */ + char TimeBuffer[CFE_TIME_PRINTED_STRING_SIZE]; + CFE_TIME_SysTime_t NewTime; + uint16 NumSkipped; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; if (SC_OperData.AtsCtrlBlckAddr->AtpState == SC_Status_EXECUTING) { - JumpTime = Cmd->Payload.NewTime; - AtsIndex = SC_AtsNumToIndex(SC_OperData.AtsCtrlBlckAddr->CurrAtsNum); + JumpTime = Cmd->Payload.NewTime; + AtsIndex = SC_AtsNumToIndex(SC_OperData.AtsCtrlBlckAddr->CurrAtsNum); + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); /* ** Loop through the commands until a time tag is found @@ -512,14 +530,14 @@ void SC_JumpAtsCmd(const SC_JumpAtsCmd_t *Cmd) TimeIndex = SC_SEQUENCE_IDX_FIRST; NumSkipped = 0; - while (TimeIndex < SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands) + while (TimeIndex < AtsInfoPtr->NumberOfCommands) { /* first get the cmd index at this list entry */ - CmdIndex = SC_CommandNumToIndex(SC_AppData.AtsTimeIndexBuffer[AtsIndex][TimeIndex]); + CmdIndex = SC_CommandNumToIndex(SC_GetAtsCommandNumAtSeq(AtsIndex, TimeIndex)->CmdNum); /* then get the entry index from the cmd index table */ - EntryIndex = SC_AppData.AtsCmdIndexBuffer[AtsIndex][CmdIndex]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, CmdIndex); /* then get a pointer to the ATS entry data */ - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][EntryIndex]; + Entry = &SC_GetAtsEntryAtOffset(AtsIndex, CmdOffsetRec->Offset)->Header; /* then get cmd execution time from the ATS entry */ ListCmdTime = SC_GetAtsEntryTime(Entry); @@ -534,9 +552,10 @@ void SC_JumpAtsCmd(const SC_JumpAtsCmd_t *Cmd) ** if the command has any other status, SC_Status_SKIPPED, SC_Status_EXECUTED, ** etc, then leave the status alone. */ - if (SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] == SC_Status_LOADED) + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, CmdIndex); + if (StatusEntryPtr->Status == SC_Status_LOADED) { - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] = SC_Status_SKIPPED; + StatusEntryPtr->Status = SC_Status_SKIPPED; NumSkipped++; } @@ -554,7 +573,7 @@ void SC_JumpAtsCmd(const SC_JumpAtsCmd_t *Cmd) /* ** Check to see if the whole ATS was skipped */ - if (TimeIndex == SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands) + if (TimeIndex == AtsInfoPtr->NumberOfCommands) { CFE_EVS_SendEvent(SC_JUMPATS_CMD_STOPPED_ERR_EID, CFE_EVS_EventType_ERROR, "Jump Cmd: All ATS commands were skipped, ATS stopped"); @@ -643,7 +662,8 @@ void SC_ContinueAtsOnFailureCmd(const SC_ContinueAtsOnFailureCmd_t *Cmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_AppendAtsCmd(const SC_AppendAtsCmd_t *Cmd) { - SC_AtsIndex_t AtsIndex; /* index (not ID) of target ATS */ + SC_AtsIndex_t AtsIndex; /* index (not ID) of target ATS */ + SC_AtsInfoTable_t *AtsInfoPtr; if ((Cmd->Payload.AtsNum == 0) || (Cmd->Payload.AtsNum > SC_NUMBER_OF_ATS)) { @@ -657,9 +677,10 @@ void SC_AppendAtsCmd(const SC_AppendAtsCmd_t *Cmd) } /* create base zero array index from base one ID value */ - AtsIndex = SC_AtsNumToIndex(Cmd->Payload.AtsNum); + AtsIndex = SC_AtsNumToIndex(Cmd->Payload.AtsNum); + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); - if (SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands == 0) + if (AtsInfoPtr->NumberOfCommands == 0) { /* target ATS table is empty */ SC_OperData.HkPacket.Payload.CmdErrCtr++; @@ -675,15 +696,14 @@ void SC_AppendAtsCmd(const SC_AppendAtsCmd_t *Cmd) CFE_EVS_SendEvent(SC_APPEND_CMD_SRC_ERR_EID, CFE_EVS_EventType_ERROR, "Append ATS %c error: Append table is empty", 'A' + AtsIndex); } - else if ((SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize + SC_AppData.AppendWordCount) > SC_ATS_BUFF_SIZE32) + else if ((AtsInfoPtr->AtsSize + SC_AppData.AppendWordCount) > SC_ATS_BUFF_SIZE32) { /* not enough room in ATS buffer for Append table data */ SC_OperData.HkPacket.Payload.CmdErrCtr++; CFE_EVS_SendEvent(SC_APPEND_CMD_FIT_ERR_EID, CFE_EVS_EventType_ERROR, "Append ATS %c error: ATS size = %d, Append size = %d, ATS buffer = %d", 'A' + AtsIndex, - (int)SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize, SC_AppData.AppendWordCount, - SC_ATS_BUFF_SIZE32); + (int)AtsInfoPtr->AtsSize, SC_AppData.AppendWordCount, SC_ATS_BUFF_SIZE32); } else { diff --git a/fsw/src/sc_cmds.c b/fsw/src/sc_cmds.c index ffd9246..0f24d9a 100644 --- a/fsw/src/sc_cmds.c +++ b/fsw/src/sc_cmds.c @@ -55,16 +55,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_ProcessAtpCmd(void) { - SC_EntryOffset_t EntryIndex; /* ATS entry location in table */ - SC_AtsIndex_t AtsIndex; /* ATS selection index */ - SC_CommandIndex_t CmdIndex; /* ATS command index */ - char TempAtsChar; - CFE_Status_t Result; - bool AbortATS = false; - SC_AtsEntry_t * EntryPtr; - CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; - CFE_MSG_FcnCode_t CommandCode = 0; - bool ChecksumValid; + SC_AtsIndex_t AtsIndex; /* ATS selection index */ + SC_CommandIndex_t CmdIndex; /* ATS command index */ + CFE_Status_t Result; + char TempAtsChar; + bool AbortATS = false; + SC_AtsEntry_t * EntryPtr; + CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; + CFE_MSG_FcnCode_t CommandCode = 0; + bool ChecksumValid; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; /* ATS entry location in table */ + SC_AtsCmdStatusEntry_t * StatusEntryPtr; /* ** The following conditions must be met before the ATS command will be @@ -81,15 +82,15 @@ void SC_ProcessAtpCmd(void) /* ** Get a pointer to the next ats command */ - AtsIndex = SC_AtsNumToIndex(SC_OperData.AtsCtrlBlckAddr->CurrAtsNum); /* remember 0..1 */ - CmdIndex = SC_CommandNumToIndex(SC_OperData.AtsCtrlBlckAddr->CmdNumber); - EntryIndex = SC_AppData.AtsCmdIndexBuffer[AtsIndex][CmdIndex]; - EntryPtr = (SC_AtsEntry_t *)&SC_OperData.AtsTblAddr[AtsIndex][EntryIndex]; - + AtsIndex = SC_AtsNumToIndex(SC_OperData.AtsCtrlBlckAddr->CurrAtsNum); /* remember 0..1 */ + CmdIndex = SC_CommandNumToIndex(SC_OperData.AtsCtrlBlckAddr->CmdNumber); + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, CmdIndex); + EntryPtr = SC_GetAtsEntryAtOffset(AtsIndex, CmdOffsetRec->Offset); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, CmdIndex); /* ** Make sure the command has not been executed, skipped or has any other bad status */ - if (SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] == SC_Status_LOADED) + if (StatusEntryPtr->Status == SC_Status_LOADED) { /* ** Make sure the command number matches what the command @@ -142,13 +143,13 @@ void SC_ProcessAtpCmd(void) ** Increment the counter and update the status for ** this command */ - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] = SC_Status_EXECUTED; + StatusEntryPtr->Status = SC_Status_EXECUTED; SC_OperData.HkPacket.Payload.AtsCmdCtr++; } else { /* the switch failed for some reason */ - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] = SC_Status_FAILED_DISTRIB; + StatusEntryPtr->Status = SC_Status_FAILED_DISTRIB; SC_OperData.HkPacket.Payload.AtsCmdErrCtr++; SC_OperData.HkPacket.Payload.LastAtsErrSeq = SC_OperData.AtsCtrlBlckAddr->CurrAtsNum; SC_OperData.HkPacket.Payload.LastAtsErrCmd = SC_OperData.AtsCtrlBlckAddr->CmdNumber; @@ -162,12 +163,12 @@ void SC_ProcessAtpCmd(void) if (Result == CFE_SUCCESS) { /* The command sent OK */ - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] = SC_Status_EXECUTED; + StatusEntryPtr->Status = SC_Status_EXECUTED; SC_OperData.HkPacket.Payload.AtsCmdCtr++; } else { /* the command had Software Bus problems */ - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] = SC_Status_FAILED_DISTRIB; + StatusEntryPtr->Status = SC_Status_FAILED_DISTRIB; SC_OperData.HkPacket.Payload.AtsCmdErrCtr++; SC_OperData.HkPacket.Payload.LastAtsErrSeq = SC_OperData.AtsCtrlBlckAddr->CurrAtsNum; SC_OperData.HkPacket.Payload.LastAtsErrCmd = SC_OperData.AtsCtrlBlckAddr->CmdNumber; @@ -200,7 +201,7 @@ void SC_ProcessAtpCmd(void) SC_OperData.HkPacket.Payload.LastAtsErrCmd = SC_OperData.AtsCtrlBlckAddr->CmdNumber; /* update the command status index table */ - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] = SC_Status_FAILED_CHECKSUM; + StatusEntryPtr->Status = SC_Status_FAILED_CHECKSUM; if (SC_OperData.HkPacket.Payload.ContinueAtsOnFailureFlag == false) { @@ -230,7 +231,7 @@ void SC_ProcessAtpCmd(void) SC_OperData.HkPacket.Payload.LastAtsErrCmd = SC_OperData.AtsCtrlBlckAddr->CmdNumber; /* update the command status index table */ - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] = SC_Status_SKIPPED; + StatusEntryPtr->Status = SC_Status_SKIPPED; /* Mark this ATS for abortion */ AbortATS = true; @@ -242,8 +243,8 @@ void SC_ProcessAtpCmd(void) ** Send an event message to report the invalid command status */ CFE_EVS_SendEvent(SC_ATS_SKP_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid ATS Command Status: Command Skipped, Status: %d", - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex]); + "Invalid ATS Command Status: Command Skipped, Status: %lu", + (unsigned long)StatusEntryPtr->Status); /* ** Increment the ATS error counter */ @@ -296,11 +297,12 @@ void SC_ProcessAtpCmd(void) void SC_ProcessRtpCommand(void) { - SC_RtsEntry_t * EntryPtr; /* a pointer to an RTS entry header */ - SC_RtsIndex_t RtsIndex; /* the RTS index for the cmd */ - SC_EntryOffset_t CmdOffset; /* the location of the cmd */ - CFE_Status_t Result; - bool ChecksumValid; + SC_RtsEntry_t * EntryPtr; /* a pointer to an RTS entry header */ + SC_RtsIndex_t RtsIndex; /* the RTS index for the cmd */ + SC_EntryOffset_t CmdOffset; /* the location of the cmd */ + CFE_Status_t Result; + bool ChecksumValid; + SC_RtsInfoEntry_t *RtsInfoPtr; /* ** The following conditions must be met before a RTS command is executed: @@ -312,10 +314,11 @@ void SC_ProcessRtpCommand(void) /* convert the RTS number so that it can be directly indexed into the table*/ RtsIndex = SC_RtsNumToIndex(SC_OperData.RtsCtrlBlckAddr->CurrRtsNum); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + if ((SC_AppData.NextCmdTime[SC_AppData.NextProcNumber] <= SC_AppData.CurrentTime) && (SC_AppData.NextProcNumber == SC_Process_RTP) && (SC_OperData.RtsCtrlBlckAddr->CurrRtsNum > 0) && - (SC_OperData.RtsCtrlBlckAddr->CurrRtsNum <= SC_NUMBER_OF_RTS) && - (SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_EXECUTING)) + (SC_OperData.RtsCtrlBlckAddr->CurrRtsNum <= SC_NUMBER_OF_RTS) && (RtsInfoPtr->RtsStatus == SC_Status_EXECUTING)) { /* ** Count the command for the rate limiter @@ -326,12 +329,12 @@ void SC_ProcessRtpCommand(void) /* ** Get the Command offset within the RTS */ - CmdOffset = SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr; + CmdOffset = RtsInfoPtr->NextCommandPtr; /* ** Get a pointer to the RTS entry using the RTS number and the offset */ - EntryPtr = (SC_RtsEntry_t *)&SC_OperData.RtsTblAddr[RtsIndex][CmdOffset]; + EntryPtr = SC_GetRtsEntryAtOffset(RtsIndex, CmdOffset); ChecksumValid = SC_AppData.EnableHeaderUpdate; if (!SC_AppData.EnableHeaderUpdate) @@ -351,7 +354,7 @@ void SC_ProcessRtpCommand(void) { /* the command was sent OK */ SC_OperData.HkPacket.Payload.RtsCmdCtr++; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr++; + RtsInfoPtr->CmdCtr++; /* ** Get the next command. @@ -369,7 +372,7 @@ void SC_ProcessRtpCommand(void) (int)SC_OperData.RtsCtrlBlckAddr->CurrRtsNum, (unsigned int)Result); SC_OperData.HkPacket.Payload.RtsCmdErrCtr++; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr++; + RtsInfoPtr->CmdErrCtr++; SC_OperData.HkPacket.Payload.LastRtsErrSeq = SC_OperData.RtsCtrlBlckAddr->CurrRtsNum; SC_OperData.HkPacket.Payload.LastRtsErrCmd = CmdOffset; @@ -393,7 +396,7 @@ void SC_ProcessRtpCommand(void) ** Update the RTS command error counter and last RTS error info */ SC_OperData.HkPacket.Payload.RtsCmdErrCtr++; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr++; + RtsInfoPtr->CmdErrCtr++; SC_OperData.HkPacket.Payload.LastRtsErrSeq = SC_OperData.RtsCtrlBlckAddr->CurrRtsNum; SC_OperData.HkPacket.Payload.LastRtsErrCmd = CmdOffset; @@ -412,17 +415,20 @@ void SC_ProcessRtpCommand(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_SendHkPacket(void) { - uint16 i; + uint16 i; + SC_AtsInfoTable_t *AtsInfoPtr; + SC_RtsInfoEntry_t *RtsInfoPtr; /* ** fill in the free bytes in each ATS */ - SC_OperData.HkPacket.Payload.AtpFreeBytes[SC_AtsNumToIndex(SC_AtsId_ATSA)] = - (SC_ATS_BUFF_SIZE32 * SC_BYTES_IN_WORD) - - (SC_OperData.AtsInfoTblAddr[SC_AtsNumToIndex(SC_AtsId_ATSA)].AtsSize * SC_BYTES_IN_WORD); - SC_OperData.HkPacket.Payload.AtpFreeBytes[SC_AtsNumToIndex(SC_AtsId_ATSB)] = - (SC_ATS_BUFF_SIZE32 * SC_BYTES_IN_WORD) - - (SC_OperData.AtsInfoTblAddr[SC_AtsNumToIndex(SC_AtsId_ATSB)].AtsSize * SC_BYTES_IN_WORD); + for (i = 0; i < SC_NUMBER_OF_ATS; ++i) + { + AtsInfoPtr = SC_GetAtsInfoObject(SC_ATS_IDX_C(i)); + + SC_OperData.HkPacket.Payload.AtpFreeBytes[i] = + (SC_ATS_BUFF_SIZE32 * SC_BYTES_IN_WORD) - (AtsInfoPtr->AtsSize * SC_BYTES_IN_WORD); + } /* ** @@ -459,12 +465,14 @@ void SC_SendHkPacket(void) for (i = 0; i < SC_NUMBER_OF_RTS; i++) { - if (SC_OperData.RtsInfoTblAddr[i].DisabledFlag == true) + RtsInfoPtr = SC_GetRtsInfoObject(SC_RTS_IDX_C(i)); + + if (RtsInfoPtr->DisabledFlag == true) { SC_OperData.HkPacket.Payload.RtsDisabledStatus[i / SC_NUMBER_OF_RTS_IN_UINT16] |= (1 << (i % SC_NUMBER_OF_RTS_IN_UINT16)); } - if (SC_OperData.RtsInfoTblAddr[i].RtsStatus == SC_Status_EXECUTING) + if (RtsInfoPtr->RtsStatus == SC_Status_EXECUTING) { SC_OperData.HkPacket.Payload.RtsExecutingStatus[i / SC_NUMBER_OF_RTS_IN_UINT16] |= (1 << (i % SC_NUMBER_OF_RTS_IN_UINT16)); @@ -483,13 +491,17 @@ void SC_SendHkPacket(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_SendHkCmd(const SC_SendHkCmd_t *Cmd) { + SC_RtsInfoEntry_t *RtsInfoPtr; + /* set during init to power on or processor reset auto-exec RTS */ if (SC_AppData.AutoStartRTS != 0) { + RtsInfoPtr = SC_GetRtsInfoObject(SC_RtsNumToIndex(SC_AppData.AutoStartRTS)); + /* make sure the selected auto-exec RTS is enabled */ - if (SC_OperData.RtsInfoTblAddr[SC_RtsNumToIndex(SC_AppData.AutoStartRTS)].RtsStatus == SC_Status_LOADED) + if (RtsInfoPtr->RtsStatus == SC_Status_LOADED) { - SC_OperData.RtsInfoTblAddr[SC_RtsNumToIndex(SC_AppData.AutoStartRTS)].DisabledFlag = false; + RtsInfoPtr->DisabledFlag = false; } /* send ground cmd to have SC start the RTS */ diff --git a/fsw/src/sc_loads.c b/fsw/src/sc_loads.c index eb1441c..c77d0de 100644 --- a/fsw/src/sc_loads.c +++ b/fsw/src/sc_loads.c @@ -51,14 +51,16 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_LoadAts(SC_AtsIndex_t AtsIndex) { - uint16 AtsEntryWords; /* current ats entry length in words */ - SC_CommandNum_t AtsCmdNum; /* current ats entry command number */ - SC_EntryOffset_t AtsEntryIndex; /* index into the load for current ats entry */ - SC_AtsEntry_t * EntryPtr; /* a pointer to an ats entry */ - uint32 * AtsTablePtr; /* pointer to the start of the Ats table */ - CFE_MSG_Size_t MessageSize = 0; - int32 Result = CFE_SUCCESS; - bool StillProcessing = true; + uint16 AtsEntryWords; /* current ats entry length in words */ + SC_CommandNum_t AtsCmdNum; /* current ats entry command number */ + SC_EntryOffset_t AtsEntryIndex; /* index into the load for current ats entry */ + SC_AtsEntry_t * EntryPtr; /* a pointer to an ats entry */ + CFE_MSG_Size_t MessageSize = 0; + int32 Result = CFE_SUCCESS; + bool StillProcessing = true; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; /* ATS entry location in table */ /* validate ATS array index */ if (AtsIndex >= SC_NUMBER_OF_ATS) @@ -74,8 +76,8 @@ void SC_LoadAts(SC_AtsIndex_t AtsIndex) SC_InitAtsTables(AtsIndex); /* initialize pointers and counters */ - AtsTablePtr = SC_OperData.AtsTblAddr[AtsIndex]; - AtsEntryIndex = 0; + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + AtsEntryIndex = SC_ENTRY_OFFSET_FIRST; while (StillProcessing) { @@ -86,7 +88,7 @@ void SC_LoadAts(SC_AtsIndex_t AtsIndex) if (AtsEntryIndex < SC_ATS_BUFF_SIZE32) { /* get a pointer to the ats command in the table */ - EntryPtr = (SC_AtsEntry_t *)&AtsTablePtr[AtsEntryIndex]; + EntryPtr = SC_GetAtsEntryAtOffset(AtsIndex, AtsEntryIndex); /* get the next command number from the buffer */ AtsCmdNum = EntryPtr->Header.CmdNumber; @@ -94,20 +96,29 @@ void SC_LoadAts(SC_AtsIndex_t AtsIndex) if (AtsCmdNum == 0) { /* end of the load reached */ - Result = CFE_SUCCESS; - StillProcessing = false; + Result = CFE_SUCCESS; + break; + } + + if (!SC_AtsCommandNumIsValid(AtsCmdNum)) + { + /* the cmd number is invalid */ + Result = SC_ERROR; + break; } /* make sure the CmdPtr can fit in a whole Ats Cmd Header at the very least */ - else if (AtsEntryIndex > (SC_ATS_BUFF_SIZE32 - SC_ATS_HDR_WORDS)) + if (AtsEntryIndex > (SC_ATS_BUFF_SIZE32 - SC_ATS_HDR_WORDS)) { /* even the smallest command will not fit in the buffer */ - Result = SC_ERROR; - StillProcessing = false; - } /* else if the cmd number is valid and the command */ - /* has not already been loaded */ - else if (AtsCmdNum <= SC_MAX_ATS_CMDS && - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][SC_CommandNumToIndex(AtsCmdNum)] == SC_Status_EMPTY) + Result = SC_ERROR; + break; + } + + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_CommandNumToIndex(AtsCmdNum)); + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_CommandNumToIndex(AtsCmdNum)); + + if (StatusEntryPtr->Status == SC_Status_EMPTY) { /* get message size */ CFE_MSG_GetSize(CFE_MSG_PTR(EntryPtr->Msg), &MessageSize); @@ -124,13 +135,13 @@ void SC_LoadAts(SC_AtsIndex_t AtsIndex) /* set the command pointer in the command index table */ /* CmdNum starts at one.... */ - SC_AppData.AtsCmdIndexBuffer[AtsIndex][SC_CommandNumToIndex(AtsCmdNum)] = AtsEntryIndex; + CmdOffsetRec->Offset = AtsEntryIndex; /* set the command status to loaded in the command status table */ - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][SC_CommandNumToIndex(AtsCmdNum)] = SC_Status_LOADED; + StatusEntryPtr->Status = SC_Status_LOADED; /* increment the number of commands loaded */ - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands++; + AtsInfoPtr->NumberOfCommands++; /* increment the ats_entry index to the next ats entry */ AtsEntryIndex = AtsEntryIndex + AtsEntryWords; @@ -174,10 +185,10 @@ void SC_LoadAts(SC_AtsIndex_t AtsIndex) ** if the load was a success, need to build the tables */ /* if the load finished without errors and there was at least one command */ - if ((Result == CFE_SUCCESS) && (SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands > 0)) + if ((Result == CFE_SUCCESS) && (AtsInfoPtr->NumberOfCommands > 0)) { /* record the size of the load in the ATS info table */ - SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize = AtsEntryIndex; /* size in 32-bit WORDS */ + AtsInfoPtr->AtsSize = AtsEntryIndex; /* size in 32-bit WORDS */ /* build the time index table */ SC_BuildTimeIndexTable(AtsIndex); @@ -195,8 +206,10 @@ void SC_LoadAts(SC_AtsIndex_t AtsIndex) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_BuildTimeIndexTable(SC_AtsIndex_t AtsIndex) { - int32 i; - int32 ListLength; + int32 i; + int32 ListLength; + SC_CommandIndex_t CmdIdx; + SC_AtsCmdNumRecord_t *AtsCmdNumRec; /* validate ATS array index */ if (AtsIndex >= SC_NUMBER_OF_ATS) @@ -212,12 +225,14 @@ void SC_BuildTimeIndexTable(SC_AtsIndex_t AtsIndex) /* initialize sorted list contents */ for (i = 0; i < SC_MAX_ATS_CMDS; i++) { - SC_AppData.AtsTimeIndexBuffer[AtsIndex][i] = SC_INVALID_CMD_NUMBER; + AtsCmdNumRec = SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_C(i)); + AtsCmdNumRec->CmdNum = SC_INVALID_CMD_NUMBER; /* add in-use command entries to time sorted list */ - if (SC_AppData.AtsCmdIndexBuffer[AtsIndex][i] != SC_ERROR) + CmdIdx = SC_COMMAND_IDX_C(i); + if (!SC_IDX_EQUAL(SC_GetAtsEntryOffsetForCmd(AtsIndex, CmdIdx)->Offset, SC_ENTRY_OFFSET_INVALID)) { - SC_Insert(AtsIndex, i, ListLength); + SC_Insert(AtsIndex, CmdIdx, ListLength); ListLength++; } } @@ -230,12 +245,14 @@ void SC_BuildTimeIndexTable(SC_AtsIndex_t AtsIndex) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_Insert(SC_AtsIndex_t AtsIndex, SC_CommandIndex_t NewCmdIndex, uint32 ListLength) { - SC_AtsEntryHeader_t *EntryHeader; /* ATS table entry pointer */ - SC_AbsTimeTag_t NewCmdTime = 0; /* new command execution time */ - SC_AbsTimeTag_t ListCmdTime; /* list entry execution time */ - SC_CommandIndex_t CmdIndex; /* ATS command index (cmd num - 1) */ - SC_EntryOffset_t EntryIndex; /* ATS entry location in table */ - SC_SeqIndex_t TimeBufIndex; /* this must be signed */ + SC_AtsEntryHeader_t * EntryHeader; /* ATS table entry pointer */ + SC_AbsTimeTag_t NewCmdTime = 0; /* new command execution time */ + SC_AbsTimeTag_t ListCmdTime; /* list entry execution time */ + SC_CommandIndex_t CmdIndex; /* ATS command index (cmd num - 1) */ + SC_SeqIndex_t TimeBufIndex; + SC_SeqIndex_t NextIndex; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; /* ATS entry location in table */ + SC_AtsCmdNumRecord_t * AtsCmdNumRec; /* validate ATS array index */ if (AtsIndex >= SC_NUMBER_OF_ATS) @@ -249,9 +266,9 @@ void SC_Insert(SC_AtsIndex_t AtsIndex, SC_CommandIndex_t NewCmdIndex, uint32 Lis if (ListLength > 0) { /* first get the entry index in the selected ATS table for the new command */ - EntryIndex = SC_AppData.AtsCmdIndexBuffer[AtsIndex][NewCmdIndex]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, NewCmdIndex); /* then get a pointer to the ATS entry */ - EntryHeader = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][EntryIndex]; + EntryHeader = &SC_GetAtsEntryAtOffset(AtsIndex, CmdOffsetRec->Offset)->Header; /* then get the execution time from the ATS entry for the new command */ NewCmdTime = SC_GetAtsEntryTime(EntryHeader); } @@ -262,11 +279,11 @@ void SC_Insert(SC_AtsIndex_t AtsIndex, SC_CommandIndex_t NewCmdIndex, uint32 Lis while (TimeBufIndex >= 0) { /* first get the cmd index for this list entry */ - CmdIndex = SC_CommandNumToIndex(SC_AppData.AtsTimeIndexBuffer[AtsIndex][TimeBufIndex]); + CmdIndex = SC_CommandNumToIndex(SC_GetAtsCommandNumAtSeq(AtsIndex, TimeBufIndex)->CmdNum); /* then get the entry index from the ATS table */ - EntryIndex = SC_AppData.AtsCmdIndexBuffer[AtsIndex][CmdIndex]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, CmdIndex); /* then get a pointer to the ATS entry data */ - EntryHeader = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][EntryIndex]; + EntryHeader = &SC_GetAtsEntryAtOffset(AtsIndex, CmdOffsetRec->Offset)->Header; /* then get cmd execution time from the ATS entry */ ListCmdTime = SC_GetAtsEntryTime(EntryHeader); @@ -276,8 +293,11 @@ void SC_Insert(SC_AtsIndex_t AtsIndex, SC_CommandIndex_t NewCmdIndex, uint32 Lis /* new cmd will execute before this list entry */ /* move this list entry to make room for new cmd */ - SC_AppData.AtsTimeIndexBuffer[AtsIndex][TimeBufIndex + 1] = - SC_AppData.AtsTimeIndexBuffer[AtsIndex][TimeBufIndex]; + NextIndex = TimeBufIndex; + SC_IDX_INCREMENT(NextIndex); + + SC_GetAtsCommandNumAtSeq(AtsIndex, NextIndex)->CmdNum = + SC_GetAtsCommandNumAtSeq(AtsIndex, TimeBufIndex)->CmdNum; /* back up to previous list entry (ok if -1) */ TimeBufIndex--; @@ -296,7 +316,10 @@ void SC_Insert(SC_AtsIndex_t AtsIndex, SC_CommandIndex_t NewCmdIndex, uint32 Lis ** else only entries with later times have been moved ** In either case, there is an empty slot next to TimeBufIndex */ - SC_AppData.AtsTimeIndexBuffer[AtsIndex][TimeBufIndex + 1] = SC_CommandIndexToNum(NewCmdIndex); + SC_IDX_INCREMENT(TimeBufIndex); + + AtsCmdNumRec = SC_GetAtsCommandNumAtSeq(AtsIndex, TimeBufIndex); + AtsCmdNumRec->CmdNum = SC_CommandIndexToNum(NewCmdIndex); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -306,7 +329,11 @@ void SC_Insert(SC_AtsIndex_t AtsIndex, SC_CommandIndex_t NewCmdIndex, uint32 Lis /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_InitAtsTables(SC_AtsIndex_t AtsIndex) { - int32 i; + int32 i; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + SC_AtsCmdNumRecord_t * AtsCmdNumRec; /* validate ATS array index */ if (AtsIndex >= SC_NUMBER_OF_ATS) @@ -319,14 +346,19 @@ void SC_InitAtsTables(SC_AtsIndex_t AtsIndex) /* loop through and set the ATS tables to zero */ for (i = 0; i < SC_MAX_ATS_CMDS; i++) { - SC_AppData.AtsCmdIndexBuffer[AtsIndex][i] = SC_ERROR; - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][i] = SC_Status_EMPTY; - SC_AppData.AtsTimeIndexBuffer[AtsIndex][i] = SC_INVALID_CMD_NUMBER; + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(i)); + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(i)); + AtsCmdNumRec = SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_C(i)); + + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_INVALID; + StatusEntryPtr->Status = SC_Status_EMPTY; + AtsCmdNumRec->CmdNum = SC_INVALID_CMD_NUMBER; } /* initialize the pointers and counters */ - SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize = 0; - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 0; + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + AtsInfoPtr->AtsSize = 0; + AtsInfoPtr->NumberOfCommands = 0; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -336,19 +368,23 @@ void SC_InitAtsTables(SC_AtsIndex_t AtsIndex) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_LoadRts(SC_RtsIndex_t RtsIndex) { + SC_RtsInfoEntry_t *RtsInfoPtr; + /* validate RTS array index */ if (RtsIndex < SC_NUMBER_OF_RTS) { /* Clear out the RTS info table */ - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_LOADED; - SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandTime = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr = 0; + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + + RtsInfoPtr->RtsStatus = SC_Status_LOADED; + RtsInfoPtr->UseCtr = 0; + RtsInfoPtr->CmdCtr = 0; + RtsInfoPtr->CmdErrCtr = 0; + RtsInfoPtr->NextCommandTime = 0; + RtsInfoPtr->NextCommandPtr = SC_ENTRY_OFFSET_FIRST; /* Make sure the RTS is disabled */ - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = true; + RtsInfoPtr->DisabledFlag = true; } else { @@ -598,12 +634,15 @@ void SC_UpdateAppend(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_ProcessAppend(SC_AtsIndex_t AtsIndex) { - SC_AtsEntry_t * EntryPtr; - CFE_MSG_Size_t CommandBytes = 0; - int32 CommandWords; - SC_EntryOffset_t EntryIndex; - int32 i; - SC_CommandIndex_t CmdIndex; + SC_AtsEntry_t * EntryPtr; + CFE_MSG_Size_t CommandBytes = 0; + int32 CommandWords; + SC_EntryOffset_t EntryIndex; + int32 i; + SC_CommandIndex_t CmdIndex; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; /* validate ATS array index */ if (AtsIndex >= SC_NUMBER_OF_ATS) @@ -614,33 +653,37 @@ void SC_ProcessAppend(SC_AtsIndex_t AtsIndex) } /* save index of free area at end of ATS table data */ - EntryIndex = SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize; + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + EntryIndex = SC_ENTRY_OFFSET_C(AtsInfoPtr->AtsSize); /* copy Append table data to end of ATS table data */ - memcpy(&SC_OperData.AtsTblAddr[AtsIndex][EntryIndex], SC_OperData.AppendTblAddr, + memcpy(SC_GetAtsEntryAtOffset(AtsIndex, EntryIndex), SC_OperData.AppendTblAddr, SC_AppData.AppendWordCount * SC_BYTES_IN_WORD); /* update size of ATS table data */ - SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize += SC_AppData.AppendWordCount; + AtsInfoPtr->AtsSize += SC_AppData.AppendWordCount; /* add appended entries to ats process tables */ for (i = 0; i < SC_OperData.HkPacket.Payload.AppendEntryCount; i++) { /* get pointer to next appended entry */ - EntryPtr = (SC_AtsEntry_t *)&SC_OperData.AtsTblAddr[AtsIndex][EntryIndex]; + EntryPtr = SC_GetAtsEntryAtOffset(AtsIndex, EntryIndex); /* convert base one cmd number to base zero index */ CmdIndex = SC_CommandNumToIndex(EntryPtr->Header.CmdNumber); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, CmdIndex); + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, CmdIndex); + /* count only new commands, not replaced commands */ - if (SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] == SC_Status_EMPTY) + if (StatusEntryPtr->Status == SC_Status_EMPTY) { - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands++; + AtsInfoPtr->NumberOfCommands++; } /* update array of pointers to ats entries */ - SC_AppData.AtsCmdIndexBuffer[AtsIndex][CmdIndex] = EntryIndex; - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] = SC_Status_LOADED; + CmdOffsetRec->Offset = EntryIndex; + StatusEntryPtr->Status = SC_Status_LOADED; /* update entry index to point to the next entry */ CFE_MSG_GetSize(CFE_MSG_PTR(EntryPtr->Msg), &CommandBytes); @@ -825,8 +868,8 @@ int32 SC_VerifyAtsEntry(uint32 *Buffer32, int32 EntryIndex, int32 BufferWords) Result = SC_ERROR; CFE_EVS_SendEvent(SC_VERIFY_ATS_DUP_ERR_EID, CFE_EVS_EventType_ERROR, - "Verify ATS Table error: dup cmd number: buf index = %d, cmd num = %d, dup index = %d", - (int)EntryIndex, EntryPtr->Header.CmdNumber, + "Verify ATS Table error: dup cmd number: buf index = %d, cmd num = %u, dup index = %d", + (int)EntryIndex, SC_IDNUM_AS_UINT(EntryPtr->Header.CmdNumber), (int)SC_OperData.AtsDupTestArray[SC_CommandNumToIndex(EntryPtr->Header.CmdNumber)]); } else diff --git a/fsw/src/sc_rtsrq.c b/fsw/src/sc_rtsrq.c index 34a5273..c12dc37 100644 --- a/fsw/src/sc_rtsrq.c +++ b/fsw/src/sc_rtsrq.c @@ -55,6 +55,7 @@ void SC_StartRtsCmd(const SC_StartRtsCmd_t *Cmd) SC_RtsEntryHeader_t *RtsEntryPtr; /* pointer to an rts entry */ CFE_MSG_Message_t * RtsEntryCmd; /* pointer to an rts command */ CFE_MSG_Size_t CmdLength = 0; /* the length of the 1st cmd */ + SC_RtsInfoEntry_t * RtsInfoPtr; /* ** Check start RTS parameters @@ -64,18 +65,19 @@ void SC_StartRtsCmd(const SC_StartRtsCmd_t *Cmd) if ((RtsNum > 0) && (RtsNum <= SC_NUMBER_OF_RTS)) { /* convert RTS ID to RTS array index */ - RtsIndex = SC_RtsNumToIndex(RtsNum); + RtsIndex = SC_RtsNumToIndex(RtsNum); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); /* make sure that RTS is not disabled */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false) + if (RtsInfoPtr->DisabledFlag == false) { /* the requested RTS is not being used and is not empty */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_LOADED) + if (RtsInfoPtr->RtsStatus == SC_Status_LOADED) { /* ** Check the command length */ - RtsEntryPtr = (SC_RtsEntryHeader_t *)SC_OperData.RtsTblAddr[RtsIndex]; + RtsEntryPtr = &SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST)->Header; RtsEntryCmd = (CFE_MSG_Message_t *)((uint8_t *)RtsEntryPtr + SC_RTS_HEADER_SIZE); CFE_MSG_GetSize(RtsEntryCmd, &CmdLength); @@ -86,18 +88,17 @@ void SC_StartRtsCmd(const SC_StartRtsCmd_t *Cmd) /* ** Initialize the RTS info table entry */ - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr++; + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr->CmdCtr = 0; + RtsInfoPtr->CmdErrCtr = 0; + RtsInfoPtr->NextCommandPtr = SC_ENTRY_OFFSET_FIRST; + RtsInfoPtr->UseCtr++; /* ** Get the absolute time for the RTSs next_cmd_time ** using the current time and the relative time tag. */ - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandTime = - SC_ComputeAbsTime(((SC_RtsEntryHeader_t *)SC_OperData.RtsTblAddr[RtsIndex])->TimeTag); + RtsInfoPtr->NextCommandTime = SC_ComputeAbsTime(RtsEntryPtr->TimeTag); /* ** Last, Increment some global counters associated with the @@ -135,7 +136,7 @@ void SC_StartRtsCmd(const SC_StartRtsCmd_t *Cmd) CFE_EVS_SendEvent(SC_STARTRTS_CMD_NOT_LDED_ERR_EID, CFE_EVS_EventType_ERROR, "Start RTS %03d Rejected: RTS Not Loaded or In Use, Status: %d", Cmd->Payload.RtsNum, - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus); + RtsInfoPtr->RtsStatus); SC_OperData.HkPacket.Payload.CmdErrCtr++; SC_OperData.HkPacket.Payload.RtsActiveErrCtr++; @@ -168,12 +169,13 @@ void SC_StartRtsCmd(const SC_StartRtsCmd_t *Cmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_StartRtsGrpCmd(const SC_StartRtsGrpCmd_t *Cmd) { - SC_RtsNum_t FirstRtsNum; - SC_RtsNum_t LastRtsNum; - SC_RtsIndex_t FirstIndex; /* RTS array index */ - SC_RtsIndex_t LastIndex; - SC_RtsIndex_t RtsIndex; - int32 StartCount = 0; + SC_RtsNum_t FirstRtsNum; + SC_RtsNum_t LastRtsNum; + SC_RtsIndex_t FirstIndex; /* RTS array index */ + SC_RtsIndex_t LastIndex; + SC_RtsIndex_t RtsIndex; + int32 StartCount = 0; + SC_RtsInfoEntry_t *RtsInfoPtr; FirstRtsNum = Cmd->Payload.FirstRtsNum; LastRtsNum = Cmd->Payload.LastRtsNum; @@ -188,21 +190,23 @@ void SC_StartRtsGrpCmd(const SC_StartRtsGrpCmd_t *Cmd) for (RtsIndex = FirstIndex; RtsIndex <= LastIndex; RtsIndex++) { + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + /* make sure that RTS is not disabled, empty or executing */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false) + if (RtsInfoPtr->DisabledFlag == false) { - if (SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_LOADED) + if (RtsInfoPtr->RtsStatus == SC_Status_LOADED) { /* initialize the RTS info table entry */ - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr++; + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr->CmdCtr = 0; + RtsInfoPtr->CmdErrCtr = 0; + RtsInfoPtr->NextCommandPtr = SC_ENTRY_OFFSET_FIRST; + RtsInfoPtr->UseCtr++; /* get absolute time for 1st cmd in the RTS */ - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandTime = - SC_ComputeAbsTime(((SC_RtsEntryHeader_t *)SC_OperData.RtsTblAddr[RtsIndex])->TimeTag); + RtsInfoPtr->NextCommandTime = + SC_ComputeAbsTime(SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST)->Header.TimeTag); /* maintain counters associated with starting RTS */ SC_OperData.RtsCtrlBlckAddr->NumRtsActive++; @@ -216,7 +220,7 @@ void SC_StartRtsGrpCmd(const SC_StartRtsGrpCmd_t *Cmd) CFE_EVS_SendEvent( SC_STARTRTSGRP_CMD_NOT_LDED_ERR_EID, CFE_EVS_EventType_ERROR, "Start RTS group error: rejected RTS ID %03d, RTS Not Loaded or In Use, Status: %d", - SC_RtsIndexToNum(RtsIndex), SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus); + SC_RtsIndexToNum(RtsIndex), RtsInfoPtr->RtsStatus); SC_OperData.HkPacket.Payload.RtsActiveErrCtr++; @@ -291,12 +295,13 @@ void SC_StopRtsCmd(const SC_StopRtsCmd_t *Cmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_StopRtsGrpCmd(const SC_StopRtsGrpCmd_t *Cmd) { - SC_RtsNum_t FirstRtsNum; - SC_RtsNum_t LastRtsNum; - SC_RtsIndex_t FirstIndex; /* RTS array index */ - SC_RtsIndex_t LastIndex; - SC_RtsIndex_t RtsIndex; - int32 StopCount = 0; + SC_RtsNum_t FirstRtsNum; + SC_RtsNum_t LastRtsNum; + SC_RtsIndex_t FirstIndex; /* RTS array index */ + SC_RtsIndex_t LastIndex; + SC_RtsIndex_t RtsIndex; + int32 StopCount = 0; + SC_RtsInfoEntry_t *RtsInfoPtr; FirstRtsNum = Cmd->Payload.FirstRtsNum; LastRtsNum = Cmd->Payload.LastRtsNum; @@ -311,8 +316,10 @@ void SC_StopRtsGrpCmd(const SC_StopRtsGrpCmd_t *Cmd) for (RtsIndex = FirstIndex; RtsIndex <= LastIndex; RtsIndex++) { + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + /* count the entries that were actually stopped */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_EXECUTING) + if (RtsInfoPtr->RtsStatus == SC_Status_EXECUTING) { SC_KillRts(RtsIndex); StopCount++; @@ -340,8 +347,9 @@ void SC_StopRtsGrpCmd(const SC_StopRtsGrpCmd_t *Cmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_DisableRtsCmd(const SC_DisableRtsCmd_t *Cmd) { - SC_RtsNum_t RtsNum; /* RTS number */ - SC_RtsIndex_t RtsIndex; /* RTS array index */ + SC_RtsNum_t RtsNum; /* RTS number */ + SC_RtsIndex_t RtsIndex; /* RTS array index */ + SC_RtsInfoEntry_t *RtsInfoPtr; RtsNum = Cmd->Payload.RtsNum; @@ -349,10 +357,11 @@ void SC_DisableRtsCmd(const SC_DisableRtsCmd_t *Cmd) if (RtsNum <= SC_NUMBER_OF_RTS) { /* convert RTS ID to RTS array index */ - RtsIndex = SC_RtsNumToIndex(RtsNum); + RtsIndex = SC_RtsNumToIndex(RtsNum); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); /* disable the RTS */ - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = true; + RtsInfoPtr->DisabledFlag = true; /* update the command status */ SC_OperData.HkPacket.Payload.CmdCtr++; @@ -376,12 +385,13 @@ void SC_DisableRtsCmd(const SC_DisableRtsCmd_t *Cmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_DisableRtsGrpCmd(const SC_DisableRtsGrpCmd_t *Cmd) { - SC_RtsNum_t FirstRtsNum; - SC_RtsNum_t LastRtsNum; - SC_RtsIndex_t FirstIndex; /* RTS array index */ - SC_RtsIndex_t LastIndex; - SC_RtsIndex_t RtsIndex; - int32 DisableCount = 0; + SC_RtsNum_t FirstRtsNum; + SC_RtsNum_t LastRtsNum; + SC_RtsIndex_t FirstIndex; /* RTS array index */ + SC_RtsIndex_t LastIndex; + SC_RtsIndex_t RtsIndex; + int32 DisableCount = 0; + SC_RtsInfoEntry_t *RtsInfoPtr; FirstRtsNum = Cmd->Payload.FirstRtsNum; LastRtsNum = Cmd->Payload.LastRtsNum; @@ -396,11 +406,13 @@ void SC_DisableRtsGrpCmd(const SC_DisableRtsGrpCmd_t *Cmd) for (RtsIndex = FirstIndex; RtsIndex <= LastIndex; RtsIndex++) { + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + /* count the entries that were actually disabled */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false) + if (RtsInfoPtr->DisabledFlag == false) { DisableCount++; - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = true; + RtsInfoPtr->DisabledFlag = true; } } @@ -425,8 +437,9 @@ void SC_DisableRtsGrpCmd(const SC_DisableRtsGrpCmd_t *Cmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_EnableRtsCmd(const SC_EnableRtsCmd_t *Cmd) { - SC_RtsNum_t RtsNum; /* RTS number */ - SC_RtsIndex_t RtsIndex; /* RTS array index */ + SC_RtsNum_t RtsNum; /* RTS number */ + SC_RtsIndex_t RtsIndex; /* RTS array index */ + SC_RtsInfoEntry_t *RtsInfoPtr; RtsNum = Cmd->Payload.RtsNum; @@ -434,10 +447,11 @@ void SC_EnableRtsCmd(const SC_EnableRtsCmd_t *Cmd) if ((RtsNum > 0) && (RtsNum <= SC_NUMBER_OF_RTS)) { /* convert RTS ID to RTS array index */ - RtsIndex = SC_RtsNumToIndex(RtsNum); + RtsIndex = SC_RtsNumToIndex(RtsNum); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); /* re-enable the RTS */ - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = false; + RtsInfoPtr->DisabledFlag = false; /* update the command status */ SC_OperData.HkPacket.Payload.CmdCtr++; @@ -462,12 +476,13 @@ void SC_EnableRtsCmd(const SC_EnableRtsCmd_t *Cmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_EnableRtsGrpCmd(const SC_EnableRtsGrpCmd_t *Cmd) { - SC_RtsNum_t FirstRtsNum; - SC_RtsNum_t LastRtsNum; - SC_RtsIndex_t FirstIndex; /* RTS array index */ - SC_RtsIndex_t LastIndex; - SC_RtsIndex_t RtsIndex; - int32 EnableCount = 0; + SC_RtsNum_t FirstRtsNum; + SC_RtsNum_t LastRtsNum; + SC_RtsIndex_t FirstIndex; /* RTS array index */ + SC_RtsIndex_t LastIndex; + SC_RtsIndex_t RtsIndex; + int32 EnableCount = 0; + SC_RtsInfoEntry_t *RtsInfoPtr; FirstRtsNum = Cmd->Payload.FirstRtsNum; LastRtsNum = Cmd->Payload.LastRtsNum; @@ -482,11 +497,13 @@ void SC_EnableRtsGrpCmd(const SC_EnableRtsGrpCmd_t *Cmd) for (RtsIndex = FirstIndex; RtsIndex <= LastIndex; RtsIndex++) { + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + /* count the entries that were actually enabled */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == true) + if (RtsInfoPtr->DisabledFlag == true) { EnableCount++; - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = false; + RtsInfoPtr->DisabledFlag = false; } } @@ -511,25 +528,29 @@ void SC_EnableRtsGrpCmd(const SC_EnableRtsGrpCmd_t *Cmd) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_KillRts(SC_RtsIndex_t RtsIndex) { + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + /* validate RTS array index */ if (RtsIndex >= SC_NUMBER_OF_RTS) { CFE_EVS_SendEvent(SC_KILLRTS_INV_INDEX_ERR_EID, CFE_EVS_EventType_ERROR, "RTS kill error: invalid RTS index %d", RtsIndex); } - else if (SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_EXECUTING) + else if (RtsInfoPtr->RtsStatus == SC_Status_EXECUTING) { /* - ** Stop the RTS from executing - */ - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_LOADED; - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandTime = SC_MAX_TIME; + ** Stop the RTS from executing + */ + RtsInfoPtr->RtsStatus = SC_Status_LOADED; + RtsInfoPtr->NextCommandTime = SC_MAX_TIME; /* - ** Note: the rest of the fields are left alone - ** to provide information on where the - ** rts stopped. They are cleared out when it is restarted. - */ + ** Note: the rest of the fields are left alone + ** to provide information on where the + ** rts stopped. They are cleared out when it is restarted. + */ if (SC_OperData.RtsCtrlBlckAddr->NumRtsActive > 0) { diff --git a/fsw/src/sc_state.c b/fsw/src/sc_state.c index 5db0cab..02fd216 100644 --- a/fsw/src/sc_state.c +++ b/fsw/src/sc_state.c @@ -57,9 +57,10 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_GetNextRtsTime(void) { - int16 i; /* loop counter MUST be SIGNED !*/ - SC_RtsIndex_t NextRts; /* the next rts to schedule */ - SC_AbsTimeTag_t NextTime; /* the next time for the RTS */ + int16 i; /* loop counter MUST be SIGNED !*/ + SC_RtsIndex_t NextRts; /* the next rts to schedule */ + SC_AbsTimeTag_t NextTime; /* the next time for the RTS */ + SC_RtsInfoEntry_t *RtsInfoPtr; NextRts = SC_INVALID_RTS_INDEX; NextTime = SC_MAX_TIME; @@ -72,11 +73,12 @@ void SC_GetNextRtsTime(void) */ for (i = SC_NUMBER_OF_RTS - 1; i >= 0; i--) { - if (SC_OperData.RtsInfoTblAddr[i].RtsStatus == SC_Status_EXECUTING) + RtsInfoPtr = SC_GetRtsInfoObject(SC_RTS_IDX_C(i)); + if (RtsInfoPtr->RtsStatus == SC_Status_EXECUTING) { - if (SC_OperData.RtsInfoTblAddr[i].NextCommandTime <= NextTime) + if (RtsInfoPtr->NextCommandTime <= NextTime) { - NextTime = SC_OperData.RtsInfoTblAddr[i].NextCommandTime; + NextTime = RtsInfoPtr->NextCommandTime; NextRts = SC_RTS_IDX_C(i); } /* end if */ } /* end if */ @@ -89,7 +91,7 @@ void SC_GetNextRtsTime(void) } else { - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = NextRts + 1; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(NextRts); SC_AppData.NextCmdTime[SC_Process_RTP] = NextTime; } /* end if */ } @@ -144,10 +146,11 @@ void SC_UpdateNextTime(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_GetNextRtsCommand(void) { - SC_RtsIndex_t RtsIndex; - SC_EntryOffset_t CmdOffset; - SC_RtsEntry_t * EntryPtr; - CFE_MSG_Size_t CmdLength = 0; + SC_RtsIndex_t RtsIndex; + SC_EntryOffset_t CmdOffset; + SC_RtsEntry_t * EntryPtr; + CFE_MSG_Size_t CmdLength = 0; + SC_RtsInfoEntry_t *RtsInfoPtr; /* ** Make sure that the RTP is executing some RTS @@ -156,17 +159,18 @@ void SC_GetNextRtsCommand(void) if ((SC_OperData.RtsCtrlBlckAddr->CurrRtsNum > 0) && (SC_OperData.RtsCtrlBlckAddr->CurrRtsNum <= SC_NUMBER_OF_RTS)) { /* Get the index of the rts that is running */ - RtsIndex = SC_RtsNumToIndex(SC_OperData.RtsCtrlBlckAddr->CurrRtsNum); + RtsIndex = SC_RtsNumToIndex(SC_OperData.RtsCtrlBlckAddr->CurrRtsNum); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); /* ** Find out if the RTS is EXECUTING or just STARTED */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_EXECUTING) + if (RtsInfoPtr->RtsStatus == SC_Status_EXECUTING) { /* ** Get the information needed to find the next command */ - CmdOffset = SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr; - EntryPtr = (SC_RtsEntry_t *)&SC_OperData.RtsTblAddr[RtsIndex][CmdOffset]; + CmdOffset = RtsInfoPtr->NextCommandPtr; + EntryPtr = SC_GetRtsEntryAtOffset(RtsIndex, CmdOffset); CFE_MSG_GetSize(CFE_MSG_PTR(EntryPtr->Msg), &CmdLength); CmdLength += SC_RTS_HEADER_SIZE; @@ -191,7 +195,7 @@ void SC_GetNextRtsCommand(void) /* ** Get the next RTS command */ - EntryPtr = (SC_RtsEntry_t *)&SC_OperData.RtsTblAddr[RtsIndex][CmdOffset]; + EntryPtr = SC_GetRtsEntryAtOffset(RtsIndex, CmdOffset); /* ** get the length of the new command @@ -223,13 +227,12 @@ void SC_GetNextRtsCommand(void) ** Everything passed! ** Update the proper next command time for that RTS */ - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandTime = - SC_ComputeAbsTime(EntryPtr->Header.TimeTag); + RtsInfoPtr->NextCommandTime = SC_ComputeAbsTime(EntryPtr->Header.TimeTag); /* ** Update the appropriate RTS info table current command pointer */ - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr = CmdOffset; + RtsInfoPtr->NextCommandPtr = CmdOffset; } else { /* the command runs past the end of the buffer */ @@ -239,7 +242,7 @@ void SC_GetNextRtsCommand(void) ** is an error condition, so record it */ SC_OperData.HkPacket.Payload.RtsCmdErrCtr++; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr++; + RtsInfoPtr->CmdErrCtr++; SC_OperData.HkPacket.Payload.LastRtsErrSeq = SC_OperData.RtsCtrlBlckAddr->CurrRtsNum; SC_OperData.HkPacket.Payload.LastRtsErrCmd = CmdOffset; @@ -258,7 +261,7 @@ void SC_GetNextRtsCommand(void) /* update the error information */ SC_OperData.HkPacket.Payload.RtsCmdErrCtr++; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr++; + RtsInfoPtr->CmdErrCtr++; SC_OperData.HkPacket.Payload.LastRtsErrSeq = SC_OperData.RtsCtrlBlckAddr->CurrRtsNum; SC_OperData.HkPacket.Payload.LastRtsErrCmd = CmdOffset; @@ -310,32 +313,40 @@ void SC_GetNextRtsCommand(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_GetNextAtsCommand(void) { - SC_AtsIndex_t AtsIndex; /* ats array index */ - SC_SeqIndex_t TimeIndex; /* a time index pointer */ - SC_EntryOffset_t CmdIndex; /* ats command array index */ - SC_AtsEntry_t * EntryPtr; + SC_AtsIndex_t AtsIndex; /* ats array index */ + SC_SeqIndex_t TimeIndex; /* a time index pointer */ + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + SC_AtsEntry_t * EntryPtr; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdNumRecord_t * AtsCmdNumRec; + SC_CommandIndex_t CurrCmdIndex; if (SC_OperData.AtsCtrlBlckAddr->AtpState == SC_Status_EXECUTING) { /* ** Get the information that is needed to find the next command */ - AtsIndex = SC_AtsNumToIndex(SC_OperData.AtsCtrlBlckAddr->CurrAtsNum); - TimeIndex = SC_OperData.AtsCtrlBlckAddr->TimeIndexPtr + 1; + AtsIndex = SC_AtsNumToIndex(SC_OperData.AtsCtrlBlckAddr->CurrAtsNum); + TimeIndex = SC_OperData.AtsCtrlBlckAddr->TimeIndexPtr + 1; + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); /* ** Check to see if there are more ATS commands */ - if (TimeIndex < SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands) + if (TimeIndex < AtsInfoPtr->NumberOfCommands) { /* get the information for the next command in the ATP control block */ + AtsCmdNumRec = SC_GetAtsCommandNumAtSeq(AtsIndex, TimeIndex); + CurrCmdIndex = SC_CommandNumToIndex(AtsCmdNumRec->CmdNum); + SC_OperData.AtsCtrlBlckAddr->TimeIndexPtr = TimeIndex; - SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_AppData.AtsTimeIndexBuffer[AtsIndex][TimeIndex]; + SC_OperData.AtsCtrlBlckAddr->CmdNumber = AtsCmdNumRec->CmdNum; /* update the next command time */ - CmdIndex = - SC_AppData.AtsCmdIndexBuffer[AtsIndex][SC_CommandNumToIndex(SC_OperData.AtsCtrlBlckAddr->CmdNumber)]; - EntryPtr = (SC_AtsEntry_t *)&SC_OperData.AtsTblAddr[AtsIndex][CmdIndex]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, CurrCmdIndex); + + EntryPtr = SC_GetAtsEntryAtOffset(AtsIndex, CmdOffsetRec->Offset); + SC_AppData.NextCmdTime[SC_Process_ATP] = SC_GetAtsEntryTime(&EntryPtr->Header); } else diff --git a/unit-test/sc_atsrq_tests.c b/unit-test/sc_atsrq_tests.c index 8a9f3b3..31c35ad 100644 --- a/unit-test/sc_atsrq_tests.c +++ b/unit-test/sc_atsrq_tests.c @@ -66,14 +66,20 @@ CFE_TIME_Compare_t UT_SC_StartAtsRq_CompareHook3(void *UserObj, int32 StubRetcod void SC_StartAtsCmd_Test_NominalA(void) { - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdNumRecord_t *AtsCmdNumRec; + + AtsCmdNumRec = SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_FIRST); + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_CmdBuf.StartAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.AtsInfoTblAddr[0].NumberOfCommands = 1; - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_IDLE; + UT_CmdBuf.StartAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); + AtsInfoPtr->NumberOfCommands = 1; + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_IDLE; + AtsCmdNumRec->CmdNum = SC_COMMAND_NUM_C(1); /* Execute the function being tested */ UtAssert_VOIDCALL(SC_StartAtsCmd(&UT_CmdBuf.StartAtsCmd)); @@ -89,14 +95,20 @@ void SC_StartAtsCmd_Test_NominalA(void) void SC_StartAtsCmd_Test_NominalB(void) { - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdNumRecord_t *AtsCmdNumRec; + + AtsCmdNumRec = SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_FIRST); + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_CmdBuf.StartAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.AtsInfoTblAddr[1].NumberOfCommands = 1; - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_IDLE; + UT_CmdBuf.StartAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); + AtsInfoPtr->NumberOfCommands = 1; + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_IDLE; + AtsCmdNumRec->CmdNum = SC_COMMAND_NUM_C(1); /* Execute the function being tested */ UtAssert_VOIDCALL(SC_StartAtsCmd(&UT_CmdBuf.StartAtsCmd)); @@ -112,18 +124,21 @@ void SC_StartAtsCmd_Test_NominalB(void) void SC_StartAtsCmd_Test_CouldNotStart(void) { - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_START_ATS_CC; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_START_ATS_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t *AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); UT_SetDeferredRetcode(UT_KEY(SC_CompareAbsTime), 1, true); - UT_CmdBuf.StartAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.AtsInfoTblAddr[0].NumberOfCommands = 1; - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_IDLE; + UT_CmdBuf.StartAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); + AtsInfoPtr->NumberOfCommands = 1; + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_IDLE; /* Set to cause SC_BeginAts to return false, in order to reach block starting with "could not start the ats" */ UT_SetHookFunction(UT_KEY(CFE_TIME_Compare), UT_SC_StartAtsRq_CompareHookAgreaterthanB, NULL); @@ -140,16 +155,19 @@ void SC_StartAtsCmd_Test_CouldNotStart(void) void SC_StartAtsCmd_Test_NoCommandsA(void) { - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_START_ATS_CC; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_START_ATS_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t *AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_CmdBuf.StartAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.AtsInfoTblAddr[0].NumberOfCommands = 0; - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_IDLE; + UT_CmdBuf.StartAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); + AtsInfoPtr->NumberOfCommands = 0; + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_IDLE; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_StartAtsCmd(&UT_CmdBuf.StartAtsCmd)); @@ -163,16 +181,19 @@ void SC_StartAtsCmd_Test_NoCommandsA(void) void SC_StartAtsCmd_Test_NoCommandsB(void) { - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_START_ATS_CC; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_START_ATS_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_AtsInfoTable_t *AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_CmdBuf.StartAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.AtsInfoTblAddr[1].NumberOfCommands = 0; - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_IDLE; + UT_CmdBuf.StartAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); + AtsInfoPtr->NumberOfCommands = 0; + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_IDLE; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_StartAtsCmd(&UT_CmdBuf.StartAtsCmd)); @@ -309,18 +330,23 @@ void SC_StopAtsCmd_Test_NoRunningAts(void) void SC_BeginAts_Test_Nominal(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - uint16 TimeOffset = 0; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + uint16 TimeOffset = 0; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdNumRecord_t *AtsCmdNumRec; + + AtsCmdNumRec = SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_FIRST); + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); - SC_OperData.AtsInfoTblAddr[0].NumberOfCommands = 1; + AtsInfoPtr->NumberOfCommands = 1; + AtsCmdNumRec->CmdNum = SC_COMMAND_NUM_C(1); /* Execute the function being tested */ UtAssert_BOOL_TRUE(SC_BeginAts(AtsIndex, TimeOffset)); /* Verify results */ SC_Assert_ID_VALUE(SC_OperData.AtsCtrlBlckAddr->CurrAtsNum, 1); - UtAssert_True(SC_OperData.AtsCtrlBlckAddr->CmdNumber == SC_AppData.AtsTimeIndexBuffer[AtsIndex][0], - "SC_OperData.AtsCtrlBlckAddr->CmdNumber == SC_AppData.AtsTimeIndexBuffer[AtsIndex][0]"); + SC_Assert_ID_EQ(SC_OperData.AtsCtrlBlckAddr->CmdNumber, AtsCmdNumRec->CmdNum); SC_Assert_IDX_VALUE(SC_OperData.AtsCtrlBlckAddr->TimeIndexPtr, 0); UtAssert_True(SC_AppData.NextCmdTime[SC_Process_ATP] == 0, "SC_AppData.NextCmdTime[SC_Process_ATP] == 0"); @@ -330,13 +356,21 @@ void SC_BeginAts_Test_Nominal(void) void SC_BeginAts_Test_AllCommandsSkipped(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - uint16 TimeOffset = 0; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + uint16 TimeOffset = 0; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t *StatusEntryPtr; + SC_AtsCmdNumRecord_t * AtsCmdNumRec; + + AtsCmdNumRec = SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_FIRST); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDeferredRetcode(UT_KEY(SC_CompareAbsTime), 1, true); - SC_AppData.AtsTimeIndexBuffer[0][0] = 1; - SC_OperData.AtsInfoTblAddr[0].NumberOfCommands = 1; + AtsCmdNumRec->CmdNum = SC_COMMAND_NUM_C(1); + AtsInfoPtr->NumberOfCommands = 1; /* Set to cause all commnds to be skipped, to generate error message SC_ATS_SKP_ALL_ERR_EID */ UT_SetHookFunction(UT_KEY(CFE_TIME_Compare), UT_SC_StartAtsRq_CompareHookAgreaterthanB, NULL); @@ -345,9 +379,7 @@ void SC_BeginAts_Test_AllCommandsSkipped(void) UtAssert_BOOL_FALSE(SC_BeginAts(AtsIndex, TimeOffset)); /* Verify results */ - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_SKIPPED, - "SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_SKIPPED"); - + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_SKIPPED); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_ATS_SKP_ALL_ERR_EID); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } @@ -367,7 +399,10 @@ void SC_BeginAts_Test_InvalidAtsIndex(void) void SC_KillAts_Test(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t *AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); SC_OperData.AtsCtrlBlckAddr->AtpState = (SC_Status_Enum_t)99; @@ -376,7 +411,7 @@ void SC_KillAts_Test(void) UtAssert_VOIDCALL(SC_KillAts()); /* Verify results */ - UtAssert_True(SC_OperData.AtsInfoTblAddr[0].AtsUseCtr == 1, "SC_OperData.AtsInfoTblAddr[0].AtsUseCtr == 1"); + UtAssert_UINT32_EQ(AtsInfoPtr->AtsUseCtr, 1); UtAssert_True(SC_OperData.AtsCtrlBlckAddr->AtpState == SC_Status_IDLE, "SC_OperData.AtsCtrlBlckAddr->AtpState == SC_Status_IDLE"); UtAssert_True(SC_AppData.NextCmdTime[SC_Process_ATP] == SC_MAX_TIME, @@ -387,14 +422,17 @@ void SC_KillAts_Test(void) void SC_SwitchAtsCmd_Test_Nominal(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_ONEHZ_WAKEUP_MID); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_ONEHZ_WAKEUP_MID); + SC_AtsInfoTable_t *AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - SC_OperData.AtsInfoTblAddr[1].NumberOfCommands = 1; + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + AtsInfoPtr->NumberOfCommands = 1; UT_SetDeferredRetcode(UT_KEY(SC_ToggleAtsIndex), 1, 1); @@ -412,14 +450,17 @@ void SC_SwitchAtsCmd_Test_Nominal(void) void SC_SwitchAtsCmd_Test_DestinationAtsNotLoaded(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_ONEHZ_WAKEUP_MID); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_ONEHZ_WAKEUP_MID); + SC_AtsInfoTable_t *AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - SC_OperData.AtsInfoTblAddr[1].NumberOfCommands = 0; + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + AtsInfoPtr->NumberOfCommands = 0; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_SwitchAtsCmd(&UT_CmdBuf.SwitchAtsCmd)); @@ -456,8 +497,11 @@ void SC_SwitchAtsCmd_Test_AtpIdle(void) void SC_ServiceSwitchPend_Test_NominalA(void) { - SC_AtsIndex_t AtsIndex0 = SC_ATS_IDX_C(0); - SC_AtsIndex_t AtsIndex1 = SC_ATS_IDX_C(1); + SC_AtsIndex_t AtsIndex0 = SC_ATS_IDX_C(0); + SC_AtsIndex_t AtsIndex1 = SC_ATS_IDX_C(1); + SC_AtsCmdNumRecord_t *AtsCmdNumRec; + + AtsCmdNumRec = SC_GetAtsCommandNumAtSeq(AtsIndex1, SC_SEQUENCE_IDX_FIRST); UT_SetDeferredRetcode(UT_KEY(SC_CompareAbsTime), 1, true); @@ -465,11 +509,11 @@ void SC_ServiceSwitchPend_Test_NominalA(void) UT_SC_StartAtsRq_CompareHookRunCount = 0; UT_SetHookFunction(UT_KEY(CFE_TIME_Compare), UT_SC_StartAtsRq_CompareHook3, NULL); - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(1); - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - SC_OperData.AtsInfoTblAddr[AtsIndex0].NumberOfCommands = 1; - SC_OperData.AtsInfoTblAddr[AtsIndex1].NumberOfCommands = 1; - SC_AppData.AtsTimeIndexBuffer[AtsIndex1][0] = 1; + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(1); + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + SC_GetAtsInfoObject(AtsIndex0)->NumberOfCommands = 1; + SC_GetAtsInfoObject(AtsIndex1)->NumberOfCommands = 1; + AtsCmdNumRec->CmdNum = SC_COMMAND_NUM_C(1); UT_SetDeferredRetcode(UT_KEY(SC_ToggleAtsIndex), 1, 1); @@ -488,8 +532,11 @@ void SC_ServiceSwitchPend_Test_NominalA(void) void SC_ServiceSwitchPend_Test_NominalB(void) { - SC_AtsIndex_t AtsIndex0 = SC_ATS_IDX_C(0); - SC_AtsIndex_t AtsIndex1 = SC_ATS_IDX_C(1); + SC_AtsIndex_t AtsIndex0 = SC_ATS_IDX_C(0); + SC_AtsIndex_t AtsIndex1 = SC_ATS_IDX_C(1); + SC_AtsCmdNumRecord_t *AtsCmdNumRec; + + AtsCmdNumRec = SC_GetAtsCommandNumAtSeq(AtsIndex0, SC_SEQUENCE_IDX_FIRST); UT_SetDeferredRetcode(UT_KEY(SC_CompareAbsTime), 1, true); @@ -497,11 +544,11 @@ void SC_ServiceSwitchPend_Test_NominalB(void) UT_SC_StartAtsRq_CompareHookRunCount = 0; UT_SetHookFunction(UT_KEY(CFE_TIME_Compare), UT_SC_StartAtsRq_CompareHook3, NULL); - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(2); - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - SC_OperData.AtsInfoTblAddr[AtsIndex0].NumberOfCommands = 1; - SC_OperData.AtsInfoTblAddr[AtsIndex1].NumberOfCommands = 1; - SC_AppData.AtsTimeIndexBuffer[AtsIndex0][0] = 1; + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(2); + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + SC_GetAtsInfoObject(AtsIndex0)->NumberOfCommands = 1; + SC_GetAtsInfoObject(AtsIndex1)->NumberOfCommands = 1; + AtsCmdNumRec->CmdNum = SC_COMMAND_NUM_C(1); UT_SetDeferredRetcode(UT_KEY(SC_ToggleAtsIndex), 1, 0); @@ -526,10 +573,8 @@ void SC_ServiceSwitchPend_Test_AtsEmpty(void) UT_SC_StartAtsRq_CompareHookRunCount = 0; UT_SetHookFunction(UT_KEY(CFE_TIME_Compare), UT_SC_StartAtsRq_CompareHook3, NULL); - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(1); - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - SC_OperData.AtsInfoTblAddr[0].NumberOfCommands = 0; - SC_OperData.AtsInfoTblAddr[1].NumberOfCommands = 0; + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(1); + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_ServiceSwitchPend()); @@ -593,10 +638,10 @@ void SC_ServiceSwitchPend_Test_AtsNotStarted(void) UT_SC_StartAtsRq_CompareHookRunCount = 0; UT_SetHookFunction(UT_KEY(CFE_TIME_Compare), UT_SC_StartAtsRq_CompareHook3, NULL); - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(1); - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - SC_OperData.AtsInfoTblAddr[AtsIndex0].NumberOfCommands = 1; - SC_OperData.AtsInfoTblAddr[AtsIndex1].NumberOfCommands = 1; + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(1); + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + SC_GetAtsInfoObject(AtsIndex0)->NumberOfCommands = 1; + SC_GetAtsInfoObject(AtsIndex1)->NumberOfCommands = 1; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_ServiceSwitchPend()); @@ -613,17 +658,20 @@ void SC_ServiceSwitchPend_Test_AtsNotStarted(void) void SC_InlineSwitch_Test_NominalA(void) { - SC_AtsIndex_t AtsIndex0 = SC_ATS_IDX_C(0); - SC_AtsIndex_t AtsIndex1 = SC_ATS_IDX_C(1); + SC_AtsIndex_t AtsIndex0 = SC_ATS_IDX_C(0); + SC_AtsIndex_t AtsIndex1 = SC_ATS_IDX_C(1); + SC_AtsCmdNumRecord_t *AtsCmdNumRec; + + AtsCmdNumRec = SC_GetAtsCommandNumAtSeq(AtsIndex1, SC_SEQUENCE_IDX_FIRST); /* Set to satisfy first if-statement, while not affecting later calls to CFE_TIME_Compare */ UT_SC_StartAtsRq_CompareHookRunCount = 0; UT_SetHookFunction(UT_KEY(CFE_TIME_Compare), UT_SC_StartAtsRq_CompareHook3, NULL); - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(1); - SC_OperData.AtsInfoTblAddr[AtsIndex0].NumberOfCommands = 1; - SC_OperData.AtsInfoTblAddr[AtsIndex1].NumberOfCommands = 1; - SC_AppData.AtsTimeIndexBuffer[AtsIndex1][0] = 1; + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(1); + SC_GetAtsInfoObject(AtsIndex0)->NumberOfCommands = 1; + SC_GetAtsInfoObject(AtsIndex1)->NumberOfCommands = 1; + AtsCmdNumRec->CmdNum = SC_COMMAND_NUM_C(1); UT_SetDeferredRetcode(UT_KEY(SC_ToggleAtsIndex), 1, 1); @@ -644,17 +692,20 @@ void SC_InlineSwitch_Test_NominalA(void) void SC_InlineSwitch_Test_NominalB(void) { - SC_AtsIndex_t AtsIndex0 = SC_ATS_IDX_C(0); - SC_AtsIndex_t AtsIndex1 = SC_ATS_IDX_C(1); + SC_AtsIndex_t AtsIndex0 = SC_ATS_IDX_C(0); + SC_AtsIndex_t AtsIndex1 = SC_ATS_IDX_C(1); + SC_AtsCmdNumRecord_t *AtsCmdNumRec; + + AtsCmdNumRec = SC_GetAtsCommandNumAtSeq(AtsIndex0, SC_SEQUENCE_IDX_FIRST); /* Set to satisfy first if-statement, while not affecting later calls to CFE_TIME_Compare */ UT_SC_StartAtsRq_CompareHookRunCount = 0; UT_SetHookFunction(UT_KEY(CFE_TIME_Compare), UT_SC_StartAtsRq_CompareHook3, NULL); - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(2); - SC_OperData.AtsInfoTblAddr[AtsIndex0].NumberOfCommands = 1; - SC_OperData.AtsInfoTblAddr[AtsIndex1].NumberOfCommands = 1; - SC_AppData.AtsTimeIndexBuffer[AtsIndex0][0] = 1; + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(2); + SC_GetAtsInfoObject(AtsIndex0)->NumberOfCommands = 1; + SC_GetAtsInfoObject(AtsIndex1)->NumberOfCommands = 1; + AtsCmdNumRec->CmdNum = SC_COMMAND_NUM_C(1); UT_SetDeferredRetcode(UT_KEY(SC_ToggleAtsIndex), 1, 0); @@ -684,9 +735,9 @@ void SC_InlineSwitch_Test_AllCommandsSkipped(void) * were skipped" */ UT_SetHookFunction(UT_KEY(CFE_TIME_Compare), UT_SC_StartAtsRq_CompareHookAgreaterthanB, NULL); - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(1); - SC_OperData.AtsInfoTblAddr[AtsIndex0].NumberOfCommands = 1; - SC_OperData.AtsInfoTblAddr[AtsIndex1].NumberOfCommands = 1; + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(1); + SC_GetAtsInfoObject(AtsIndex0)->NumberOfCommands = 1; + SC_GetAtsInfoObject(AtsIndex1)->NumberOfCommands = 1; /* Execute the function being tested */ UtAssert_BOOL_FALSE(SC_InlineSwitch()); @@ -720,9 +771,17 @@ void SC_InlineSwitch_Test_DestinationAtsNotLoaded(void) void SC_JumpAtsCmd_Test_SkipOneCmd(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_JUMP_ATS_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_JUMP_ATS_CC; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t *StatusPtr0; + SC_AtsCmdStatusEntry_t *StatusPtr1; + + StatusPtr0 = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusPtr1 = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(1)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(SC_JumpAtsCmd_t), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); @@ -733,25 +792,24 @@ void SC_JumpAtsCmd_Test_SkipOneCmd(void) UT_SC_StartAtsRq_CompareHookRunCount = 0; UT_SetHookFunction(UT_KEY(CFE_TIME_Compare), UT_SC_StartAtsRq_CompareHook3, NULL); - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0] = SC_Status_LOADED; - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][1] = SC_Status_LOADED; - SC_AppData.AtsTimeIndexBuffer[AtsIndex][0] = 1; - SC_AppData.AtsTimeIndexBuffer[AtsIndex][1] = 2; - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(2); - SC_OperData.AtsInfoTblAddr[0].NumberOfCommands = 2; + StatusPtr0->Status = SC_Status_LOADED; + StatusPtr1->Status = SC_Status_LOADED; + SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_C(0))->CmdNum = SC_COMMAND_NUM_C(1); + SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_C(1))->CmdNum = SC_COMMAND_NUM_C(2); + + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(2); + AtsInfoPtr->NumberOfCommands = 2; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_JumpAtsCmd(&UT_CmdBuf.JumpAtsCmd)); /* Verify results */ - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0] == SC_Status_SKIPPED, - "SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0] == SC_Status_SKIPPED"); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][1] == SC_Status_LOADED, - "SC_OperData.AtsCmdStatusTblAddr[AtsIndex][1] == SC_Status_LOADED"); - UtAssert_True(SC_OperData.AtsCtrlBlckAddr->CmdNumber == SC_AppData.AtsTimeIndexBuffer[AtsIndex][1], - "SC_OperData.AtsCtrlBlckAddr->CmdNumber == SC_AppData.AtsTimeIndexBuffer[AtsIndex][0]"); + SC_Assert_CmdStatus(StatusPtr0->Status, SC_Status_SKIPPED); + SC_Assert_CmdStatus(StatusPtr1->Status, SC_Status_LOADED); + SC_Assert_ID_EQ(SC_OperData.AtsCtrlBlckAddr->CmdNumber, + SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_C(1))->CmdNum); SC_Assert_IDX_VALUE(SC_OperData.AtsCtrlBlckAddr->TimeIndexPtr, 1); UtAssert_True(SC_AppData.NextCmdTime[0] == 0, "SC_AppData.NextCmdTime[0] == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 1, "SC_OperData.HkPacket.Payload.CmdCtr == 1"); @@ -763,9 +821,14 @@ void SC_JumpAtsCmd_Test_SkipOneCmd(void) void SC_JumpAtsCmd_Test_AllCommandsSkipped(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_JUMP_ATS_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_JUMP_ATS_CC; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t *StatusEntryPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(SC_JumpAtsCmd_t), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); @@ -776,10 +839,10 @@ void SC_JumpAtsCmd_Test_AllCommandsSkipped(void) UT_SC_StartAtsRq_CompareHookRunCount = 0; UT_SetHookFunction(UT_KEY(CFE_TIME_Compare), UT_SC_StartAtsRq_CompareHook3, NULL); - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0] = SC_Status_LOADED; - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - SC_OperData.AtsInfoTblAddr[0].NumberOfCommands = 1; + StatusEntryPtr->Status = SC_Status_LOADED; + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + AtsInfoPtr->NumberOfCommands = 1; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_JumpAtsCmd(&UT_CmdBuf.JumpAtsCmd)); @@ -813,9 +876,16 @@ void SC_JumpAtsCmd_Test_NoRunningAts(void) void SC_JumpAtsCmd_Test_AtsNotLoaded(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_JUMP_ATS_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_JUMP_ATS_CC; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t *StatusPtr0; + SC_AtsCmdStatusEntry_t *StatusPtr1; + + StatusPtr0 = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusPtr1 = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(1)); + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(SC_JumpAtsCmd_t), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); @@ -826,22 +896,24 @@ void SC_JumpAtsCmd_Test_AtsNotLoaded(void) UT_SC_StartAtsRq_CompareHookRunCount = 0; UT_SetHookFunction(UT_KEY(CFE_TIME_Compare), UT_SC_StartAtsRq_CompareHook3, NULL); - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0] = SC_Status_SKIPPED; - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][1] = SC_Status_SKIPPED; - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - SC_OperData.AtsInfoTblAddr[0].NumberOfCommands = 2; + StatusPtr0->Status = SC_Status_SKIPPED; + StatusPtr1->Status = SC_Status_SKIPPED; + + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + AtsInfoPtr->NumberOfCommands = 2; + + SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_C(0))->CmdNum = SC_COMMAND_NUM_C(1); + SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_C(1))->CmdNum = SC_COMMAND_NUM_C(2); /* Execute the function being tested */ UtAssert_VOIDCALL(SC_JumpAtsCmd(&UT_CmdBuf.JumpAtsCmd)); /* Verify results */ - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0] == SC_Status_SKIPPED, - "SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0] == SC_Status_SKIPPED"); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][1] == SC_Status_SKIPPED, - "SC_OperData.AtsCmdStatusTblAddr[AtsIndex][1] == SC_Status_SKIPPED"); - UtAssert_True(SC_OperData.AtsCtrlBlckAddr->CmdNumber == SC_AppData.AtsTimeIndexBuffer[AtsIndex][0], - "SC_OperData.AtsCtrlBlckAddr->CmdNumber == SC_AppData.AtsTimeIndexBuffer[AtsIndex][0]"); + SC_Assert_CmdStatus(StatusPtr0->Status, SC_Status_SKIPPED); + SC_Assert_CmdStatus(StatusPtr1->Status, SC_Status_SKIPPED); + SC_Assert_ID_EQ(SC_OperData.AtsCtrlBlckAddr->CmdNumber, + SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_C(1))->CmdNum); SC_Assert_IDX_VALUE(SC_OperData.AtsCtrlBlckAddr->TimeIndexPtr, 1); UtAssert_True(SC_AppData.NextCmdTime[0] == 0, "SC_AppData.NextCmdTime[0] == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.CmdCtr == 1, "SC_OperData.HkPacket.Payload.CmdCtr == 1"); @@ -919,16 +991,19 @@ void SC_AppendAtsCmd_Test_Nominal(void) SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); CFE_MSG_FcnCode_t FcnCode = SC_APPEND_ATS_CC; + SC_AtsInfoTable_t * AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(SC_AppendAtsCmd_t), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); - UT_CmdBuf.AppendAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; - SC_OperData.HkPacket.Payload.AppendEntryCount = 1; + UT_CmdBuf.AppendAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); + AtsInfoPtr->NumberOfCommands = 1; + SC_OperData.HkPacket.Payload.AppendEntryCount = 1; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_AppendAtsCmd(&UT_CmdBuf.AppendAtsCmd)); @@ -985,16 +1060,19 @@ void SC_AppendAtsCmd_Test_InvalidAtsNumZero(void) void SC_AppendAtsCmd_Test_AtsTableEmpty(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_APPEND_ATS_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_APPEND_ATS_CC; + SC_AtsInfoTable_t *AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(SC_AppendAtsCmd_t), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_CmdBuf.AppendAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.HkPacket.Payload.AppendEntryCount = 1; - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 0; + UT_CmdBuf.AppendAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); + SC_OperData.HkPacket.Payload.AppendEntryCount = 1; + AtsInfoPtr->NumberOfCommands = 0; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_AppendAtsCmd(&UT_CmdBuf.AppendAtsCmd)); @@ -1008,16 +1086,19 @@ void SC_AppendAtsCmd_Test_AtsTableEmpty(void) void SC_AppendAtsCmd_Test_AppendTableEmpty(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_APPEND_ATS_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_APPEND_ATS_CC; + SC_AtsInfoTable_t *AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(SC_AppendAtsCmd_t), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_CmdBuf.AppendAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.HkPacket.Payload.AppendEntryCount = 0; - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; + UT_CmdBuf.AppendAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); + SC_OperData.HkPacket.Payload.AppendEntryCount = 0; + AtsInfoPtr->NumberOfCommands = 1; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_AppendAtsCmd(&UT_CmdBuf.AppendAtsCmd)); @@ -1031,18 +1112,21 @@ void SC_AppendAtsCmd_Test_AppendTableEmpty(void) void SC_AppendAtsCmd_Test_NoRoomForAppendInAts(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_APPEND_ATS_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_APPEND_ATS_CC; + SC_AtsInfoTable_t *AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(SC_AppendAtsCmd_t), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_CmdBuf.AppendAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); - SC_OperData.HkPacket.Payload.AppendEntryCount = 1; - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; - SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize = SC_ATS_BUFF_SIZE; - SC_AppData.AppendWordCount = SC_ATS_BUFF_SIZE; + UT_CmdBuf.AppendAtsCmd.Payload.AtsNum = SC_AtsIndexToNum(AtsIndex); + SC_OperData.HkPacket.Payload.AppendEntryCount = 1; + AtsInfoPtr->NumberOfCommands = 1; + AtsInfoPtr->AtsSize = SC_ATS_BUFF_SIZE; + SC_AppData.AppendWordCount = SC_ATS_BUFF_SIZE; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_AppendAtsCmd(&UT_CmdBuf.AppendAtsCmd)); diff --git a/unit-test/sc_cmds_tests.c b/unit-test/sc_cmds_tests.c index e7751e1..3a8d196 100644 --- a/unit-test/sc_cmds_tests.c +++ b/unit-test/sc_cmds_tests.c @@ -61,12 +61,17 @@ int32 Ut_SC_UpdateNextTimeHook(void *UserObj, int32 StubRetcode, uint32 CallCoun void SC_ProcessAtpCmd_Test_SwitchCmd(void) { - SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextProcNumber = SC_Process_ATP; @@ -75,8 +80,8 @@ void SC_ProcessAtpCmd_Test_SwitchCmd(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCmdStatusTblAddr[0][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; SC_AppData.EnableHeaderUpdate = true; @@ -98,20 +103,23 @@ void SC_ProcessAtpCmd_Test_SwitchCmd(void) UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 1"); UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 0, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 0"); UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_EXECUTED, - "SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_EXECUTED"); - + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EXECUTED); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_ProcessAtpCmd_Test_NonSwitchCmd(void) { - SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextProcNumber = SC_Process_ATP; @@ -120,8 +128,8 @@ void SC_ProcessAtpCmd_Test_NonSwitchCmd(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCmdStatusTblAddr[0][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; SC_AppData.EnableHeaderUpdate = true; @@ -143,20 +151,23 @@ void SC_ProcessAtpCmd_Test_NonSwitchCmd(void) UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 1"); UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 0, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 0"); UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_EXECUTED, - "SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_EXECUTED"); - + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EXECUTED); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_ProcessAtpCmd_Test_InlineSwitchError(void) { - SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextProcNumber = SC_Process_ATP; @@ -165,8 +176,8 @@ void SC_ProcessAtpCmd_Test_InlineSwitchError(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCmdStatusTblAddr[0][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; /* Set return value for CFE_TIME_Compare to make SC_CompareAbsTime return false, to satisfy first if-statement of * SC_ProcessAtpCmd, and for all other calls to CFE_TIME_Compare called from subfunctions reached by this test */ @@ -189,8 +200,7 @@ void SC_ProcessAtpCmd_Test_InlineSwitchError(void) UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 0, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1"); UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_FAILED_DISTRIB, - "SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_FAILED_DISTRIB"); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_FAILED_DISTRIB); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrSeq, 1); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrCmd, 1); @@ -199,12 +209,17 @@ void SC_ProcessAtpCmd_Test_InlineSwitchError(void) void SC_ProcessAtpCmd_Test_SBErrorAtsA(void) { - SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextCmdTime[SC_Process_ATP] = 0; @@ -215,8 +230,8 @@ void SC_ProcessAtpCmd_Test_SBErrorAtsA(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCmdStatusTblAddr[0][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; SC_AppData.EnableHeaderUpdate = true; @@ -235,8 +250,7 @@ void SC_ProcessAtpCmd_Test_SBErrorAtsA(void) UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 0, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1"); UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_FAILED_DISTRIB, - "SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_FAILED_DISTRIB"); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_FAILED_DISTRIB); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrSeq, SC_AtsId_ATSA); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrCmd, 1); @@ -247,12 +261,17 @@ void SC_ProcessAtpCmd_Test_SBErrorAtsA(void) void SC_ProcessAtpCmd_Test_SBErrorAtsB(void) { - SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_AtsEntryHeader_t * Entry; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_NOOP_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextCmdTime[SC_Process_ATP] = 0; @@ -263,8 +282,8 @@ void SC_ProcessAtpCmd_Test_SBErrorAtsB(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSB); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCmdStatusTblAddr[1][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[1][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; SC_AppData.EnableHeaderUpdate = true; @@ -283,8 +302,7 @@ void SC_ProcessAtpCmd_Test_SBErrorAtsB(void) UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 0, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1"); UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[1][0] == SC_Status_FAILED_DISTRIB, - "SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_FAILED_DISTRIB"); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_FAILED_DISTRIB); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrSeq, SC_AtsId_ATSB); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrCmd, 1); @@ -295,13 +313,18 @@ void SC_ProcessAtpCmd_Test_SBErrorAtsB(void) void SC_ProcessAtpCmd_Test_ChecksumFailedAtsA(void) { - SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; - bool ChecksumValid; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; + bool ChecksumValid; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextCmdTime[SC_Process_ATP] = 0; @@ -312,8 +335,8 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsA(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCmdStatusTblAddr[0][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; SC_OperData.HkPacket.Payload.ContinueAtsOnFailureFlag = false; @@ -338,9 +361,7 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsA(void) UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1"); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrSeq, SC_AtsId_ATSA); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrCmd, 1); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_FAILED_CHECKSUM, - "SC_OperData.AtsCmdStatusTblAddr[1][0] == SC_Status_FAILED_CHECKSUM"); - + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_FAILED_CHECKSUM); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_ATS_CHKSUM_ERR_EID); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, SC_ATS_ABT_ERR_EID); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); @@ -348,13 +369,18 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsA(void) void SC_ProcessAtpCmd_Test_ChecksumFailedAtsB(void) { - SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; - bool ChecksumValid; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_AtsEntryHeader_t * Entry; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; + bool ChecksumValid; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextCmdTime[SC_Process_ATP] = 0; @@ -365,8 +391,8 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsB(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSB); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCmdStatusTblAddr[1][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[1][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; SC_OperData.HkPacket.Payload.ContinueAtsOnFailureFlag = false; @@ -391,9 +417,7 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsB(void) UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1"); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrSeq, SC_AtsId_ATSB); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrCmd, 1); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[1][0] == SC_Status_FAILED_CHECKSUM, - "SC_OperData.AtsCmdStatusTblAddr[1][0] == SC_Status_FAILED_CHECKSUM"); - + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_FAILED_CHECKSUM); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_ATS_CHKSUM_ERR_EID); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, SC_ATS_ABT_ERR_EID); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); @@ -401,13 +425,18 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsB(void) void SC_ProcessAtpCmd_Test_ChecksumFailedAtsAContinue(void) { - SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); - CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; - bool ChecksumValid; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID); + CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; + bool ChecksumValid; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextCmdTime[SC_Process_ATP] = 0; @@ -418,8 +447,8 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsAContinue(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCmdStatusTblAddr[0][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; SC_OperData.HkPacket.Payload.ContinueAtsOnFailureFlag = SC_AtsCont_TRUE; @@ -444,31 +473,34 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsAContinue(void) UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1"); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrSeq, SC_AtsId_ATSA); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrCmd, 1); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_FAILED_CHECKSUM, - "SC_OperData.AtsCmdStatusTblAddr[1][0] == SC_Status_FAILED_CHECKSUM"); - + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_FAILED_CHECKSUM); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_ATS_CHKSUM_ERR_EID); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } void SC_ProcessAtpCmd_Test_CmdNumberMismatchAtsA(void) { - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; - Entry->CmdNumber = SC_COMMAND_NUM_C(3); + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); - SC_AppData.NextCmdTime[SC_Process_ATP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); + Entry->CmdNumber = SC_COMMAND_NUM_C(3); + SC_AppData.NextCmdTime[SC_Process_ATP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_ATP; + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCmdStatusTblAddr[0][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_ProcessAtpCmd()); @@ -478,9 +510,7 @@ void SC_ProcessAtpCmd_Test_CmdNumberMismatchAtsA(void) UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1"); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrSeq, SC_AtsId_ATSA); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrCmd, 1); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_SKIPPED, - "SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_SKIPPED"); - + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_SKIPPED); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_ATS_MSMTCH_ERR_EID); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, SC_ATS_ABT_ERR_EID); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); @@ -488,10 +518,15 @@ void SC_ProcessAtpCmd_Test_CmdNumberMismatchAtsA(void) void SC_ProcessAtpCmd_Test_CmdNumberMismatchAtsB(void) { - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_AtsEntryHeader_t * Entry; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(3); SC_AppData.NextCmdTime[SC_Process_ATP] = 0; @@ -502,8 +537,8 @@ void SC_ProcessAtpCmd_Test_CmdNumberMismatchAtsB(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSB); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCmdStatusTblAddr[1][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[1][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_ProcessAtpCmd()); @@ -513,9 +548,7 @@ void SC_ProcessAtpCmd_Test_CmdNumberMismatchAtsB(void) UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdErrCtr == 1"); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrSeq, SC_AtsId_ATSB); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastAtsErrCmd, 1); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[1][0] == SC_Status_SKIPPED, - "SC_OperData.AtsCmdStatusTblAddr[1][0] == SC_Status_SKIPPED"); - + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_SKIPPED); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_ATS_MSMTCH_ERR_EID); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, SC_ATS_ABT_ERR_EID); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); @@ -523,10 +556,12 @@ void SC_ProcessAtpCmd_Test_CmdNumberMismatchAtsB(void) void SC_ProcessAtpCmd_Test_CmdNotLoaded(void) { - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextCmdTime[SC_Process_ATP] = 0; @@ -537,7 +572,7 @@ void SC_ProcessAtpCmd_Test_CmdNotLoaded(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_ProcessAtpCmd()); @@ -553,10 +588,13 @@ void SC_ProcessAtpCmd_Test_CmdNotLoaded(void) void SC_ProcessAtpCmd_Test_CompareAbsTime(void) { - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextCmdTime[SC_Process_ATP] = 0; @@ -567,7 +605,7 @@ void SC_ProcessAtpCmd_Test_CompareAbsTime(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; UT_SetDeferredRetcode(UT_KEY(SC_CompareAbsTime), 1, true); @@ -582,10 +620,12 @@ void SC_ProcessAtpCmd_Test_CompareAbsTime(void) void SC_ProcessAtpCmd_Test_NextProcNumber(void) { - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextCmdTime[SC_Process_ATP] = 0; @@ -595,8 +635,7 @@ void SC_ProcessAtpCmd_Test_NextProcNumber(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_ProcessAtpCmd()); @@ -609,10 +648,12 @@ void SC_ProcessAtpCmd_Test_NextProcNumber(void) void SC_ProcessAtpCmd_Test_AtpState(void) { - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextCmdTime[SC_Process_ATP] = 0; @@ -623,7 +664,7 @@ void SC_ProcessAtpCmd_Test_AtpState(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(SC_AtsId_ATSA); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_ProcessAtpCmd()); @@ -636,12 +677,17 @@ void SC_ProcessAtpCmd_Test_AtpState(void) void SC_ProcessAtpCmd_Test_CmdMid(void) { - SC_AtsEntryHeader_t *Entry; - CFE_SB_MsgId_t TestMsgId = CFE_SB_INVALID_MSG_ID; - CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + CFE_SB_MsgId_t TestMsgId = CFE_SB_INVALID_MSG_ID; + CFE_MSG_FcnCode_t FcnCode = SC_SWITCH_ATS_CC; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextProcNumber = SC_Process_ATP; @@ -650,8 +696,8 @@ void SC_ProcessAtpCmd_Test_CmdMid(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCmdStatusTblAddr[0][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; SC_AppData.EnableHeaderUpdate = true; @@ -672,21 +718,22 @@ void SC_ProcessAtpCmd_Test_CmdMid(void) /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.AtsCmdCtr == 1, "SC_OperData.HkPacket.Payload.AtsCmdCtr == 1"); UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); - UtAssert_True(SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_EXECUTED, - "SC_OperData.AtsCmdStatusTblAddr[0][0] == SC_Status_EXECUTED"); - + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EXECUTED); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_ProcessRtpCommand_Test_Nominal(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; SC_AppData.EnableHeaderUpdate = true; @@ -697,21 +744,24 @@ void SC_ProcessRtpCommand_Test_Nominal(void) UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdCtr == 1, "SC_OperData.HkPacket.Payload.RtsCmdCtr == 1"); UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 0, "SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 0"); UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[0].CmdCtr == 1, "SC_OperData.RtsInfoTblAddr[0].CmdCtr == 1"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[0].CmdErrCtr == 0, "SC_OperData.RtsInfoTblAddr[0].CmdErrCtr == 0"); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdCtr, 1); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdErrCtr, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_ProcessRtpCommand_Test_BadSoftwareBusReturn(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; SC_AppData.EnableHeaderUpdate = true; @@ -725,8 +775,8 @@ void SC_ProcessRtpCommand_Test_BadSoftwareBusReturn(void) UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdCtr == 0, "SC_OperData.HkPacket.Payload.RtsCmdCtr == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 1"); UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[0].CmdCtr == 0, "SC_OperData.RtsInfoTblAddr[0].CmdCtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[0].CmdErrCtr == 1, "SC_OperData.RtsInfoTblAddr[0].CmdErrCtr == 1"); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdCtr, 0); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdErrCtr, 1); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastRtsErrSeq, 1); SC_Assert_IDX_VALUE(SC_OperData.HkPacket.Payload.LastRtsErrCmd, 0); @@ -736,14 +786,17 @@ void SC_ProcessRtpCommand_Test_BadSoftwareBusReturn(void) void SC_ProcessRtpCommand_Test_BadChecksum(void) { - bool ChecksumValid; - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + bool ChecksumValid; + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; SC_AppData.EnableHeaderUpdate = false; @@ -758,8 +811,8 @@ void SC_ProcessRtpCommand_Test_BadChecksum(void) UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdCtr == 0, "SC_OperData.HkPacket.Payload.RtsCmdCtr == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 1"); UtAssert_True(SC_OperData.NumCmdsSec == 1, "SC_OperData.NumCmdsSec == 1"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[0].CmdCtr == 0, "SC_OperData.RtsInfoTblAddr[0].CmdCtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[0].CmdErrCtr == 1, "SC_OperData.RtsInfoTblAddr[0].CmdErrCtr == 1"); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdCtr, 0); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdErrCtr, 1); SC_Assert_ID_VALUE(SC_OperData.HkPacket.Payload.LastRtsErrSeq, 1); SC_Assert_IDX_VALUE(SC_OperData.HkPacket.Payload.LastRtsErrCmd, 0); @@ -769,13 +822,16 @@ void SC_ProcessRtpCommand_Test_BadChecksum(void) void SC_ProcessRtpCommand_Test_NextCmdTime(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - SC_AppData.NextCmdTime[SC_Process_RTP] = 1; - SC_AppData.CurrentTime = 0; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; + SC_AppData.NextCmdTime[SC_Process_RTP] = 1; + SC_AppData.CurrentTime = 0; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_ProcessRtpCommand()); @@ -786,13 +842,16 @@ void SC_ProcessRtpCommand_Test_NextCmdTime(void) void SC_ProcessRtpCommand_Test_ProcNumber(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_NONE; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_NONE; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_ProcessRtpCommand()); @@ -831,13 +890,16 @@ void SC_ProcessRtpCommand_Test_RtsNumHigh(void) void SC_ProcessRtpCommand_Test_RtsStatus(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EMPTY; + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EMPTY; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_ProcessRtpCommand()); @@ -848,9 +910,11 @@ void SC_ProcessRtpCommand_Test_RtsStatus(void) void SC_SendHkPacket_Test(void) { - uint8 i; - int32 LastRtsHkIndex = 0; - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_NUMBER_OF_RTS - 1); + uint8 i; + int32 LastRtsHkIndex = 0; + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_NUMBER_OF_RTS - 1); + SC_RtsInfoEntry_t *RtsInfoPtr; + SC_AtsInfoTable_t *AtsInfoPtr; SC_OperData.HkPacket.Payload.CmdErrCtr = 1; SC_OperData.HkPacket.Payload.CmdCtr = 2; @@ -868,8 +932,6 @@ void SC_SendHkPacket_Test(void) SC_OperData.HkPacket.Payload.AppendEntryCount = 14; SC_AppData.AppendWordCount = 15; SC_OperData.HkPacket.Payload.AppendLoadCount = 16; - SC_OperData.AtsInfoTblAddr[0].AtsSize = 0; - SC_OperData.AtsInfoTblAddr[1].AtsSize = 0; SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(17); SC_OperData.AtsCtrlBlckAddr->AtpState = (SC_Status_Enum_t)18; SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(19); @@ -878,16 +940,27 @@ void SC_SendHkPacket_Test(void) SC_AppData.NextCmdTime[1] = 0; SC_OperData.RtsCtrlBlckAddr->NumRtsActive = 20; SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RTS_NUM_C(21); - SC_OperData.HkPacket.Payload.ContinueAtsOnFailureFlag = 1; + SC_OperData.HkPacket.Payload.ContinueAtsOnFailureFlag = SC_AtsCont_TRUE; + + for (i = 0; i < SC_NUMBER_OF_ATS - 1; i++) + { + AtsInfoPtr = SC_GetAtsInfoObject(SC_ATS_IDX_C(i)); + + AtsInfoPtr->AtsSize = 0; + } for (i = 0; i < SC_NUMBER_OF_RTS - 1; i++) { - SC_OperData.RtsInfoTblAddr[i].DisabledFlag = true; - SC_OperData.RtsInfoTblAddr[i].RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr = SC_GetRtsInfoObject(SC_RTS_IDX_C(i)); + + RtsInfoPtr->DisabledFlag = true; + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; } - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = 0; + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + + RtsInfoPtr->DisabledFlag = false; + RtsInfoPtr->RtsStatus = SC_Status_EMPTY; LastRtsHkIndex = sizeof(SC_OperData.HkPacket.Payload.RtsExecutingStatus) / sizeof(SC_OperData.HkPacket.Payload.RtsExecutingStatus[0]) - @@ -916,15 +989,13 @@ void SC_SendHkPacket_Test(void) UtAssert_True(SC_OperData.HkPacket.Payload.AppendLoadCount == 16, "SC_OperData.HkPacket.Payload.AppendLoadCount == 16"); UtAssert_True(SC_OperData.HkPacket.Payload.AtpFreeBytes[0] == - (SC_ATS_BUFF_SIZE32 * SC_BYTES_IN_WORD) - - (SC_OperData.AtsInfoTblAddr[0].AtsSize * SC_BYTES_IN_WORD), + (SC_ATS_BUFF_SIZE32 * SC_BYTES_IN_WORD) - (SC_GetAtsInfoObject(0)->AtsSize * SC_BYTES_IN_WORD), "SC_OperData.HkPacket.Payload.AtpFreeBytes[0] == (SC_ATS_BUFF_SIZE32 * SC_BYTES_IN_WORD)"); UtAssert_True(SC_OperData.HkPacket.Payload.AtpFreeBytes[1] == - (SC_ATS_BUFF_SIZE32 * SC_BYTES_IN_WORD) - - (SC_OperData.AtsInfoTblAddr[1].AtsSize * SC_BYTES_IN_WORD), + (SC_ATS_BUFF_SIZE32 * SC_BYTES_IN_WORD) - (SC_GetAtsInfoObject(1)->AtsSize * SC_BYTES_IN_WORD), "SC_OperData.HkPacket.Payload.AtpFreeBytes[1] == (SC_ATS_BUFF_SIZE32 * SC_BYTES_IN_WORD)"); UtAssert_UINT8_EQ(SC_OperData.HkPacket.Payload.CurrAtsId, 17); - UtAssert_True(SC_OperData.HkPacket.Payload.AtpState == 18, "SC_OperData.HkPacket.Payload.AtpState == 18"); + SC_Assert_CmdStatus(SC_OperData.HkPacket.Payload.AtpState, 18); UtAssert_UINT32_EQ(SC_OperData.HkPacket.Payload.AtpCmdNumber, 19); UtAssert_True(SC_OperData.HkPacket.Payload.SwitchPendFlag == 0, "SC_OperData.HkPacket.Payload.SwitchPendFlag == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.NextAtsTime == 0, "SC_OperData.HkPacket.Payload.NextAtsTime == 0"); @@ -963,7 +1034,10 @@ void SC_ProcessRequest_Test_HkMID(void) void SC_ProcessRequest_Test_HkMIDAutoStartRts(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); SC_AppData.AutoStartRTS = SC_RtsIndexToNum(RtsIndex); @@ -972,25 +1046,28 @@ void SC_ProcessRequest_Test_HkMIDAutoStartRts(void) /* Verify results */ SC_Assert_ID_VALUE(SC_AppData.AutoStartRTS, 0); - UtAssert_BOOL_FALSE(SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag); + UtAssert_BOOL_FALSE(RtsInfoPtr->DisabledFlag); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_ProcessRequest_Test_HkMIDAutoStartRtsLoaded(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); SC_AppData.AutoStartRTS = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_LOADED; + RtsInfoPtr->RtsStatus = SC_Status_LOADED; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_SendHkCmd(&UT_CmdBuf.SendHkCmd)); /* Verify results */ SC_Assert_ID_VALUE(SC_AppData.AutoStartRTS, 0); - UtAssert_BOOL_FALSE(SC_OperData.RtsInfoTblAddr[SC_AppData.AutoStartRTS].DisabledFlag); + UtAssert_BOOL_FALSE(RtsInfoPtr->DisabledFlag); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } @@ -1044,8 +1121,14 @@ void SC_ProcessRequest_Test_OneHzWakeupAtpNotExecutionTime(void) void SC_ProcessRequest_Test_OneHzWakeupRtpExecutionTime(void) { - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); /* required to exit processing loop after 2 iterations */ /* second iteration tests "IsThereAnotherCommandToExecute" */ @@ -1053,7 +1136,7 @@ void SC_ProcessRequest_Test_OneHzWakeupRtpExecutionTime(void) SC_CMDS_TEST_SC_UpdateNextTimeHook_RunCount = 0; UT_SetHookFunction(UT_KEY(SC_UpdateNextTime), Ut_SC_UpdateNextTimeHook, NULL); - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextProcNumber = SC_Process_RTP; @@ -1064,8 +1147,8 @@ void SC_ProcessRequest_Test_OneHzWakeupRtpExecutionTime(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCmdStatusTblAddr[0][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_OneHzWakeupCmd(&UT_CmdBuf.OneHzWakeupCmd)); @@ -1212,7 +1295,7 @@ void SC_ProcessCommand_Test_TableManageAtsTableNominal(void) SC_AtsEntryHeader_t *Entry; SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(0); UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_ATS_0; @@ -1246,7 +1329,7 @@ void SC_ProcessCommand_Test_TableManageAtsTableID(void) SC_AtsEntryHeader_t *Entry; SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(0); /* test TableID >= SC_TBL_ID_ATS_0 */ @@ -1278,7 +1361,7 @@ void SC_ProcessCommand_Test_TableManageAtsTableGetAddressNeverLoaded(void) SC_AtsEntryHeader_t *Entry; SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(0); UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_ATS_0; @@ -1303,7 +1386,7 @@ void SC_ProcessCommand_Test_TableManageAtsTableGetAddressSuccess(void) SC_AtsEntryHeader_t *Entry; SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][0]; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(0); UT_CmdBuf.ManageTableCmd.Payload.Parameter = SC_TBL_ID_ATS_0; diff --git a/unit-test/sc_loads_tests.c b/unit-test/sc_loads_tests.c index 39fa973..34a5b82 100644 --- a/unit-test/sc_loads_tests.c +++ b/unit-test/sc_loads_tests.c @@ -41,6 +41,9 @@ #define UT_SC_NOMINAL_CMD_SIZE (SC_PACKET_MAX_SIZE / 2) +static const SC_SeqIndex_t UT_SEQ_INDEX_0 = SC_IDX_FROM_UINT(0); +static const SC_SeqIndex_t UT_SEQ_INDEX_1 = SC_IDX_FROM_UINT(1); + /* * Function Definitions */ @@ -284,7 +287,15 @@ SC_RtsEntryHeader_t *UT_SC_SetupRtsTable(SC_RtsIndex_t RtsIndex, CFE_SB_MsgId_t void SC_LoadAts_Test_Nominal(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SC_SetupSingleAtsEntry(AtsIndex, 1, sizeof(SC_NoopCmd_t)); @@ -292,15 +303,23 @@ void SC_LoadAts_Test_Nominal(void) SC_LoadAts(AtsIndex); /* Verify results */ - UtAssert_INT32_EQ(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0], 0); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_LOADED); - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands, 1); + SC_Assert_IDX_EQ(CmdOffsetRec->Offset, SC_ENTRY_OFFSET_FIRST); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_LOADED); + UtAssert_UINT32_EQ(AtsInfoPtr->NumberOfCommands, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_LoadAts_Test_CmdRunOffEndOfBuffer(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); /* Set up -- Modify the final entry so it would go off the end of the table */ UT_SC_SetupAtsTable(AtsIndex, UT_SC_NOMINAL_CMD_SIZE, SC_ATS_BUFF_SIZE32 + 1, NULL); @@ -308,67 +327,99 @@ void SC_LoadAts_Test_CmdRunOffEndOfBuffer(void) /* Execute the function being tested */ SC_LoadAts(AtsIndex); - UtAssert_INT32_EQ(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0], SC_ERROR); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_EMPTY); - UtAssert_ZERO(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands); - UtAssert_ZERO(SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize); + SC_Assert_IDX_EQ(CmdOffsetRec->Offset, SC_ENTRY_OFFSET_INVALID); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EMPTY); + UtAssert_ZERO(AtsInfoPtr->NumberOfCommands); + UtAssert_ZERO(AtsInfoPtr->AtsSize); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_LoadAts_Test_CmdLengthInvalid(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SC_SetupSingleAtsEntry(AtsIndex, 1, SC_PACKET_MAX_SIZE + 1); /* Execute the function being tested */ SC_LoadAts(AtsIndex); - UtAssert_INT32_EQ(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0], SC_ERROR); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_EMPTY); - UtAssert_ZERO(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands); - UtAssert_ZERO(SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize); + SC_Assert_IDX_EQ(CmdOffsetRec->Offset, SC_ENTRY_OFFSET_INVALID); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EMPTY); + UtAssert_ZERO(AtsInfoPtr->NumberOfCommands); + UtAssert_ZERO(AtsInfoPtr->AtsSize); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_LoadAts_Test_CmdLengthZero(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SC_SetupSingleAtsEntry(AtsIndex, 1, SC_PACKET_MIN_SIZE - 1); /* Execute the function being tested */ SC_LoadAts(AtsIndex); - UtAssert_INT32_EQ(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0], SC_ERROR); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_EMPTY); - UtAssert_ZERO(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands); - UtAssert_ZERO(SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize); + SC_Assert_IDX_EQ(CmdOffsetRec->Offset, SC_ENTRY_OFFSET_INVALID); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EMPTY); + UtAssert_ZERO(AtsInfoPtr->NumberOfCommands); + UtAssert_ZERO(AtsInfoPtr->AtsSize); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_LoadAts_Test_CmdNumberInvalid(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SC_SetupSingleAtsEntry(AtsIndex, SC_MAX_ATS_CMDS * 2, UT_SC_NOMINAL_CMD_SIZE); /* Execute the function being tested */ SC_LoadAts(AtsIndex); - UtAssert_INT32_EQ(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0], SC_ERROR); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_EMPTY); - UtAssert_ZERO(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands); - UtAssert_ZERO(SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize); + SC_Assert_IDX_EQ(CmdOffsetRec->Offset, SC_ENTRY_OFFSET_INVALID); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EMPTY); + UtAssert_ZERO(AtsInfoPtr->NumberOfCommands); + UtAssert_ZERO(AtsInfoPtr->AtsSize); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_LoadAts_Test_AtsBufferTooSmall(void) { - SC_AtsEntryHeader_t *LastValidEntry; - void * TailPtr; - SC_AtsEntryHeader_t *InvalidEntry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * LastValidEntry; + void * TailPtr; + SC_AtsEntryHeader_t * InvalidEntry; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); /* Set up -- Modify the final entry so it would go off the end of the table */ LastValidEntry = @@ -386,32 +437,48 @@ void SC_LoadAts_Test_AtsBufferTooSmall(void) SC_LoadAts(AtsIndex); /* Verify results */ - UtAssert_INT32_EQ(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0], SC_ERROR); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_EMPTY); - UtAssert_ZERO(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands); - UtAssert_ZERO(SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize); + SC_Assert_IDX_EQ(CmdOffsetRec->Offset, SC_ENTRY_OFFSET_INVALID); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EMPTY); + UtAssert_ZERO(AtsInfoPtr->NumberOfCommands); + UtAssert_ZERO(AtsInfoPtr->AtsSize); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_LoadAts_Test_AtsEmpty(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); /* Execute the function being tested */ SC_LoadAts(AtsIndex); /* Verify results */ - UtAssert_INT32_EQ(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0], SC_ERROR); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_EMPTY); - UtAssert_ZERO(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands); - UtAssert_ZERO(SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize); + SC_Assert_IDX_EQ(CmdOffsetRec->Offset, SC_ENTRY_OFFSET_INVALID); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EMPTY); + UtAssert_ZERO(AtsInfoPtr->NumberOfCommands); + UtAssert_ZERO(AtsInfoPtr->AtsSize); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_LoadAts_Test_LoadExactlyBufferLength(void) { - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); /* Set up -- Modify the final entry so it exactly takes up the remainder of the buffer */ Entry = UT_SC_SetupAtsTable(AtsIndex, UT_SC_NOMINAL_CMD_SIZE, SC_ATS_BUFF_SIZE32, NULL); @@ -420,17 +487,25 @@ void SC_LoadAts_Test_LoadExactlyBufferLength(void) SC_LoadAts(AtsIndex); /* Verify results */ - UtAssert_INT32_EQ(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0], 0); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_LOADED); - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands, Entry->CmdNumber); - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize, SC_ATS_BUFF_SIZE32); + SC_Assert_IDX_VALUE(CmdOffsetRec->Offset, 0); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_LOADED); + SC_Assert_ID_VALUE(Entry->CmdNumber, AtsInfoPtr->NumberOfCommands); + UtAssert_UINT32_EQ(AtsInfoPtr->AtsSize, SC_ATS_BUFF_SIZE32); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_LoadAts_Test_CmdNotEmpty(void) { - void * TailPtr; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + void * TailPtr; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); /* Set up a buffer that has a duplicate command number entry */ TailPtr = UT_SC_GetAtsTable(AtsIndex); @@ -441,10 +516,10 @@ void SC_LoadAts_Test_CmdNotEmpty(void) SC_LoadAts(AtsIndex); /* Verify results */ - UtAssert_UINT32_EQ(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0], SC_ERROR); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_EMPTY); - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands, 0); - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize, 0); + SC_Assert_IDX_EQ(CmdOffsetRec->Offset, SC_ENTRY_OFFSET_INVALID); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_EMPTY); + UtAssert_UINT32_EQ(AtsInfoPtr->NumberOfCommands, 0); + UtAssert_UINT32_EQ(AtsInfoPtr->AtsSize, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } @@ -477,11 +552,16 @@ void SC_BuildTimeIndexTable_Test_InvalidIndex(void) void SC_Insert_Test(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - uint8 ListLength = 1; - SC_CommandIndex_t NewCmdIndex = SC_COMMAND_IDX_C(0); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + uint8 ListLength = 1; + SC_CommandIndex_t NewCmdIndex = SC_COMMAND_IDX_C(0); + SC_AtsCmdNumRecord_t *AtsCmdNumRec0; + SC_AtsCmdNumRecord_t *AtsCmdNumRec1; + + AtsCmdNumRec0 = SC_GetAtsCommandNumAtSeq(AtsIndex, UT_SEQ_INDEX_0); + AtsCmdNumRec1 = SC_GetAtsCommandNumAtSeq(AtsIndex, UT_SEQ_INDEX_1); - SC_AppData.AtsTimeIndexBuffer[AtsIndex][0] = 1; + AtsCmdNumRec0->CmdNum = SC_CommandIndexToNum(NewCmdIndex); /* Execute the function being tested */ SC_Insert(AtsIndex, NewCmdIndex, ListLength); @@ -489,21 +569,26 @@ void SC_Insert_Test(void) /* Verify results */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_UINT16_EQ(SC_AppData.AtsTimeIndexBuffer[AtsIndex][1], SC_AppData.AtsTimeIndexBuffer[AtsIndex][0]); - UtAssert_UINT16_EQ(SC_AppData.AtsTimeIndexBuffer[AtsIndex][1], NewCmdIndex + 1); + SC_Assert_ID_EQ(AtsCmdNumRec1->CmdNum, AtsCmdNumRec0->CmdNum); + SC_Assert_ID_EQ(AtsCmdNumRec1->CmdNum, SC_CommandIndexToNum(NewCmdIndex)); } void SC_Insert_Test_MiddleOfList(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - uint8 ListLength = 1; - SC_CommandIndex_t NewCmdIndex = SC_COMMAND_IDX_C(0); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + uint8 ListLength = 1; + SC_CommandIndex_t NewCmdIndex = SC_COMMAND_IDX_C(0); + SC_AtsCmdNumRecord_t *AtsCmdNumRec0; + SC_AtsCmdNumRecord_t *AtsCmdNumRec1; + + AtsCmdNumRec0 = SC_GetAtsCommandNumAtSeq(AtsIndex, UT_SEQ_INDEX_0); + AtsCmdNumRec1 = SC_GetAtsCommandNumAtSeq(AtsIndex, UT_SEQ_INDEX_1); /* Set to cause SC_CompareAbsTime to return false, in order to reach block starting with "new cmd will execute at same time or after this list entry" */ UT_SetDeferredRetcode(UT_KEY(SC_CompareAbsTime), 1, false); - SC_AppData.AtsTimeIndexBuffer[AtsIndex][0] = 1; + AtsCmdNumRec0->CmdNum = SC_CommandIndexToNum(NewCmdIndex); /* Execute the function being tested */ SC_Insert(AtsIndex, NewCmdIndex, ListLength); @@ -511,21 +596,26 @@ void SC_Insert_Test_MiddleOfList(void) /* Verify results */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_UINT16_EQ(SC_AppData.AtsTimeIndexBuffer[AtsIndex][1], SC_AppData.AtsTimeIndexBuffer[AtsIndex][0]); - UtAssert_UINT16_EQ(SC_AppData.AtsTimeIndexBuffer[AtsIndex][1], NewCmdIndex + 1); + SC_Assert_ID_EQ(AtsCmdNumRec1->CmdNum, AtsCmdNumRec0->CmdNum); + SC_Assert_ID_EQ(AtsCmdNumRec1->CmdNum, SC_CommandIndexToNum(NewCmdIndex)); } void SC_Insert_Test_MiddleOfListCompareAbsTimeTrue(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - uint8 ListLength = 1; - SC_CommandIndex_t NewCmdIndex = SC_COMMAND_IDX_C(0); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + uint8 ListLength = 1; + SC_CommandIndex_t NewCmdIndex = SC_COMMAND_IDX_C(0); + SC_AtsCmdNumRecord_t *AtsCmdNumRec0; + SC_AtsCmdNumRecord_t *AtsCmdNumRec1; + + AtsCmdNumRec0 = SC_GetAtsCommandNumAtSeq(AtsIndex, UT_SEQ_INDEX_0); + AtsCmdNumRec1 = SC_GetAtsCommandNumAtSeq(AtsIndex, UT_SEQ_INDEX_1); /* Set to cause SC_CompareAbsTime to return false, in order to reach block starting with "new cmd will execute at same time or after this list entry" */ UT_SetDeferredRetcode(UT_KEY(SC_CompareAbsTime), 1, true); - SC_AppData.AtsTimeIndexBuffer[AtsIndex][0] = 1; + AtsCmdNumRec0->CmdNum = SC_CommandIndexToNum(NewCmdIndex); /* Execute the function being tested */ SC_Insert(AtsIndex, NewCmdIndex, ListLength); @@ -533,8 +623,8 @@ void SC_Insert_Test_MiddleOfListCompareAbsTimeTrue(void) /* Verify results */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_UINT16_EQ(SC_AppData.AtsTimeIndexBuffer[AtsIndex][1], SC_AppData.AtsTimeIndexBuffer[AtsIndex][0]); - UtAssert_UINT16_EQ(SC_AppData.AtsTimeIndexBuffer[AtsIndex][1], NewCmdIndex + 1); + SC_Assert_ID_EQ(AtsCmdNumRec1->CmdNum, AtsCmdNumRec0->CmdNum); + SC_Assert_ID_EQ(AtsCmdNumRec1->CmdNum, SC_CommandIndexToNum(NewCmdIndex)); } void SC_Insert_Test_InvalidIndex(void) @@ -950,8 +1040,16 @@ void SC_UpdateAppend_Test_CmdNumberTooHigh(void) void SC_ProcessAppend_Test(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - void * TailPtr; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + void * TailPtr; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SC_SetupSingleAtsEntry(AtsIndex, 1, UT_SC_NOMINAL_CMD_SIZE); @@ -971,19 +1069,26 @@ void SC_ProcessAppend_Test(void) SC_ProcessAppend(AtsIndex); /* Verify results */ - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize, 1); - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands, 1); - UtAssert_ZERO(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0]); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_LOADED); - UtAssert_UINT32_EQ(SC_OperData.AtsCtrlBlckAddr->AtpState, SC_Status_EXECUTING); + UtAssert_UINT32_EQ(AtsInfoPtr->AtsSize, 1); + UtAssert_UINT32_EQ(AtsInfoPtr->NumberOfCommands, 1); + SC_Assert_IDX_EQ(CmdOffsetRec->Offset, SC_ENTRY_OFFSET_FIRST); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_LOADED); + SC_Assert_CmdStatus(SC_OperData.AtsCtrlBlckAddr->AtpState, SC_Status_EXECUTING); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_ProcessAppend_Test_CmdLoaded(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - void * TailPtr; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + void * TailPtr; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SC_SetupSingleAtsEntry(AtsIndex, 1, UT_SC_NOMINAL_CMD_SIZE); @@ -993,27 +1098,35 @@ void SC_ProcessAppend_Test_CmdLoaded(void) SC_AppData.AppendWordCount = 1; SC_OperData.HkPacket.Payload.AppendEntryCount = 1; - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0] = SC_Status_LOADED; - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); + StatusEntryPtr->Status = SC_Status_LOADED; + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); /* Execute the function being tested */ SC_ProcessAppend(AtsIndex); /* Verify results */ - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize, 1); - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands, 0); - UtAssert_ZERO(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0]); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_LOADED); - UtAssert_UINT32_EQ(SC_OperData.AtsCtrlBlckAddr->AtpState, SC_Status_EXECUTING); + UtAssert_UINT32_EQ(AtsInfoPtr->AtsSize, 1); + UtAssert_UINT32_EQ(AtsInfoPtr->NumberOfCommands, 0); + SC_Assert_IDX_EQ(CmdOffsetRec->Offset, SC_ENTRY_OFFSET_FIRST); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_LOADED); + SC_Assert_CmdStatus(SC_OperData.AtsCtrlBlckAddr->AtpState, SC_Status_EXECUTING); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_ProcessAppend_Test_NotExecuting(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - void * TailPtr; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + void * TailPtr; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SC_SetupSingleAtsEntry(AtsIndex, 1, UT_SC_NOMINAL_CMD_SIZE); @@ -1030,19 +1143,27 @@ void SC_ProcessAppend_Test_NotExecuting(void) SC_ProcessAppend(AtsIndex); /* Verify results */ - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize, 1); - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands, 1); - UtAssert_ZERO(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0]); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_LOADED); - UtAssert_UINT32_EQ(SC_OperData.AtsCtrlBlckAddr->AtpState, SC_Status_IDLE); + UtAssert_UINT32_EQ(AtsInfoPtr->AtsSize, 1); + UtAssert_UINT32_EQ(AtsInfoPtr->NumberOfCommands, 1); + SC_Assert_IDX_EQ(CmdOffsetRec->Offset, SC_ENTRY_OFFSET_FIRST); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_LOADED); + SC_Assert_CmdStatus(SC_OperData.AtsCtrlBlckAddr->AtpState, SC_Status_IDLE); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } void SC_ProcessAppend_Test_AtsNum(void) { - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); - void * TailPtr; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + void * TailPtr; + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); UT_SC_SetupSingleAtsEntry(AtsIndex, 1, UT_SC_NOMINAL_CMD_SIZE); @@ -1059,11 +1180,11 @@ void SC_ProcessAppend_Test_AtsNum(void) UtAssert_VOIDCALL(SC_ProcessAppend(AtsIndex)); /* Verify results */ - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].AtsSize, 1); - UtAssert_UINT32_EQ(SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands, 1); - UtAssert_ZERO(SC_AppData.AtsCmdIndexBuffer[AtsIndex][0]); - UtAssert_UINT32_EQ(SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0], SC_Status_LOADED); - UtAssert_UINT32_EQ(SC_OperData.AtsCtrlBlckAddr->AtpState, SC_Status_EXECUTING); + UtAssert_UINT32_EQ(AtsInfoPtr->AtsSize, 1); + UtAssert_UINT32_EQ(AtsInfoPtr->NumberOfCommands, 1); + SC_Assert_IDX_EQ(CmdOffsetRec->Offset, SC_ENTRY_OFFSET_FIRST); + SC_Assert_CmdStatus(StatusEntryPtr->Status, SC_Status_LOADED); + SC_Assert_CmdStatus(SC_OperData.AtsCtrlBlckAddr->AtpState, SC_Status_EXECUTING); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } diff --git a/unit-test/sc_rtsrq_tests.c b/unit-test/sc_rtsrq_tests.c index 3050fbf..5d30161 100644 --- a/unit-test/sc_rtsrq_tests.c +++ b/unit-test/sc_rtsrq_tests.c @@ -48,14 +48,17 @@ void SC_StartRtsCmd_Test_Nominal(void) SC_RtsEntryHeader_t *Entry; SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); size_t MsgSize; + SC_RtsInfoEntry_t * RtsInfoPtr; - Entry = (SC_RtsEntryHeader_t *)&SC_OperData.RtsTblAddr[RtsIndex][0]; + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + + Entry = (SC_RtsEntryHeader_t *)SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->TimeTag = 0; UT_CmdBuf.StartRtsCmd.Payload.RtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = false; - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_LOADED; + RtsInfoPtr->DisabledFlag = false; + RtsInfoPtr->RtsStatus = SC_Status_LOADED; /* Set message size in order to satisfy if-statement after comment "Make sure the command is big enough, but not too * big" */ @@ -67,14 +70,11 @@ void SC_StartRtsCmd_Test_Nominal(void) UtAssert_VOIDCALL(SC_StartRtsCmd(&UT_CmdBuf.StartRtsCmd)); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_EXECUTING, - "SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_EXECUTING"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr == 0, "SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr == 0, - "SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr == 0, - "SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr == 1, "SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr == 1"); + UtAssert_True(RtsInfoPtr->RtsStatus == SC_Status_EXECUTING, "RtsInfoPtr->RtsStatus == SC_Status_EXECUTING"); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdCtr, 0); + UtAssert_True(RtsInfoPtr->CmdErrCtr == 0, "RtsInfoPtr->CmdErrCtr == 0"); + SC_Assert_IDX_VALUE(RtsInfoPtr->NextCommandPtr, 0); + UtAssert_UINT32_EQ(RtsInfoPtr->UseCtr, 1); UtAssert_True(SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 1, "SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 1"); UtAssert_True(SC_OperData.HkPacket.Payload.RtsActiveCtr == 1, "SC_OperData.HkPacket.Payload.RtsActiveCtr == 1"); @@ -89,17 +89,19 @@ void SC_StartRtsCmd_Test_StartRtsNoEvents(void) SC_RtsEntryHeader_t *Entry; SC_RtsIndex_t RtsIndex; size_t MsgSize; + SC_RtsInfoEntry_t * RtsInfoPtr; UT_CmdBuf.StartRtsCmd.Payload.RtsNum = SC_RTS_NUM_C(SC_NUMBER_OF_RTS); - RtsIndex = SC_RtsNumToIndex(UT_CmdBuf.StartRtsCmd.Payload.RtsNum); + RtsIndex = SC_RtsNumToIndex(UT_CmdBuf.StartRtsCmd.Payload.RtsNum); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - Entry = (SC_RtsEntryHeader_t *)&SC_OperData.RtsTblAddr[RtsIndex][0]; + Entry = (SC_RtsEntryHeader_t *)SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->TimeTag = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = false; - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_LOADED; - SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr = 0; + RtsInfoPtr->DisabledFlag = false; + RtsInfoPtr->RtsStatus = SC_Status_LOADED; + RtsInfoPtr->UseCtr = 0; /* Set message size in order to satisfy if-statement after comment "Make sure the command is big enough, but not too * big" */ @@ -111,14 +113,11 @@ void SC_StartRtsCmd_Test_StartRtsNoEvents(void) UtAssert_VOIDCALL(SC_StartRtsCmd(&UT_CmdBuf.StartRtsCmd)); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_EXECUTING, - "SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_EXECUTING"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr == 0, "SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr == 0, - "SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr == 0, - "SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr == 1, "SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr == 1"); + UtAssert_True(RtsInfoPtr->RtsStatus == SC_Status_EXECUTING, "RtsInfoPtr->RtsStatus == SC_Status_EXECUTING"); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdCtr, 0); + UtAssert_True(RtsInfoPtr->CmdErrCtr == 0, "RtsInfoPtr->CmdErrCtr == 0"); + SC_Assert_IDX_VALUE(RtsInfoPtr->NextCommandPtr, 0); + UtAssert_UINT32_EQ(RtsInfoPtr->UseCtr, 1); UtAssert_True(SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 1, "SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 1"); UtAssert_True(SC_OperData.HkPacket.Payload.RtsActiveCtr == 1, "SC_OperData.HkPacket.Payload.RtsActiveCtr == 1"); @@ -142,14 +141,17 @@ void SC_StartRtsCmd_Test_InvalidCommandLength1(void) SC_RtsEntryHeader_t *Entry; SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); size_t MsgSize; + SC_RtsInfoEntry_t * RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - Entry = (SC_RtsEntryHeader_t *)&SC_OperData.RtsTblAddr[RtsIndex][0]; + Entry = (SC_RtsEntryHeader_t *)SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->TimeTag = 0; UT_CmdBuf.StartRtsCmd.Payload.RtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = false; - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_LOADED; + RtsInfoPtr->DisabledFlag = false; + RtsInfoPtr->RtsStatus = SC_Status_LOADED; /* Set message size in order to satisfy if-statement after comment "Make sure the command is big enough, but not too * big" */ @@ -170,14 +172,17 @@ void SC_StartRtsCmd_Test_InvalidCommandLength2(void) SC_RtsEntryHeader_t *Entry; SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); size_t MsgSize; + SC_RtsInfoEntry_t * RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - Entry = (SC_RtsEntryHeader_t *)&SC_OperData.RtsTblAddr[RtsIndex][0]; + Entry = (SC_RtsEntryHeader_t *)SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->TimeTag = 0; UT_CmdBuf.StartRtsCmd.Payload.RtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = false; - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_LOADED; + RtsInfoPtr->DisabledFlag = false; + RtsInfoPtr->RtsStatus = SC_Status_LOADED; /* Set message size in order to satisfy if-statement after comment "Make sure the command is big enough, but not too * big" */ @@ -197,14 +202,17 @@ void SC_StartRtsCmd_Test_RtsNotLoadedOrInUse(void) { SC_RtsEntryHeader_t *Entry; SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t * RtsInfoPtr; - Entry = (SC_RtsEntryHeader_t *)&SC_OperData.RtsTblAddr[RtsIndex][0]; + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + + Entry = (SC_RtsEntryHeader_t *)SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->TimeTag = 0; UT_CmdBuf.StartRtsCmd.Payload.RtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = false; - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_IDLE; + RtsInfoPtr->DisabledFlag = false; + RtsInfoPtr->RtsStatus = SC_Status_IDLE; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_StartRtsCmd(&UT_CmdBuf.StartRtsCmd)); @@ -218,14 +226,17 @@ void SC_StartRtsCmd_Test_RtsDisabled(void) { SC_RtsEntryHeader_t *Entry; SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t * RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - Entry = (SC_RtsEntryHeader_t *)&SC_OperData.RtsTblAddr[RtsIndex][0]; + Entry = (SC_RtsEntryHeader_t *)SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->TimeTag = 0; UT_CmdBuf.StartRtsCmd.Payload.RtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = true; - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_LOADED; + RtsInfoPtr->DisabledFlag = true; + RtsInfoPtr->RtsStatus = SC_Status_LOADED; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_StartRtsCmd(&UT_CmdBuf.StartRtsCmd)); @@ -261,10 +272,13 @@ void SC_StartRtsCmd_Test_InvalidRtsIdZero(void) void SC_StartRtsGrpCmd_Test_Nominal(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_LOADED; - SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr = 0; + RtsInfoPtr->RtsStatus = SC_Status_LOADED; + RtsInfoPtr->UseCtr = 0; UT_CmdBuf.StartRtsGrpCmd.Payload.FirstRtsNum = SC_RtsIndexToNum(RtsIndex); UT_CmdBuf.StartRtsGrpCmd.Payload.LastRtsNum = SC_RtsIndexToNum(RtsIndex); @@ -273,14 +287,11 @@ void SC_StartRtsGrpCmd_Test_Nominal(void) UtAssert_VOIDCALL(SC_StartRtsGrpCmd(&UT_CmdBuf.StartRtsGrpCmd)); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_EXECUTING, - "SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_EXECUTING"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr == 0, "SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr == 0, - "SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr == 0, - "SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr == 1, "SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr == 1"); + UtAssert_True(RtsInfoPtr->RtsStatus == SC_Status_EXECUTING, "RtsInfoPtr->RtsStatus == SC_Status_EXECUTING"); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdCtr, 0); + UtAssert_True(RtsInfoPtr->CmdErrCtr == 0, "RtsInfoPtr->CmdErrCtr == 0"); + SC_Assert_IDX_VALUE(RtsInfoPtr->NextCommandPtr, 0); + UtAssert_UINT32_EQ(RtsInfoPtr->UseCtr, 1); UtAssert_True(SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 1, "SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 1"); UtAssert_True(SC_OperData.HkPacket.Payload.RtsActiveCtr == 1, "SC_OperData.HkPacket.Payload.RtsActiveCtr == 1"); @@ -382,27 +393,28 @@ void SC_StartRtsGrpCmd_Test_FirstLastRtsIndex(void) void SC_StartRtsGrpCmd_Test_DisabledFlag(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = true; - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; - SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr = SC_ENTRY_OFFSET_FIRST; + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - UT_CmdBuf.StartRtsGrpCmd.Payload.FirstRtsNum = SC_RtsIndexToNum(RtsIndex); - UT_CmdBuf.StartRtsGrpCmd.Payload.LastRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->DisabledFlag = true; + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr->UseCtr = 0; + RtsInfoPtr->CmdCtr = 0; + RtsInfoPtr->NextCommandPtr = SC_ENTRY_OFFSET_FIRST; + + UT_CmdBuf.StartRtsGrpCmd.Payload.FirstRtsNum = SC_RTS_NUM_C(1); + UT_CmdBuf.StartRtsGrpCmd.Payload.LastRtsNum = SC_RTS_NUM_C(1); /* Execute the function being tested */ UtAssert_VOIDCALL(SC_StartRtsGrpCmd(&UT_CmdBuf.StartRtsGrpCmd)); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr == 0, "SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr == 0, - "SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr == 0, - "SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr == 0, "SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr == 0"); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdCtr, 0); + UtAssert_True(RtsInfoPtr->CmdErrCtr == 0, "RtsInfoPtr->CmdErrCtr == 0"); + SC_Assert_IDX_VALUE(RtsInfoPtr->NextCommandPtr, 0); + UtAssert_UINT32_EQ(RtsInfoPtr->UseCtr, 0); UtAssert_True(SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 0, "SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.RtsActiveCtr == 0, "SC_OperData.HkPacket.Payload.RtsActiveCtr == 0"); @@ -417,12 +429,15 @@ void SC_StartRtsGrpCmd_Test_DisabledFlag(void) void SC_StartRtsGrpCmd_Test_RtsStatus(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; - SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr = SC_ENTRY_OFFSET_FIRST; + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr->UseCtr = 0; + RtsInfoPtr->CmdCtr = 0; + RtsInfoPtr->NextCommandPtr = SC_ENTRY_OFFSET_FIRST; UT_CmdBuf.StartRtsGrpCmd.Payload.FirstRtsNum = SC_RTS_NUM_C(1); UT_CmdBuf.StartRtsGrpCmd.Payload.LastRtsNum = SC_RTS_NUM_C(1); @@ -431,14 +446,11 @@ void SC_StartRtsGrpCmd_Test_RtsStatus(void) UtAssert_VOIDCALL(SC_StartRtsGrpCmd(&UT_CmdBuf.StartRtsGrpCmd)); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_EXECUTING, - "SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_EXECUTING"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr == 0, "SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr == 0, - "SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr == 0, - "SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr == 0"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr == 0, "SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr == 0"); + UtAssert_True(RtsInfoPtr->RtsStatus == SC_Status_EXECUTING, "RtsInfoPtr->RtsStatus == SC_Status_EXECUTING"); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdCtr, 0); + UtAssert_True(RtsInfoPtr->CmdErrCtr == 0, "RtsInfoPtr->CmdErrCtr == 0"); + SC_Assert_IDX_VALUE(RtsInfoPtr->NextCommandPtr, 0); + UtAssert_UINT32_EQ(RtsInfoPtr->UseCtr, 0); UtAssert_True(SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 0, "SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 0"); UtAssert_True(SC_OperData.HkPacket.Payload.RtsActiveCtr == 0, "SC_OperData.HkPacket.Payload.RtsActiveCtr == 0"); @@ -511,9 +523,12 @@ void SC_StopRtsGrpCmd_Test_Error(void) void SC_StopRtsGrpCmd_Test_NotExecuting(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; UT_CmdBuf.StopRtsGrpCmd.Payload.FirstRtsNum = SC_RTS_NUM_C(1); UT_CmdBuf.StopRtsGrpCmd.Payload.LastRtsNum = SC_RTS_NUM_C(1); @@ -605,7 +620,10 @@ void SC_StopRtsGrpCmd_Test_FirstLastRtsIndex(void) void SC_DisableRtsCmd_Test_Nominal(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); UT_CmdBuf.DisableRtsCmd.Payload.RtsNum = SC_RtsIndexToNum(RtsIndex); @@ -613,8 +631,7 @@ void SC_DisableRtsCmd_Test_Nominal(void) UtAssert_VOIDCALL(SC_DisableRtsCmd(&UT_CmdBuf.DisableRtsCmd)); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == true, - "SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == true"); + 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); @@ -637,7 +654,10 @@ void SC_DisableRtsCmd_Test_InvalidRtsID(void) void SC_DisableRtsGrpCmd_Test_Nominal(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); /* RtsNum - 1 */ + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); UT_CmdBuf.DisableRtsGrpCmd.Payload.FirstRtsNum = SC_RtsIndexToNum(RtsIndex); UT_CmdBuf.DisableRtsGrpCmd.Payload.LastRtsNum = SC_RtsIndexToNum(RtsIndex); @@ -646,8 +666,7 @@ void SC_DisableRtsGrpCmd_Test_Nominal(void) UtAssert_VOIDCALL(SC_DisableRtsGrpCmd(&UT_CmdBuf.DisableRtsGrpCmd)); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == true, - "SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == true"); + 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_DISRTSGRP_CMD_INF_EID); @@ -746,9 +765,12 @@ void SC_DisableRtsGrpCmd_Test_FirstLastRtsIndex(void) void SC_DisableRtsGrpCmd_Test_DisabledFlag(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); /* RtsNum - 1 */ + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); /* RtsNum - 1 */ + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = true; + RtsInfoPtr->DisabledFlag = true; UT_CmdBuf.DisableRtsGrpCmd.Payload.FirstRtsNum = SC_RtsIndexToNum(RtsIndex); UT_CmdBuf.DisableRtsGrpCmd.Payload.LastRtsNum = SC_RtsIndexToNum(RtsIndex); @@ -757,8 +779,7 @@ void SC_DisableRtsGrpCmd_Test_DisabledFlag(void) UtAssert_VOIDCALL(SC_DisableRtsGrpCmd(&UT_CmdBuf.DisableRtsGrpCmd)); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == true, - "SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == true"); + 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_DISRTSGRP_CMD_INF_EID); @@ -767,7 +788,10 @@ void SC_DisableRtsGrpCmd_Test_DisabledFlag(void) void SC_EnableRtsCmd_Test_Nominal(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); UT_CmdBuf.EnableRtsCmd.Payload.RtsNum = SC_RtsIndexToNum(RtsIndex); @@ -775,8 +799,7 @@ void SC_EnableRtsCmd_Test_Nominal(void) UtAssert_VOIDCALL(SC_EnableRtsCmd(&UT_CmdBuf.EnableRtsCmd)); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false, - "SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false"); + 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); @@ -813,7 +836,10 @@ void SC_EnableRtsCmd_Test_InvalidRtsIDZero(void) void SC_EnableRtsGrpCmd_Test_Nominal(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); /* RtsNum - 1 */ + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); /* RtsNum - 1 */ + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); UT_CmdBuf.EnableRtsGrpCmd.Payload.FirstRtsNum = SC_RtsIndexToNum(RtsIndex); UT_CmdBuf.EnableRtsGrpCmd.Payload.LastRtsNum = SC_RtsIndexToNum(RtsIndex); @@ -822,8 +848,7 @@ void SC_EnableRtsGrpCmd_Test_Nominal(void) UtAssert_VOIDCALL(SC_EnableRtsGrpCmd(&UT_CmdBuf.EnableRtsGrpCmd)); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false, - "SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false"); + 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_ENARTSGRP_CMD_INF_EID); @@ -922,19 +947,24 @@ void SC_EnableRtsGrpCmd_Test_FirstLastRtsIndex(void) void SC_EnableRtsGrpCmd_Test_DisabledFlag(void) { - SC_RtsIndex_t RtsIndex0 = SC_RTS_IDX_C(0); - SC_RtsIndex_t RtsIndex1 = SC_RTS_IDX_C(1); + SC_RtsIndex_t RtsIndex0 = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex1 = SC_RTS_IDX_C(1); + SC_RtsInfoEntry_t *RtsInfoPtr0; + SC_RtsInfoEntry_t *RtsInfoPtr1; + + RtsInfoPtr0 = SC_GetRtsInfoObject(RtsIndex0); + RtsInfoPtr1 = SC_GetRtsInfoObject(RtsIndex1); - SC_OperData.RtsInfoTblAddr[RtsIndex0].DisabledFlag = false; - SC_OperData.RtsInfoTblAddr[RtsIndex1].DisabledFlag = true; - UT_CmdBuf.EnableRtsGrpCmd.Payload.FirstRtsNum = SC_RtsIndexToNum(RtsIndex0); - UT_CmdBuf.EnableRtsGrpCmd.Payload.LastRtsNum = SC_RtsIndexToNum(RtsIndex1); + RtsInfoPtr0->DisabledFlag = false; + RtsInfoPtr1->DisabledFlag = true; + UT_CmdBuf.EnableRtsGrpCmd.Payload.FirstRtsNum = SC_RtsIndexToNum(RtsIndex0); + UT_CmdBuf.EnableRtsGrpCmd.Payload.LastRtsNum = SC_RtsIndexToNum(RtsIndex1); /* Execute the function being tested */ UtAssert_VOIDCALL(SC_EnableRtsGrpCmd(&UT_CmdBuf.EnableRtsGrpCmd)); /* Verify results */ - UtAssert_BOOL_FALSE(SC_OperData.RtsInfoTblAddr[RtsIndex0].DisabledFlag); + UtAssert_True(RtsInfoPtr0->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_ENARTSGRP_CMD_INF_EID); @@ -943,19 +973,20 @@ void SC_EnableRtsGrpCmd_Test_DisabledFlag(void) void SC_KillRts_Test(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; - SC_OperData.RtsCtrlBlckAddr->NumRtsActive = 1; + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + SC_OperData.RtsCtrlBlckAddr->NumRtsActive = 1; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_KillRts(RtsIndex)); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_LOADED, - "SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_LOADED"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandTime == SC_MAX_TIME, - "SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandTime == SC_MAX_TIME"); + UtAssert_True(RtsInfoPtr->RtsStatus == SC_Status_LOADED, "RtsInfoPtr->RtsStatus == SC_Status_LOADED"); + UtAssert_True(RtsInfoPtr->NextCommandTime == SC_MAX_TIME, "RtsInfoPtr->NextCommandTime == SC_MAX_TIME"); UtAssert_True(SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 0, "SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 0"); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -963,19 +994,20 @@ void SC_KillRts_Test(void) void SC_KillRts_Test_NoActiveRts(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; - SC_OperData.RtsCtrlBlckAddr->NumRtsActive = 0; + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + SC_OperData.RtsCtrlBlckAddr->NumRtsActive = 0; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_KillRts(RtsIndex)); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_LOADED, - "SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_Status_LOADED"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandTime == SC_MAX_TIME, - "SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandTime == SC_MAX_TIME"); + UtAssert_True(RtsInfoPtr->RtsStatus == SC_Status_LOADED, "RtsInfoPtr->RtsStatus == SC_Status_LOADED"); + UtAssert_True(RtsInfoPtr->NextCommandTime == SC_MAX_TIME, "RtsInfoPtr->NextCommandTime == SC_MAX_TIME"); UtAssert_True(SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 0, "SC_OperData.RtsCtrlBlckAddr->NumRtsActive == 0"); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); diff --git a/unit-test/sc_state_tests.c b/unit-test/sc_state_tests.c index b32ebd6..962fcde 100644 --- a/unit-test/sc_state_tests.c +++ b/unit-test/sc_state_tests.c @@ -56,10 +56,13 @@ int32 SC_STATE_TEST_CFE_SB_GetTotalMsgLengthHook(void *UserObj, int32 StubRetcod void SC_GetNextRtsTime_Test_Nominal(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandTime = SC_MAX_TIME; + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr->NextCommandTime = SC_MAX_TIME; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_GetNextRtsTime()); @@ -73,11 +76,14 @@ void SC_GetNextRtsTime_Test_Nominal(void) void SC_GetNextRtsTime_Test_InvalidRtsNum(void) { - uint8 i; + uint8 i; + SC_RtsInfoEntry_t *RtsInfoPtr; for (i = 0; i < SC_NUMBER_OF_RTS; i++) { - SC_OperData.RtsInfoTblAddr[i].RtsStatus = (SC_Status_Enum_t)(-1); + RtsInfoPtr = SC_GetRtsInfoObject(SC_RTS_IDX_C(i)); + + RtsInfoPtr->RtsStatus = (SC_Status_Enum_t)(-1); } /* Execute the function being tested */ @@ -93,11 +99,17 @@ void SC_GetNextRtsTime_Test_InvalidRtsNum(void) void SC_GetNextRtsTime_Test_RtsPriority(void) { - SC_OperData.RtsInfoTblAddr[0].RtsStatus = SC_Status_EXECUTING; - SC_OperData.RtsInfoTblAddr[0].NextCommandTime = SC_MAX_TIME; + SC_RtsInfoEntry_t *RtsInfoPtr0; + SC_RtsInfoEntry_t *RtsInfoPtr1; + + RtsInfoPtr0 = SC_GetRtsInfoObject(SC_RTS_IDX_C(0)); + RtsInfoPtr1 = SC_GetRtsInfoObject(SC_RTS_IDX_C(1)); + + RtsInfoPtr0->RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr0->NextCommandTime = SC_MAX_TIME; - SC_OperData.RtsInfoTblAddr[1].RtsStatus = SC_Status_EXECUTING; - SC_OperData.RtsInfoTblAddr[1].NextCommandTime = SC_MAX_TIME - 1; + RtsInfoPtr1->RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr1->NextCommandTime = SC_MAX_TIME - 1; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_GetNextRtsTime()); @@ -140,14 +152,17 @@ void SC_UpdateNextTime_Test_Atp2(void) void SC_UpdateNextTime_Test_Rtp(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RTS_NUM_C(10); SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.NextCmdTime[SC_Process_ATP] = 10; - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandTime = 1; + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr->NextCommandTime = 1; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_UpdateNextTime()); @@ -160,14 +175,17 @@ void SC_UpdateNextTime_Test_Rtp(void) void SC_UpdateNextTime_Test_RtpAtpPriority(void) { - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_NUMBER_OF_RTS - 1); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_NUMBER_OF_RTS - 1); + SC_RtsInfoEntry_t *RtsInfoPtr; + + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); SC_AppData.NextCmdTime[SC_Process_RTP] = 0; SC_AppData.NextCmdTime[SC_Process_ATP] = 0; - SC_OperData.RtsInfoTblAddr[SC_NUMBER_OF_RTS - 1].RtsStatus = SC_Status_EXECUTING; - SC_OperData.RtsInfoTblAddr[SC_NUMBER_OF_RTS - 1].NextCommandTime = 1; + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + RtsInfoPtr->NextCommandTime = 1; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_UpdateNextTime()); @@ -178,16 +196,21 @@ void SC_UpdateNextTime_Test_RtpAtpPriority(void) void SC_GetNextRtsCommand_Test_GetNextCommand(void) { - size_t MsgSize; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + size_t MsgSize; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t *RtsInfoPtr; + SC_AtsInfoTable_t *AtsInfoPtr; - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RTS_NUM_C(1); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RTS_NUM_C(1); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + AtsInfoPtr->NumberOfCommands = 1; /* Give the packet the minimum possible size, to ensure that (CmdOffset < SC_RTS_HDR_WORDS) is met */ MsgSize = SC_PACKET_MIN_SIZE; @@ -202,10 +225,7 @@ void SC_GetNextRtsCommand_Test_GetNextCommand(void) UtAssert_VOIDCALL(SC_GetNextRtsCommand()); /* Verify results */ - UtAssert_True(SC_OperData.RtsInfoTblAddr[0].NextCommandPtr == - (SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 1) / SC_BYTES_IN_WORD, - "SC_OperData.RtsInfoTblAddr[0].NextCommandPtr == (SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 1) / " - "SC_BYTES_IN_WORD"); + SC_Assert_IDX_VALUE(RtsInfoPtr->NextCommandPtr, (SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 1) / SC_BYTES_IN_WORD); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } @@ -221,16 +241,21 @@ void SC_GetNextRtsCommand_Test_RtsNumZero(void) void SC_GetNextRtsCommand_Test_RtsNumMax(void) { - size_t MsgSize; - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_NUMBER_OF_RTS - 1); - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + size_t MsgSize; + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_NUMBER_OF_RTS - 1); + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_RtsInfoEntry_t *RtsInfoPtr; + SC_AtsInfoTable_t *AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + AtsInfoPtr->NumberOfCommands = 1; /* Give the packet the minimum possible size, to ensure that (CmdOffset < SC_RTS_HDR_WORDS) is met */ MsgSize = SC_PACKET_MIN_SIZE; @@ -250,14 +275,17 @@ void SC_GetNextRtsCommand_Test_RtsNumMax(void) void SC_GetNextRtsCommand_Test_RtsNumOverMax(void) { - size_t MsgSize; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + size_t MsgSize; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_AtsInfoTable_t *AtsInfoPtr; - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RTS_NUM_C(SC_NUMBER_OF_RTS + 1); - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RTS_NUM_C(SC_NUMBER_OF_RTS + 1); + AtsInfoPtr->NumberOfCommands = 1; /* Give the packet the minimum possible size, to ensure that (CmdOffset < SC_RTS_HDR_WORDS) is met */ MsgSize = SC_PACKET_MIN_SIZE; @@ -277,16 +305,21 @@ void SC_GetNextRtsCommand_Test_RtsNumOverMax(void) void SC_GetNextRtsCommand_Test_RtsNotExecuting(void) { - size_t MsgSize; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); - SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_NUMBER_OF_RTS - 1); + size_t MsgSize; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_NUMBER_OF_RTS - 1); + SC_RtsInfoEntry_t *RtsInfoPtr; + SC_AtsInfoTable_t *AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_IDLE; - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_IDLE; + AtsInfoPtr->NumberOfCommands = 1; /* Give the packet the minimum possible size, to ensure that (CmdOffset < SC_RTS_HDR_WORDS) is met */ MsgSize = SC_PACKET_MIN_SIZE; @@ -309,16 +342,24 @@ void SC_GetNextRtsCommand_Test_RtsLengthError(void) SC_RtsEntryHeader_t *Entry; size_t MsgSize1; size_t MsgSize2; + uint32 EntryOffsetVal; SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t * RtsInfoPtr; + SC_AtsInfoTable_t * AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; - Entry = (SC_RtsEntryHeader_t *)&SC_OperData.RtsTblAddr[0][0]; + Entry = (SC_RtsEntryHeader_t *)SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST); + EntryOffsetVal = + SC_RTS_BUFF_SIZE32 - SC_RTS_HDR_WORDS - ((SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD); /* Set to generate error message SC_RTS_LNGTH_ERR_EID */ CFE_MSG_Init((CFE_MSG_Message_t *)Entry, CFE_SB_ValueToMsgId(SC_CMD_MID), SC_PACKET_MAX_SIZE); @@ -331,24 +372,19 @@ void SC_GetNextRtsCommand_Test_RtsLengthError(void) /* Set so checksum will pass in SC_ProcessRtpCommand */ UT_SetDeferredRetcode(UT_KEY(CFE_MSG_ValidateChecksum), 1, true); - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; - - SC_OperData.RtsInfoTblAddr[0].NextCommandPtr = - (SC_RTS_BUFF_SIZE32 - (SC_RTS_HDR_WORDS)) - ((SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD); + AtsInfoPtr->NumberOfCommands = 1; + RtsInfoPtr->NextCommandPtr = SC_ENTRY_OFFSET_C(EntryOffsetVal); /* Execute the function being tested */ UtAssert_VOIDCALL(SC_GetNextRtsCommand()); /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 1"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[0].CmdErrCtr == 1, "SC_OperData.RtsInfoTblAddr[0].CmdErrCtr == 1"); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdErrCtr, 1); SC_Assert_ID_EQ(SC_OperData.HkPacket.Payload.LastRtsErrSeq, SC_OperData.RtsCtrlBlckAddr->CurrRtsNum); - UtAssert_True(SC_OperData.HkPacket.Payload.LastRtsErrCmd == - SC_OperData.RtsInfoTblAddr[0].NextCommandPtr + - ((SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD), - "SC_OperData.HkPacket.Payload.LastRtsErrCmd == SC_OperData.RtsInfoTblAddr[0].NextCommandPtr + " - "((SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD)"); + EntryOffsetVal += (SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD; + SC_Assert_IDX_VALUE(SC_OperData.HkPacket.Payload.LastRtsErrCmd, EntryOffsetVal); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_RTS_LNGTH_ERR_EID); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); @@ -359,16 +395,24 @@ void SC_GetNextRtsCommand_Test_CommandLengthError(void) SC_RtsEntryHeader_t *Entry; size_t MsgSize1; size_t MsgSize2; + uint32 EntryOffsetVal; SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t * RtsInfoPtr; + SC_AtsInfoTable_t * AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; - Entry = (SC_RtsEntryHeader_t *)&SC_OperData.RtsTblAddr[0][0]; + Entry = (SC_RtsEntryHeader_t *)SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST); + EntryOffsetVal = + SC_RTS_BUFF_SIZE32 - SC_RTS_HDR_WORDS - ((SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD); /* Set to generate error message SC_RTS_LNGTH_ERR_EID */ CFE_MSG_Init((CFE_MSG_Message_t *)Entry, CFE_SB_ValueToMsgId(SC_CMD_MID), SC_PACKET_MAX_SIZE); @@ -381,24 +425,19 @@ void SC_GetNextRtsCommand_Test_CommandLengthError(void) /* Set so checksum will pass in SC_ProcessRtpCommand */ UT_SetDeferredRetcode(UT_KEY(CFE_MSG_ValidateChecksum), 1, true); - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; - - SC_OperData.RtsInfoTblAddr[0].NextCommandPtr = - (SC_RTS_BUFF_SIZE32 - (SC_RTS_HDR_WORDS)) - ((SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD); + AtsInfoPtr->NumberOfCommands = 1; + RtsInfoPtr->NextCommandPtr = SC_ENTRY_OFFSET_C(EntryOffsetVal); /* Execute the function being tested */ UtAssert_VOIDCALL(SC_GetNextRtsCommand()); /* Verify results */ UtAssert_True(SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 1, "SC_OperData.HkPacket.Payload.RtsCmdErrCtr == 1"); - UtAssert_True(SC_OperData.RtsInfoTblAddr[0].CmdErrCtr == 1, "SC_OperData.RtsInfoTblAddr[0].CmdErrCtr == 1"); + UtAssert_UINT32_EQ(RtsInfoPtr->CmdErrCtr, 1); SC_Assert_ID_EQ(SC_OperData.HkPacket.Payload.LastRtsErrSeq, SC_OperData.RtsCtrlBlckAddr->CurrRtsNum); - UtAssert_True(SC_OperData.HkPacket.Payload.LastRtsErrCmd == - SC_OperData.RtsInfoTblAddr[0].NextCommandPtr + - ((SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD), - "SC_OperData.HkPacket.Payload.LastRtsErrCmd == SC_OperData.RtsInfoTblAddr[0].NextCommandPtr + " - "((SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD)"); + EntryOffsetVal += (SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD; + SC_Assert_IDX_VALUE(SC_OperData.HkPacket.Payload.LastRtsErrCmd, EntryOffsetVal); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_RTS_CMD_LNGTH_ERR_EID); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); @@ -409,16 +448,24 @@ void SC_GetNextRtsCommand_Test_ZeroCommandLength(void) SC_RtsEntryHeader_t *Entry; size_t MsgSize1; size_t MsgSize2; + uint32 EntryOffsetVal; SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_LAST_RTS_WITH_EVENTS - 1); + SC_RtsInfoEntry_t * RtsInfoPtr; + SC_AtsInfoTable_t * AtsInfoPtr; - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - Entry = (SC_RtsEntryHeader_t *)&SC_OperData.RtsTblAddr[SC_LAST_RTS_WITH_EVENTS - 1][0]; + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + + Entry = (SC_RtsEntryHeader_t *)SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST); + EntryOffsetVal = + SC_RTS_BUFF_SIZE32 - SC_RTS_HDR_WORDS - ((SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD) - 1; /* Set to generate error message SC_RTS_LNGTH_ERR_EID */ CFE_MSG_Init((CFE_MSG_Message_t *)Entry, CFE_SB_ValueToMsgId(SC_CMD_MID), SC_LAST_RTS_WITH_EVENTS - 1); @@ -431,11 +478,8 @@ void SC_GetNextRtsCommand_Test_ZeroCommandLength(void) /* Set so checksum will pass in SC_ProcessRtpCommand */ UT_SetDeferredRetcode(UT_KEY(CFE_MSG_ValidateChecksum), 1, true); - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; - - SC_OperData.RtsInfoTblAddr[0].NextCommandPtr = (SC_RTS_BUFF_SIZE - (SC_RTS_HDR_WORDS)) - - ((SC_PACKET_MAX_SIZE + SC_RTS_HEADER_SIZE + 1) / SC_BYTES_IN_WORD) - - 1; + AtsInfoPtr->NumberOfCommands = 1; + RtsInfoPtr->NextCommandPtr = SC_ENTRY_OFFSET_C(EntryOffsetVal); /* Execute the function being tested */ UtAssert_VOIDCALL(SC_GetNextRtsCommand()); @@ -450,16 +494,24 @@ void SC_GetNextRtsCommand_Test_ZeroCommandLengthLastRts(void) SC_RtsEntryHeader_t *Entry; size_t MsgSize1; size_t MsgSize2; + uint32 EntryOffsetVal; SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_LAST_RTS_WITH_EVENTS); + SC_RtsInfoEntry_t * RtsInfoPtr; + SC_AtsInfoTable_t * AtsInfoPtr; - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); + + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; - Entry = (SC_RtsEntryHeader_t *)&SC_OperData.RtsTblAddr[SC_LAST_RTS_WITH_EVENTS][0]; + Entry = (SC_RtsEntryHeader_t *)SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST); + EntryOffsetVal = + SC_RTS_BUFF_SIZE32 - SC_RTS_HDR_WORDS - ((SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD) - 1; /* Set to generate error message SC_RTS_LNGTH_ERR_EID */ CFE_MSG_Init((CFE_MSG_Message_t *)Entry, CFE_SB_ValueToMsgId(SC_CMD_MID), SC_PACKET_MIN_SIZE - 1); @@ -472,11 +524,8 @@ void SC_GetNextRtsCommand_Test_ZeroCommandLengthLastRts(void) /* Set so checksum will pass in SC_ProcessRtpCommand */ UT_SetDeferredRetcode(UT_KEY(CFE_MSG_ValidateChecksum), 1, true); - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; - - SC_OperData.RtsInfoTblAddr[0].NextCommandPtr = (SC_RTS_BUFF_SIZE - (SC_RTS_HDR_WORDS)) - - ((SC_PACKET_MAX_SIZE + SC_RTS_HEADER_SIZE + 1) / SC_BYTES_IN_WORD) - - 1; + AtsInfoPtr->NumberOfCommands = 1; + RtsInfoPtr->NextCommandPtr = SC_ENTRY_OFFSET_C(EntryOffsetVal); /* Execute the function being tested */ UtAssert_VOIDCALL(SC_GetNextRtsCommand()); @@ -489,16 +538,24 @@ void SC_GetNextRtsCommand_Test_EndOfBuffer(void) { SC_RtsEntryHeader_t *Entry; size_t MsgSize; + uint32 EntryOffsetVal; SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(0); + SC_RtsInfoEntry_t * RtsInfoPtr; + SC_AtsInfoTable_t * AtsInfoPtr; + + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; - Entry = (SC_RtsEntryHeader_t *)&SC_OperData.RtsTblAddr[0][0]; + Entry = (SC_RtsEntryHeader_t *)SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST); + EntryOffsetVal = + SC_RTS_BUFF_SIZE32 - SC_RTS_HDR_WORDS - ((SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD) - 1; /* Set to generate error message SC_RTS_LNGTH_ERR_EID */ CFE_MSG_Init((CFE_MSG_Message_t *)Entry, CFE_SB_ValueToMsgId(SC_CMD_MID), 2 * SC_RTS_BUFF_SIZE); @@ -509,11 +566,8 @@ void SC_GetNextRtsCommand_Test_EndOfBuffer(void) /* Set so checksum will pass in SC_ProcessRtpCommand */ UT_SetDeferredRetcode(UT_KEY(CFE_MSG_ValidateChecksum), 1, true); - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; - - SC_OperData.RtsInfoTblAddr[0].NextCommandPtr = (SC_RTS_BUFF_SIZE - (SC_RTS_HDR_WORDS)) - - ((SC_PACKET_MAX_SIZE + SC_RTS_HEADER_SIZE + 1) / SC_BYTES_IN_WORD) - - 1; + AtsInfoPtr->NumberOfCommands = 1; + RtsInfoPtr->NextCommandPtr = SC_ENTRY_OFFSET_C(EntryOffsetVal); /* Execute the function being tested */ UtAssert_VOIDCALL(SC_GetNextRtsCommand()); @@ -528,15 +582,23 @@ void SC_GetNextRtsCommand_Test_EndOfBufferLastRts(void) SC_RtsEntryHeader_t *Entry; size_t MsgSize; SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + uint32 EntryOffsetVal; SC_RtsIndex_t RtsIndex = SC_RTS_IDX_C(SC_LAST_RTS_WITH_EVENTS); + SC_RtsInfoEntry_t * RtsInfoPtr; + SC_AtsInfoTable_t * AtsInfoPtr; - SC_AppData.NextCmdTime[SC_Process_RTP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_RTP; - SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_Status_EXECUTING; + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + RtsInfoPtr = SC_GetRtsInfoObject(RtsIndex); - Entry = (SC_RtsEntryHeader_t *)&SC_OperData.RtsTblAddr[SC_LAST_RTS_WITH_EVENTS][0]; + SC_AppData.NextCmdTime[SC_Process_RTP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_RTP; + SC_OperData.RtsCtrlBlckAddr->CurrRtsNum = SC_RtsIndexToNum(RtsIndex); + RtsInfoPtr->RtsStatus = SC_Status_EXECUTING; + + Entry = (SC_RtsEntryHeader_t *)SC_GetRtsEntryAtOffset(RtsIndex, SC_ENTRY_OFFSET_FIRST); + EntryOffsetVal = + SC_RTS_BUFF_SIZE32 - SC_RTS_HDR_WORDS - ((SC_PACKET_MIN_SIZE + SC_RTS_HEADER_SIZE + 3) / SC_BYTES_IN_WORD) - 1; /* Set to generate error message SC_RTS_LNGTH_ERR_EID */ CFE_MSG_Init((CFE_MSG_Message_t *)Entry, CFE_SB_ValueToMsgId(SC_CMD_MID), 2 * SC_RTS_BUFF_SIZE); @@ -547,11 +609,8 @@ void SC_GetNextRtsCommand_Test_EndOfBufferLastRts(void) /* Set so checksum will pass in SC_ProcessRtpCommand */ UT_SetDeferredRetcode(UT_KEY(CFE_MSG_ValidateChecksum), 1, true); - SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands = 1; - - SC_OperData.RtsInfoTblAddr[0].NextCommandPtr = (SC_RTS_BUFF_SIZE - (SC_RTS_HDR_WORDS)) - - ((SC_PACKET_MAX_SIZE + SC_RTS_HEADER_SIZE + 1) / SC_BYTES_IN_WORD) - - 1; + AtsInfoPtr->NumberOfCommands = 1; + RtsInfoPtr->NextCommandPtr = SC_ENTRY_OFFSET_C(EntryOffsetVal); /* Execute the function being tested */ UtAssert_VOIDCALL(SC_GetNextRtsCommand()); @@ -594,32 +653,39 @@ void SC_GetNextAtsCommand_Test_Idle(void) void SC_GetNextAtsCommand_Test_GetNextCommand(void) { - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsInfoTable_t * AtsInfoPtr; + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[0][0]; - Entry->CmdNumber = SC_COMMAND_NUM_C(1); + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + AtsInfoPtr = SC_GetAtsInfoObject(AtsIndex); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); - SC_AppData.NextCmdTime[SC_Process_ATP] = 0; - SC_AppData.CurrentTime = 1; - SC_AppData.NextProcNumber = SC_Process_ATP; - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); + Entry->CmdNumber = SC_COMMAND_NUM_C(1); - SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); - SC_AppData.AtsTimeIndexBuffer[0][0] = 1; - SC_AppData.AtsTimeIndexBuffer[0][1] = 2; + SC_AppData.NextCmdTime[SC_Process_ATP] = 0; + SC_AppData.CurrentTime = 1; + SC_AppData.NextProcNumber = SC_Process_ATP; + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_Status_EXECUTING; + SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_AtsIndexToNum(AtsIndex); + SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_C(0))->CmdNum = SC_COMMAND_NUM_C(1); + SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_C(1))->CmdNum = SC_COMMAND_NUM_C(2); - SC_OperData.AtsCmdStatusTblAddr[0][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[0][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; - SC_OperData.AtsInfoTblAddr[SC_Process_ATP].NumberOfCommands = 100; + AtsInfoPtr->NumberOfCommands = 100; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_GetNextAtsCommand()); /* Verify results */ SC_Assert_IDX_VALUE(SC_OperData.AtsCtrlBlckAddr->TimeIndexPtr, 1); - UtAssert_INT32_EQ(SC_OperData.AtsCtrlBlckAddr->CmdNumber, SC_AppData.AtsTimeIndexBuffer[0][1]); + SC_Assert_ID_EQ(SC_OperData.AtsCtrlBlckAddr->CmdNumber, + SC_GetAtsCommandNumAtSeq(AtsIndex, SC_SEQUENCE_IDX_C(1))->CmdNum); UtAssert_INT32_EQ(SC_AppData.NextCmdTime[SC_Process_ATP], 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -627,10 +693,15 @@ void SC_GetNextAtsCommand_Test_GetNextCommand(void) void SC_GetNextAtsCommand_Test_ExecutionACompleted(void) { - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsEntryHeader_t * Entry; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(0); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[0][0]; + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); + + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextCmdTime[SC_Process_ATP] = 0; @@ -641,8 +712,8 @@ void SC_GetNextAtsCommand_Test_ExecutionACompleted(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(2); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(0); - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[AtsIndex][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_GetNextAtsCommand()); @@ -654,10 +725,15 @@ void SC_GetNextAtsCommand_Test_ExecutionACompleted(void) void SC_GetNextAtsCommand_Test_ExecutionBCompleted(void) { - SC_AtsEntryHeader_t *Entry; - SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_AtsEntryHeader_t * Entry; + SC_AtsIndex_t AtsIndex = SC_ATS_IDX_C(1); + SC_AtsCmdStatusEntry_t * StatusEntryPtr; + SC_AtsCmdEntryOffsetRecord_t *CmdOffsetRec; + + CmdOffsetRec = SC_GetAtsEntryOffsetForCmd(AtsIndex, SC_COMMAND_IDX_C(0)); + StatusEntryPtr = SC_GetAtsStatusEntryForCommand(AtsIndex, SC_COMMAND_IDX_C(0)); - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[0][0]; + Entry = (SC_AtsEntryHeader_t *)SC_GetAtsEntryAtOffset(AtsIndex, SC_ENTRY_OFFSET_FIRST); Entry->CmdNumber = SC_COMMAND_NUM_C(1); SC_AppData.NextCmdTime[SC_Process_ATP] = 0; @@ -668,8 +744,8 @@ void SC_GetNextAtsCommand_Test_ExecutionBCompleted(void) SC_OperData.AtsCtrlBlckAddr->CurrAtsNum = SC_ATS_NUM_C(1); SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_COMMAND_NUM_C(0); - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][0] = SC_Status_LOADED; - SC_AppData.AtsCmdIndexBuffer[AtsIndex][0] = 0; + StatusEntryPtr->Status = SC_Status_LOADED; + CmdOffsetRec->Offset = SC_ENTRY_OFFSET_FIRST; /* Execute the function being tested */ UtAssert_VOIDCALL(SC_GetNextAtsCommand()); diff --git a/unit-test/utilities/sc_test_utils.c b/unit-test/utilities/sc_test_utils.c index 6f3bb25..19fb503 100644 --- a/unit-test/utilities/sc_test_utils.c +++ b/unit-test/utilities/sc_test_utils.c @@ -41,14 +41,14 @@ CFE_ES_WriteToSysLog_context_t context_CFE_ES_WriteToSysLog; UT_CmdBuf_t UT_CmdBuf; /* Table buffers */ -uint32 AtsTblAddr[SC_NUMBER_OF_ATS][SC_ATS_BUFF_SIZE32]; -uint32 AppendTblAddr[SC_APPEND_BUFF_SIZE32]; -uint32 RtsTblAddr[SC_NUMBER_OF_RTS][SC_RTS_BUFF_SIZE32]; -SC_AtsInfoTable_t AtsInfoTblAddr[SC_NUMBER_OF_ATS]; -SC_RtsInfoEntry_t RtsInfoTblAddr[SC_NUMBER_OF_RTS]; -SC_RtpControlBlock_t RtsCtrlBlckAddr; -SC_AtpControlBlock_t AtsCtrlBlckAddr; -SC_Status_Enum_t AtsCmdStatusTblAddr[SC_NUMBER_OF_ATS][SC_MAX_ATS_CMDS]; +uint32 AtsTblAddr[SC_NUMBER_OF_ATS][SC_ATS_BUFF_SIZE32]; +uint32 AppendTblAddr[SC_APPEND_BUFF_SIZE32]; +uint32 RtsTblAddr[SC_NUMBER_OF_RTS][SC_RTS_BUFF_SIZE32]; +SC_AtsInfoTable_t AtsInfoTblAddr[SC_NUMBER_OF_ATS]; +SC_RtsInfoEntry_t RtsInfoTblAddr[SC_NUMBER_OF_RTS]; +SC_RtpControlBlock_t RtsCtrlBlckAddr; +SC_AtpControlBlock_t AtsCtrlBlckAddr; +SC_AtsCmdStatusEntry_t AtsCmdStatusTblAddr[SC_NUMBER_OF_ATS][SC_MAX_ATS_CMDS]; /* * Function Definitions diff --git a/unit-test/utilities/sc_test_utils.h b/unit-test/utilities/sc_test_utils.h index c84aa9b..f181472 100644 --- a/unit-test/utilities/sc_test_utils.h +++ b/unit-test/utilities/sc_test_utils.h @@ -102,6 +102,10 @@ extern UT_CmdBuf_t UT_CmdBuf; UtAssert_GenericUnsignedCompare(SC_IDX_AS_UINT(actual), UtAssert_Compare_EQ, (unsigned int)(ref), \ UtAssert_Radix_DECIMAL, __FILE__, __LINE__, "IDXV", #actual, #ref) +#define SC_Assert_CmdStatus(actual, ref) \ + UtAssert_GenericUnsignedCompare((unsigned long)(actual), UtAssert_Compare_EQ, (unsigned long)(ref), \ + UtAssert_Radix_DECIMAL, __FILE__, __LINE__, "Status", #actual, #ref) + /* * Function Definitions */