diff --git a/fsw/src/sc_atsrq.c b/fsw/src/sc_atsrq.c index 8a7c7d2..0e6a120 100644 --- a/fsw/src/sc_atsrq.c +++ b/fsw/src/sc_atsrq.c @@ -52,72 +52,72 @@ void SC_StartAtsCmd(const CFE_SB_Buffer_t *BufPtr) uint16 AtsId; /* ATS ID */ uint16 AtsIndex; /* ATS array index */ - AtsId = ((SC_StartAtsCmd_t *)BufPtr)->AtsId; + AtsId = ((SC_StartAtsCmd_t *)BufPtr)->AtsId; - /* validate ATS ID */ - if ((AtsId > 0) && (AtsId <= SC_NUMBER_OF_ATS)) - { - /* convert ATS ID to array index */ - AtsIndex = SC_ATS_ID_TO_INDEX(AtsId); + /* validate ATS ID */ + if ((AtsId > 0) && (AtsId <= SC_NUMBER_OF_ATS)) + { + /* convert ATS ID to array index */ + AtsIndex = SC_ATS_ID_TO_INDEX(AtsId); - /* make sure that there is no ATS running on the ATP */ - if (SC_OperData.AtsCtrlBlckAddr->AtpState == SC_IDLE) + /* make sure that there is no ATS running on the ATP */ + if (SC_OperData.AtsCtrlBlckAddr->AtpState == SC_IDLE) + { + /* make sure the specified ATS is ready */ + if (SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands > 0) { - /* make sure the specified ATS is ready */ - if (SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands > 0) + /* start the ats */ + if (SC_BeginAts(AtsIndex, 0)) { - /* start the ats */ - if (SC_BeginAts(AtsIndex, 0)) - { - /* finish the ATP control block .. */ - SC_OperData.AtsCtrlBlckAddr->AtpState = SC_EXECUTING; - - /* increment the command request counter */ - SC_OperData.HkPacket.CmdCtr++; - - CFE_EVS_SendEvent(SC_STARTATS_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, - "ATS %c Execution Started", (AtsIndex ? 'B' : 'A')); - } - else - { /* could not start the ats, all commands were skipped */ - /* event message was sent from SC_BeginAts */ - /* increment the command request error counter */ - /* SC_OperData.AtsCtrlBlckAddr->AtpState is updated in SC_KillAts */ - SC_OperData.HkPacket.CmdErrCtr++; - - } /* end if */ - } - else - { /* the ats didn't have any commands in it */ + /* finish the ATP control block .. */ + SC_OperData.AtsCtrlBlckAddr->AtpState = SC_EXECUTING; - CFE_EVS_SendEvent(SC_STARTATS_CMD_NOT_LDED_ERR_EID, CFE_EVS_EventType_ERROR, - "Start ATS Rejected: ATS %c Not Loaded", (AtsIndex ? 'B' : 'A')); + /* increment the command request counter */ + SC_OperData.HkPacket.CmdCtr++; + CFE_EVS_SendEvent(SC_STARTATS_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, + "ATS %c Execution Started", (AtsIndex ? 'B' : 'A')); + } + else + { /* could not start the ats, all commands were skipped */ + /* event message was sent from SC_BeginAts */ /* increment the command request error counter */ + /* SC_OperData.AtsCtrlBlckAddr->AtpState is updated in SC_KillAts */ SC_OperData.HkPacket.CmdErrCtr++; } /* end if */ } else - { /* the ATS is being used */ + { /* the ats didn't have any commands in it */ + + CFE_EVS_SendEvent(SC_STARTATS_CMD_NOT_LDED_ERR_EID, CFE_EVS_EventType_ERROR, + "Start ATS Rejected: ATS %c Not Loaded", (AtsIndex ? 'B' : 'A')); - CFE_EVS_SendEvent(SC_STARTATS_CMD_NOT_IDLE_ERR_EID, CFE_EVS_EventType_ERROR, - "Start ATS Rejected: ATP is not Idle"); /* increment the command request error counter */ SC_OperData.HkPacket.CmdErrCtr++; } /* end if */ } else - { /* the specified ATS id is not valid */ - - CFE_EVS_SendEvent(SC_STARTATS_CMD_INVLD_ID_ERR_EID, CFE_EVS_EventType_ERROR, - "Start ATS %d Rejected: Invalid ATS ID", AtsId); + { /* the ATS is being used */ + CFE_EVS_SendEvent(SC_STARTATS_CMD_NOT_IDLE_ERR_EID, CFE_EVS_EventType_ERROR, + "Start ATS Rejected: ATP is not Idle"); /* increment the command request error counter */ SC_OperData.HkPacket.CmdErrCtr++; } /* end if */ + } + else + { /* the specified ATS id is not valid */ + + CFE_EVS_SendEvent(SC_STARTATS_CMD_INVLD_ID_ERR_EID, CFE_EVS_EventType_ERROR, + "Start ATS %d Rejected: Invalid ATS ID", AtsId); + + /* increment the command request error counter */ + SC_OperData.HkPacket.CmdErrCtr++; + + } /* end if */ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -130,40 +130,40 @@ void SC_StopAtsCmd(const CFE_SB_Buffer_t *BufPtr) char TempAtsChar = ' '; int32 Result = SC_ERROR; - /* - ** Set the temp ATS ID if it is valid - */ - if (SC_OperData.AtsCtrlBlckAddr->AtsNumber == SC_ATSA) + /* + ** Set the temp ATS ID if it is valid + */ + if (SC_OperData.AtsCtrlBlckAddr->AtsNumber == SC_ATSA) + { + TempAtsChar = 'A'; + Result = CFE_SUCCESS; + } + else + { + if (SC_OperData.AtsCtrlBlckAddr->AtsNumber == SC_ATSB) { - TempAtsChar = 'A'; + TempAtsChar = 'B'; Result = CFE_SUCCESS; } - else - { - if (SC_OperData.AtsCtrlBlckAddr->AtsNumber == SC_ATSB) - { - TempAtsChar = 'B'; - Result = CFE_SUCCESS; - } - } + } - if (Result == CFE_SUCCESS) - { - CFE_EVS_SendEvent(SC_STOPATS_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, "ATS %c stopped", TempAtsChar); - } - else - { - CFE_EVS_SendEvent(SC_STOPATS_NO_ATS_INF_EID, CFE_EVS_EventType_INFORMATION, - "There is no ATS running to stop"); - } + if (Result == CFE_SUCCESS) + { + CFE_EVS_SendEvent(SC_STOPATS_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, "ATS %c stopped", TempAtsChar); + } + else + { + CFE_EVS_SendEvent(SC_STOPATS_NO_ATS_INF_EID, CFE_EVS_EventType_INFORMATION, + "There is no ATS running to stop"); + } - /* Stop the ATS from executing */ - SC_KillAts(); + /* Stop the ATS from executing */ + SC_KillAts(); - /* clear the global switch pend flag */ - SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = false; + /* clear the global switch pend flag */ + SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = false; - SC_OperData.HkPacket.CmdCtr++; + SC_OperData.HkPacket.CmdCtr++; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -315,28 +315,28 @@ void SC_GroundSwitchCmd(const CFE_SB_Buffer_t *BufPtr) else { /* the other ATS does not have any commands in it */ - CFE_EVS_SendEvent(SC_SWITCH_ATS_CMD_NOT_LDED_ERR_EID, CFE_EVS_EventType_ERROR, - "Switch ATS Failure: Destination ATS Not Loaded"); + CFE_EVS_SendEvent(SC_SWITCH_ATS_CMD_NOT_LDED_ERR_EID, CFE_EVS_EventType_ERROR, + "Switch ATS Failure: Destination ATS Not Loaded"); - /* update command error counter */ - SC_OperData.HkPacket.CmdErrCtr++; + /* update command error counter */ + SC_OperData.HkPacket.CmdErrCtr++; - SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = false; + SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = false; - } /* end if */ - } - else - { /* the ATP is not currently executing any commands */ + } /* end if */ + } + else + { /* the ATP is not currently executing any commands */ - CFE_EVS_SendEvent(SC_SWITCH_ATS_CMD_IDLE_ERR_EID, CFE_EVS_EventType_ERROR, - "Switch ATS Rejected: ATP is idle"); + CFE_EVS_SendEvent(SC_SWITCH_ATS_CMD_IDLE_ERR_EID, CFE_EVS_EventType_ERROR, + "Switch ATS Rejected: ATP is idle"); - /* update the command error counter */ - SC_OperData.HkPacket.CmdErrCtr++; + /* update the command error counter */ + SC_OperData.HkPacket.CmdErrCtr++; - SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = false; + SC_OperData.AtsCtrlBlckAddr->SwitchPendFlag = false; - } /* end if */ + } /* end if */ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -495,112 +495,113 @@ void SC_JumpAtsCmd(const CFE_SB_Buffer_t *BufPtr) CFE_TIME_SysTime_t NewTime; uint16 NumSkipped; - if (SC_OperData.AtsCtrlBlckAddr->AtpState == SC_EXECUTING) - { - JumpTime = ((SC_JumpAtsCmd_t *)BufPtr)->NewTime; - AtsIndex = SC_ATS_NUM_TO_INDEX(SC_OperData.AtsCtrlBlckAddr->AtsNumber); + if (SC_OperData.AtsCtrlBlckAddr->AtpState == SC_EXECUTING) + { + JumpTime = ((SC_JumpAtsCmd_t *)BufPtr)->NewTime; + AtsIndex = SC_ATS_NUM_TO_INDEX(SC_OperData.AtsCtrlBlckAddr->AtsNumber); - /* - ** Loop through the commands until a time tag is found - ** that has a time greater than or equal to the current time OR - ** all of the commands have been skipped - */ - TimeIndex = 0; - NumSkipped = 0; + /* + ** Loop through the commands until a time tag is found + ** that has a time greater than or equal to the current time OR + ** all of the commands have been skipped + */ + TimeIndex = 0; + NumSkipped = 0; - while (TimeIndex < SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands) + while (TimeIndex < SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands) + { + /* first get the cmd index at this list entry */ + CmdIndex = SC_ATS_CMD_NUM_TO_INDEX(SC_AppData.AtsTimeIndexBuffer[AtsIndex][TimeIndex]); + /* then get the entry index from the cmd index table */ + EntryIndex = SC_AppData.AtsCmdIndexBuffer[AtsIndex][CmdIndex]; + /* then get a pointer to the ATS entry data */ + Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][EntryIndex]; + /* then get cmd execution time from the ATS entry */ + ListCmdTime = SC_GetAtsEntryTime(Entry); + + /* compare ATS jump time to this list entry time */ + if (SC_CompareAbsTime(JumpTime, ListCmdTime)) { - /* first get the cmd index at this list entry */ - CmdIndex = SC_ATS_CMD_NUM_TO_INDEX(SC_AppData.AtsTimeIndexBuffer[AtsIndex][TimeIndex]); - /* then get the entry index from the cmd index table */ - EntryIndex = SC_AppData.AtsCmdIndexBuffer[AtsIndex][CmdIndex]; - /* then get a pointer to the ATS entry data */ - Entry = (SC_AtsEntryHeader_t *)&SC_OperData.AtsTblAddr[AtsIndex][EntryIndex]; - /* then get cmd execution time from the ATS entry */ - ListCmdTime = SC_GetAtsEntryTime(Entry); - - /* compare ATS jump time to this list entry time */ - if (SC_CompareAbsTime(JumpTime, ListCmdTime)) - { - /* jump time is greater than this list entry time */ - - /* - ** If the ATS command is loaded and ready to run, then - ** mark the command as being skipped - ** if the command has any other status, SC_SKIPPED, SC_EXECUTED, - ** etc, then leave the status alone. - */ - if (SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] == SC_LOADED) - { - SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] = SC_SKIPPED; - NumSkipped++; - } - - TimeIndex++; - } - else + /* jump time is greater than this list entry time */ + + /* + ** If the ATS command is loaded and ready to run, then + ** mark the command as being skipped + ** if the command has any other status, SC_SKIPPED, SC_EXECUTED, + ** etc, then leave the status alone. + */ + if (SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] == SC_LOADED) { - /* jump time is less than or equal to this list entry */ - CFE_EVS_SendEvent(SC_JUMPATS_CMD_LIST_INF_EID, CFE_EVS_EventType_INFORMATION, - "Jump Cmd: Jump time less than or equal to list entry %d", CmdIndex); - break; + SC_OperData.AtsCmdStatusTblAddr[AtsIndex][CmdIndex] = SC_SKIPPED; + NumSkipped++; } - } - /* - ** Check to see if the whole ATS was skipped - */ - if (TimeIndex == SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands) - { - CFE_EVS_SendEvent(SC_JUMPATS_CMD_STOPPED_ERR_EID, CFE_EVS_EventType_ERROR, - "Jump Cmd: All ATS commands were skipped, ATS stopped"); - - SC_OperData.HkPacket.CmdErrCtr++; - - /* stop the ats */ - SC_KillAts(); + TimeIndex++; } else - { /* there is at least one command to execute */ + { + /* jump time is less than or equal to this list entry */ + CFE_EVS_SendEvent(SC_JUMPATS_CMD_LIST_INF_EID, CFE_EVS_EventType_INFORMATION, + "Jump Cmd: Jump time less than or equal to list entry %d", CmdIndex); + break; + } + } - /* - ** Update the ATP Control Block entries. - */ - SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_ATS_CMD_INDEX_TO_NUM(CmdIndex); - SC_OperData.AtsCtrlBlckAddr->TimeIndexPtr = TimeIndex; + /* + ** Check to see if the whole ATS was skipped + */ + if (TimeIndex == SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands) + { + CFE_EVS_SendEvent(SC_JUMPATS_CMD_STOPPED_ERR_EID, CFE_EVS_EventType_ERROR, + "Jump Cmd: All ATS commands were skipped, ATS stopped"); - /* - ** Set the next command time for the ATP - */ - SC_AppData.NextCmdTime[SC_ATP] = ListCmdTime; + SC_OperData.HkPacket.CmdErrCtr++; - SC_OperData.HkPacket.CmdCtr++; + /* stop the ats */ + SC_KillAts(); + } + else + { /* there is at least one command to execute */ - /* print out the date in a readable format */ - NewTime.Seconds = ListCmdTime; - NewTime.Subseconds = 0; + /* + ** Update the ATP Control Block entries. + */ + SC_OperData.AtsCtrlBlckAddr->CmdNumber = SC_ATS_CMD_INDEX_TO_NUM(CmdIndex); + SC_OperData.AtsCtrlBlckAddr->TimeIndexPtr = TimeIndex; - CFE_TIME_Print((char *)&TimeBuffer, NewTime); + /* + ** Set the next command time for the ATP + */ + SC_AppData.NextCmdTime[SC_ATP] = ListCmdTime; - CFE_EVS_SendEvent(SC_JUMP_ATS_INF_EID, CFE_EVS_EventType_INFORMATION, - "Next ATS command time in the ATP was set to %s", TimeBuffer); - if (NumSkipped > 0) - { - /* We skipped come commands, but not all of them */ - CFE_EVS_SendEvent(SC_JUMP_ATS_SKIPPED_DBG_EID, CFE_EVS_EventType_DEBUG, - "Jump Cmd: Skipped %d ATS commands", NumSkipped); - } + SC_OperData.HkPacket.CmdCtr++; - } /* end if */ - } - else - { /* There is not a running ATS */ + /* print out the date in a readable format */ + NewTime.Seconds = ListCmdTime; + NewTime.Subseconds = 0; - CFE_EVS_SendEvent(SC_JUMPATS_CMD_NOT_ACT_ERR_EID, CFE_EVS_EventType_ERROR, - "ATS Jump Failed: No active ATS"); - SC_OperData.HkPacket.CmdErrCtr++; + CFE_TIME_Print((char *)&TimeBuffer, NewTime); + + CFE_EVS_SendEvent(SC_JUMP_ATS_INF_EID, CFE_EVS_EventType_INFORMATION, + "Next ATS command time in the ATP was set to %s", TimeBuffer); + if (NumSkipped > 0) + { + /* We skipped come commands, but not all of them */ + CFE_EVS_SendEvent(SC_JUMP_ATS_SKIPPED_DBG_EID, CFE_EVS_EventType_DEBUG, + "Jump Cmd: Skipped %d ATS commands", NumSkipped); + } } /* end if */ + } + + else + { /* There is not a running ATS */ + + CFE_EVS_SendEvent(SC_JUMPATS_CMD_NOT_ACT_ERR_EID, CFE_EVS_EventType_ERROR, + "ATS Jump Failed: No active ATS"); + SC_OperData.HkPacket.CmdErrCtr++; + + } /* end if */ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -612,24 +613,24 @@ void SC_ContinueAtsOnFailureCmd(const CFE_SB_Buffer_t *BufPtr) { uint16 State; - State = ((SC_SetContinueAtsOnFailureCmd_t *)BufPtr)->ContinueState; + State = ((SC_SetContinueAtsOnFailureCmd_t *)BufPtr)->ContinueState; - if (State != SC_CONTINUE_TRUE && State != SC_CONTINUE_FALSE) - { - SC_OperData.HkPacket.CmdErrCtr++; + if (State != SC_CONTINUE_TRUE && State != SC_CONTINUE_FALSE) + { + SC_OperData.HkPacket.CmdErrCtr++; - CFE_EVS_SendEvent(SC_CONT_CMD_ERR_EID, CFE_EVS_EventType_ERROR, - "Continue ATS On Failure command failed, invalid state: %d", State); - } - else - { - SC_OperData.HkPacket.ContinueAtsOnFailureFlag = State; + CFE_EVS_SendEvent(SC_CONT_CMD_ERR_EID, CFE_EVS_EventType_ERROR, + "Continue ATS On Failure command failed, invalid state: %d", State); + } + else + { + SC_OperData.HkPacket.ContinueAtsOnFailureFlag = State; - SC_OperData.HkPacket.CmdCtr++; + SC_OperData.HkPacket.CmdCtr++; - CFE_EVS_SendEvent(SC_CONT_CMD_DEB_EID, CFE_EVS_EventType_DEBUG, - "Continue-ATS-On-Failure command, State: %d", State); - } + CFE_EVS_SendEvent(SC_CONT_CMD_DEB_EID, CFE_EVS_EventType_DEBUG, + "Continue-ATS-On-Failure command, State: %d", State); + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -642,59 +643,59 @@ void SC_AppendAtsCmd(const CFE_SB_Buffer_t *BufPtr) SC_AppendAtsCmd_t *AppendCmd = (SC_AppendAtsCmd_t *)BufPtr; uint16 AtsIndex; /* index (not ID) of target ATS */ - if ((AppendCmd->AtsId == 0) || (AppendCmd->AtsId > SC_NUMBER_OF_ATS)) - { - /* invalid target ATS selection */ - SC_OperData.HkPacket.CmdErrCtr++; + if ((AppendCmd->AtsId == 0) || (AppendCmd->AtsId > SC_NUMBER_OF_ATS)) + { + /* invalid target ATS selection */ + SC_OperData.HkPacket.CmdErrCtr++; - CFE_EVS_SendEvent(SC_APPEND_CMD_ARG_ERR_EID, CFE_EVS_EventType_ERROR, - "Append ATS error: invalid ATS ID = %d", AppendCmd->AtsId); + CFE_EVS_SendEvent(SC_APPEND_CMD_ARG_ERR_EID, CFE_EVS_EventType_ERROR, + "Append ATS error: invalid ATS ID = %d", AppendCmd->AtsId); - return; - } + return; + } - /* create base zero array index from base one ID value */ - AtsIndex = SC_ATS_ID_TO_INDEX(AppendCmd->AtsId); + /* create base zero array index from base one ID value */ + AtsIndex = SC_ATS_ID_TO_INDEX(AppendCmd->AtsId); - if (SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands == 0) - { - /* target ATS table is empty */ - SC_OperData.HkPacket.CmdErrCtr++; + if (SC_OperData.AtsInfoTblAddr[AtsIndex].NumberOfCommands == 0) + { + /* target ATS table is empty */ + SC_OperData.HkPacket.CmdErrCtr++; - CFE_EVS_SendEvent(SC_APPEND_CMD_TGT_ERR_EID, CFE_EVS_EventType_ERROR, - "Append ATS %c error: ATS table is empty", 'A' + AtsIndex); - } - else if (SC_OperData.HkPacket.AppendEntryCount == 0) - { - /* append table is empty */ - SC_OperData.HkPacket.CmdErrCtr++; + CFE_EVS_SendEvent(SC_APPEND_CMD_TGT_ERR_EID, CFE_EVS_EventType_ERROR, + "Append ATS %c error: ATS table is empty", 'A' + AtsIndex); + } + else if (SC_OperData.HkPacket.AppendEntryCount == 0) + { + /* append table is empty */ + SC_OperData.HkPacket.CmdErrCtr++; - 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) - { - /* not enough room in ATS buffer for Append table data */ - SC_OperData.HkPacket.CmdErrCtr++; + 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) + { + /* not enough room in ATS buffer for Append table data */ + SC_OperData.HkPacket.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); - } - else - { - /* store ATS selection from most recent ATS Append command */ - SC_OperData.HkPacket.AppendCmdArg = AppendCmd->AtsId; + 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); + } + else + { + /* store ATS selection from most recent ATS Append command */ + SC_OperData.HkPacket.AppendCmdArg = AppendCmd->AtsId; - /* copy append data and re-calc timing data */ - SC_ProcessAppend(AtsIndex); + /* copy append data and re-calc timing data */ + SC_ProcessAppend(AtsIndex); - /* increment command success counter */ - SC_OperData.HkPacket.CmdCtr++; + /* increment command success counter */ + SC_OperData.HkPacket.CmdCtr++; - CFE_EVS_SendEvent(SC_APPEND_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, - "Append ATS %c command: %d ATS entries appended", 'A' + AtsIndex, - SC_OperData.HkPacket.AppendEntryCount); - } + CFE_EVS_SendEvent(SC_APPEND_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, + "Append ATS %c command: %d ATS entries appended", 'A' + AtsIndex, + SC_OperData.HkPacket.AppendEntryCount); + } } diff --git a/fsw/src/sc_cmds.c b/fsw/src/sc_cmds.c index 76feb59..d678cce 100644 --- a/fsw/src/sc_cmds.c +++ b/fsw/src/sc_cmds.c @@ -475,16 +475,16 @@ void SC_SendHkPacket(void) void SC_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr) { - CFE_EVS_SendEvent(SC_RESET_DEB_EID, CFE_EVS_EventType_DEBUG, "Reset counters command"); - - SC_OperData.HkPacket.CmdCtr = 0; - SC_OperData.HkPacket.CmdErrCtr = 0; - SC_OperData.HkPacket.AtsCmdCtr = 0; - SC_OperData.HkPacket.AtsCmdErrCtr = 0; - SC_OperData.HkPacket.RtsCmdCtr = 0; - SC_OperData.HkPacket.RtsCmdErrCtr = 0; - SC_OperData.HkPacket.RtsActiveCtr = 0; - SC_OperData.HkPacket.RtsActiveErrCtr = 0; + CFE_EVS_SendEvent(SC_RESET_DEB_EID, CFE_EVS_EventType_DEBUG, "Reset counters command"); + + SC_OperData.HkPacket.CmdCtr = 0; + SC_OperData.HkPacket.CmdErrCtr = 0; + SC_OperData.HkPacket.AtsCmdCtr = 0; + SC_OperData.HkPacket.AtsCmdErrCtr = 0; + SC_OperData.HkPacket.RtsCmdCtr = 0; + SC_OperData.HkPacket.RtsCmdErrCtr = 0; + SC_OperData.HkPacket.RtsActiveCtr = 0; + SC_OperData.HkPacket.RtsActiveErrCtr = 0; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -494,9 +494,9 @@ void SC_ResetCountersCmd(const CFE_SB_Buffer_t *BufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SC_NoOpCmd(const CFE_SB_Buffer_t *BufPtr) { - SC_OperData.HkPacket.CmdCtr++; - CFE_EVS_SendEvent(SC_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command. Version %d.%d.%d.%d", - SC_MAJOR_VERSION, SC_MINOR_VERSION, SC_REVISION, SC_MISSION_REV); + SC_OperData.HkPacket.CmdCtr++; + CFE_EVS_SendEvent(SC_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command. Version %d.%d.%d.%d", + SC_MAJOR_VERSION, SC_MINOR_VERSION, SC_REVISION, SC_MISSION_REV); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/fsw/src/sc_rtsrq.c b/fsw/src/sc_rtsrq.c index bee3dd4..d45b998 100644 --- a/fsw/src/sc_rtsrq.c +++ b/fsw/src/sc_rtsrq.c @@ -56,97 +56,87 @@ void SC_StartRtsCmd(const CFE_SB_Buffer_t *CmdPacket) CFE_MSG_Message_t * RtsEntryCmd; /* pointer to an rts command */ CFE_MSG_Size_t CmdLength = 0; /* the length of the 1st cmd */ - /* - ** Check start RTS parameters - */ - RtsId = ((SC_RtsCmd_t *)CmdPacket)->RtsId; + /* + ** Check start RTS parameters + */ + RtsId = ((SC_RtsCmd_t *)CmdPacket)->RtsId; - if ((RtsId > 0) && (RtsId <= SC_NUMBER_OF_RTS)) - { - /* convert RTS ID to RTS array index */ - RtsIndex = SC_RTS_ID_TO_INDEX(RtsId); + if ((RtsId > 0) && (RtsId <= SC_NUMBER_OF_RTS)) + { + /* convert RTS ID to RTS array index */ + RtsIndex = SC_RTS_ID_TO_INDEX(RtsId); - /* make sure that RTS is not disabled */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false) + /* make sure that RTS is not disabled */ + if (SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false) + { + /* the requested RTS is not being used and is not empty */ + if (SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_LOADED) { - /* the requested RTS is not being used and is not empty */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_LOADED) + /* + ** Check the command length + */ + RtsEntryPtr = (SC_RtsEntryHeader_t *)SC_OperData.RtsTblAddr[RtsIndex]; + RtsEntryCmd = (CFE_MSG_Message_t *)((uint8_t *)RtsEntryPtr + SC_RTS_HEADER_SIZE); + + CFE_MSG_GetSize(RtsEntryCmd, &CmdLength); + + /* Make sure the command is big enough, but not too big */ + if (CmdLength >= SC_PACKET_MIN_SIZE && CmdLength <= SC_PACKET_MAX_SIZE) { /* - ** Check the command length - */ - RtsEntryPtr = (SC_RtsEntryHeader_t *)SC_OperData.RtsTblAddr[RtsIndex]; - RtsEntryCmd = (CFE_MSG_Message_t *)((uint8_t *)RtsEntryPtr + SC_RTS_HEADER_SIZE); + ** Initialize the RTS info table entry + */ + SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_EXECUTING; + SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr = 0; + SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr = 0; + SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr = 0; + SC_OperData.RtsInfoTblAddr[RtsIndex].UseCtr++; - CFE_MSG_GetSize(RtsEntryCmd, &CmdLength); + /* + ** 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); - /* Make sure the command is big enough, but not too big */ - if (CmdLength >= SC_PACKET_MIN_SIZE && CmdLength <= SC_PACKET_MAX_SIZE) + /* + ** Last, Increment some global counters associated with the + ** starting of the RTS + */ + SC_OperData.RtsCtrlBlckAddr->NumRtsActive++; + SC_OperData.HkPacket.RtsActiveCtr++; + SC_OperData.HkPacket.CmdCtr++; + + if (((SC_RtsCmd_t *)CmdPacket)->RtsId <= SC_LAST_RTS_WITH_EVENTS) { - /* - ** Initialize the RTS info table entry - */ - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_EXECUTING; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].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); - - /* - ** Last, Increment some global counters associated with the - ** starting of the RTS - */ - SC_OperData.RtsCtrlBlckAddr->NumRtsActive++; - SC_OperData.HkPacket.RtsActiveCtr++; - SC_OperData.HkPacket.CmdCtr++; - - if (((SC_RtsCmd_t *)CmdPacket)->RtsId <= SC_LAST_RTS_WITH_EVENTS) - { - CFE_EVS_SendEvent(SC_RTS_START_INF_EID, CFE_EVS_EventType_INFORMATION, - "RTS Number %03d Started", RtsId); - } - else - { - CFE_EVS_SendEvent(SC_STARTRTS_CMD_DBG_EID, CFE_EVS_EventType_DEBUG, "Start RTS #%d command", - RtsId); - } + CFE_EVS_SendEvent(SC_RTS_START_INF_EID, CFE_EVS_EventType_INFORMATION, + "RTS Number %03d Started", RtsId); } else - { /* the length field of the 1st cmd was bad */ - CFE_EVS_SendEvent( - SC_STARTRTS_CMD_INVLD_LEN_ERR_EID, CFE_EVS_EventType_ERROR, - "Start RTS %03d Rejected: Invld Len Field for 1st Cmd in Sequence. Invld Cmd Length = %d", - RtsId, (int)CmdLength); - - SC_OperData.HkPacket.CmdErrCtr++; - SC_OperData.HkPacket.RtsActiveErrCtr++; - - } /* end if - check command number */ + { + CFE_EVS_SendEvent(SC_STARTRTS_CMD_DBG_EID, CFE_EVS_EventType_DEBUG, "Start RTS #%d command", + RtsId); + } } else - { /* Cannot use the RTS now */ - - 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", - ((SC_RtsCmd_t *)CmdPacket)->RtsId, - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus); + { /* the length field of the 1st cmd was bad */ + CFE_EVS_SendEvent( + SC_STARTRTS_CMD_INVLD_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + "Start RTS %03d Rejected: Invld Len Field for 1st Cmd in Sequence. Invld Cmd Length = %d", + RtsId, (int)CmdLength); SC_OperData.HkPacket.CmdErrCtr++; SC_OperData.HkPacket.RtsActiveErrCtr++; - } /* end if */ + } /* end if - check command number */ } else - { /* the RTS is disabled */ - CFE_EVS_SendEvent(SC_STARTRTS_CMD_DISABLED_ERR_EID, CFE_EVS_EventType_ERROR, - "Start RTS %03d Rejected: RTS Disabled", RtsId); + { /* Cannot use the RTS now */ + + 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", + ((SC_RtsCmd_t *)CmdPacket)->RtsId, + SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus); SC_OperData.HkPacket.CmdErrCtr++; SC_OperData.HkPacket.RtsActiveErrCtr++; @@ -154,13 +144,22 @@ void SC_StartRtsCmd(const CFE_SB_Buffer_t *CmdPacket) } /* end if */ } else - { /* the rts id is invalid */ - CFE_EVS_SendEvent(SC_STARTRTS_CMD_INVALID_ERR_EID, CFE_EVS_EventType_ERROR, - "Start RTS %03d Rejected: Invalid RTS ID", RtsId); + { /* the RTS is disabled */ + CFE_EVS_SendEvent(SC_STARTRTS_CMD_DISABLED_ERR_EID, CFE_EVS_EventType_ERROR, + "Start RTS %03d Rejected: RTS Disabled", RtsId); SC_OperData.HkPacket.CmdErrCtr++; SC_OperData.HkPacket.RtsActiveErrCtr++; - } + } /* end if */ + } + else + { /* the rts id is invalid */ + CFE_EVS_SendEvent(SC_STARTRTS_CMD_INVALID_ERR_EID, CFE_EVS_EventType_ERROR, + "Start RTS %03d Rejected: Invalid RTS ID", RtsId); + + SC_OperData.HkPacket.CmdErrCtr++; + SC_OperData.HkPacket.RtsActiveErrCtr++; + } } #if (SC_ENABLE_GROUP_COMMANDS == true) @@ -178,75 +177,75 @@ void SC_StartRtsGrpCmd(const CFE_SB_Buffer_t *CmdPacket) uint16 RtsIndex; int32 StartCount = 0; - FirstId = ((SC_RtsGrpCmd_t *)CmdPacket)->FirstRtsId; - LastId = ((SC_RtsGrpCmd_t *)CmdPacket)->LastRtsId; + FirstId = ((SC_RtsGrpCmd_t *)CmdPacket)->FirstRtsId; + LastId = ((SC_RtsGrpCmd_t *)CmdPacket)->LastRtsId; - /* make sure the specified group is valid */ - if ((FirstId > 0) && (LastId > 0) && (FirstId <= SC_NUMBER_OF_RTS) && (LastId <= SC_NUMBER_OF_RTS) && - (FirstId <= LastId)) - { - /* convert RTS ID to RTS array index */ - FirstIndex = SC_RTS_ID_TO_INDEX(FirstId); - LastIndex = SC_RTS_ID_TO_INDEX(LastId); + /* make sure the specified group is valid */ + if ((FirstId > 0) && (LastId > 0) && (FirstId <= SC_NUMBER_OF_RTS) && (LastId <= SC_NUMBER_OF_RTS) && + (FirstId <= LastId)) + { + /* convert RTS ID to RTS array index */ + FirstIndex = SC_RTS_ID_TO_INDEX(FirstId); + LastIndex = SC_RTS_ID_TO_INDEX(LastId); - for (RtsIndex = FirstIndex; RtsIndex <= LastIndex; RtsIndex++) + for (RtsIndex = FirstIndex; RtsIndex <= LastIndex; RtsIndex++) + { + /* make sure that RTS is not disabled, empty or executing */ + if (SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false) { - /* make sure that RTS is not disabled, empty or executing */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false) + if (SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_LOADED) { - if (SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_LOADED) - { - /* initialize the RTS info table entry */ - SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_EXECUTING; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr = 0; - SC_OperData.RtsInfoTblAddr[RtsIndex].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); - - /* maintain counters associated with starting RTS */ - SC_OperData.RtsCtrlBlckAddr->NumRtsActive++; - SC_OperData.HkPacket.RtsActiveCtr++; - - /* count the RTS that were actually started */ - StartCount++; - } - else - { /* Cannot use the RTS now */ - 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_RTS_INDEX_TO_ID(RtsIndex), SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus); - - SC_OperData.HkPacket.RtsActiveErrCtr++; - - } /* end if */ + /* initialize the RTS info table entry */ + SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus = SC_EXECUTING; + SC_OperData.RtsInfoTblAddr[RtsIndex].CmdCtr = 0; + SC_OperData.RtsInfoTblAddr[RtsIndex].CmdErrCtr = 0; + SC_OperData.RtsInfoTblAddr[RtsIndex].NextCommandPtr = 0; + SC_OperData.RtsInfoTblAddr[RtsIndex].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); + + /* maintain counters associated with starting RTS */ + SC_OperData.RtsCtrlBlckAddr->NumRtsActive++; + SC_OperData.HkPacket.RtsActiveCtr++; + + /* count the RTS that were actually started */ + StartCount++; } else - { /* the RTS is disabled */ - CFE_EVS_SendEvent(SC_STARTRTSGRP_CMD_DISABLED_ERR_EID, CFE_EVS_EventType_ERROR, - "Start RTS group error: rejected RTS ID %03d, RTS Disabled", - SC_RTS_INDEX_TO_ID(RtsIndex)); + { /* Cannot use the RTS now */ + 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_RTS_INDEX_TO_ID(RtsIndex), SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus); SC_OperData.HkPacket.RtsActiveErrCtr++; } /* end if */ } + else + { /* the RTS is disabled */ + CFE_EVS_SendEvent(SC_STARTRTSGRP_CMD_DISABLED_ERR_EID, CFE_EVS_EventType_ERROR, + "Start RTS group error: rejected RTS ID %03d, RTS Disabled", + SC_RTS_INDEX_TO_ID(RtsIndex)); - /* success */ - CFE_EVS_SendEvent(SC_STARTRTSGRP_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, - "Start RTS group: FirstID=%d, LastID=%d, Modified=%d", FirstId, LastId, (int)StartCount); - SC_OperData.HkPacket.CmdCtr++; - } - else - { /* error */ - CFE_EVS_SendEvent(SC_STARTRTSGRP_CMD_ERR_EID, CFE_EVS_EventType_ERROR, - "Start RTS group error: FirstID=%d, LastID=%d", FirstId, LastId); - SC_OperData.HkPacket.CmdErrCtr++; + SC_OperData.HkPacket.RtsActiveErrCtr++; + + } /* end if */ } + + /* success */ + CFE_EVS_SendEvent(SC_STARTRTSGRP_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, + "Start RTS group: FirstID=%d, LastID=%d, Modified=%d", FirstId, LastId, (int)StartCount); + SC_OperData.HkPacket.CmdCtr++; + } + else + { /* error */ + CFE_EVS_SendEvent(SC_STARTRTSGRP_CMD_ERR_EID, CFE_EVS_EventType_ERROR, + "Start RTS group error: FirstID=%d, LastID=%d", FirstId, LastId); + SC_OperData.HkPacket.CmdErrCtr++; + } } #endif @@ -260,31 +259,31 @@ void SC_StopRtsCmd(const CFE_SB_Buffer_t *CmdPacket) uint16 RtsId; /* RTS ID */ uint16 RtsIndex; /* RTS array index */ - RtsId = ((SC_RtsCmd_t *)CmdPacket)->RtsId; + RtsId = ((SC_RtsCmd_t *)CmdPacket)->RtsId; - /* check the command parameter */ - if (RtsId <= SC_NUMBER_OF_RTS) - { - /* convert RTS ID to RTS array index */ - RtsIndex = SC_RTS_ID_TO_INDEX(RtsId); + /* check the command parameter */ + if (RtsId <= SC_NUMBER_OF_RTS) + { + /* convert RTS ID to RTS array index */ + RtsIndex = SC_RTS_ID_TO_INDEX(RtsId); - /* stop the rts by calling a generic routine */ - SC_KillRts(RtsIndex); + /* stop the rts by calling a generic routine */ + SC_KillRts(RtsIndex); - SC_OperData.HkPacket.CmdCtr++; + SC_OperData.HkPacket.CmdCtr++; - CFE_EVS_SendEvent(SC_STOPRTS_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, "RTS %03d Aborted", RtsId); - } - else - { /* the specified RTS is invalid */ + CFE_EVS_SendEvent(SC_STOPRTS_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, "RTS %03d Aborted", RtsId); + } + else + { /* the specified RTS is invalid */ - /* the rts id is invalid */ - CFE_EVS_SendEvent(SC_STOPRTS_CMD_ERR_EID, CFE_EVS_EventType_ERROR, "Stop RTS %03d rejected: Invalid RTS ID", - RtsId); + /* the rts id is invalid */ + CFE_EVS_SendEvent(SC_STOPRTS_CMD_ERR_EID, CFE_EVS_EventType_ERROR, "Stop RTS %03d rejected: Invalid RTS ID", + RtsId); - SC_OperData.HkPacket.CmdErrCtr++; + SC_OperData.HkPacket.CmdErrCtr++; - } /* end if */ + } /* end if */ } #if (SC_ENABLE_GROUP_COMMANDS == true) @@ -302,38 +301,38 @@ void SC_StopRtsGrpCmd(const CFE_SB_Buffer_t *CmdPacket) uint16 RtsIndex; int32 StopCount = 0; - FirstId = ((SC_RtsGrpCmd_t *)CmdPacket)->FirstRtsId; - LastId = ((SC_RtsGrpCmd_t *)CmdPacket)->LastRtsId; + FirstId = ((SC_RtsGrpCmd_t *)CmdPacket)->FirstRtsId; + LastId = ((SC_RtsGrpCmd_t *)CmdPacket)->LastRtsId; - /* make sure the specified group is valid */ - if ((FirstId > 0) && (LastId > 0) && (FirstId <= SC_NUMBER_OF_RTS) && (LastId <= SC_NUMBER_OF_RTS) && - (FirstId <= LastId)) - { - /* convert RTS ID to RTS array index */ - FirstIndex = SC_RTS_ID_TO_INDEX(FirstId); - LastIndex = SC_RTS_ID_TO_INDEX(LastId); + /* make sure the specified group is valid */ + if ((FirstId > 0) && (LastId > 0) && (FirstId <= SC_NUMBER_OF_RTS) && (LastId <= SC_NUMBER_OF_RTS) && + (FirstId <= LastId)) + { + /* convert RTS ID to RTS array index */ + FirstIndex = SC_RTS_ID_TO_INDEX(FirstId); + LastIndex = SC_RTS_ID_TO_INDEX(LastId); - for (RtsIndex = FirstIndex; RtsIndex <= LastIndex; RtsIndex++) + for (RtsIndex = FirstIndex; RtsIndex <= LastIndex; RtsIndex++) + { + /* count the entries that were actually stopped */ + if (SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_EXECUTING) { - /* count the entries that were actually stopped */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].RtsStatus == SC_EXECUTING) - { - SC_KillRts(RtsIndex); - StopCount++; - } + SC_KillRts(RtsIndex); + StopCount++; } - - /* success */ - CFE_EVS_SendEvent(SC_STOPRTSGRP_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, - "Stop RTS group: FirstID=%d, LastID=%d, Modified=%d", FirstId, LastId, (int)StopCount); - SC_OperData.HkPacket.CmdCtr++; - } - else - { /* error */ - CFE_EVS_SendEvent(SC_STOPRTSGRP_CMD_ERR_EID, CFE_EVS_EventType_ERROR, - "Stop RTS group error: FirstID=%d, LastID=%d", FirstId, LastId); - SC_OperData.HkPacket.CmdErrCtr++; } + + /* success */ + CFE_EVS_SendEvent(SC_STOPRTSGRP_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, + "Stop RTS group: FirstID=%d, LastID=%d, Modified=%d", FirstId, LastId, (int)StopCount); + SC_OperData.HkPacket.CmdCtr++; + } + else + { /* error */ + CFE_EVS_SendEvent(SC_STOPRTSGRP_CMD_ERR_EID, CFE_EVS_EventType_ERROR, + "Stop RTS group error: FirstID=%d, LastID=%d", FirstId, LastId); + SC_OperData.HkPacket.CmdErrCtr++; + } } #endif @@ -347,30 +346,30 @@ void SC_DisableRtsCmd(const CFE_SB_Buffer_t *CmdPacket) uint16 RtsId; /* RTS ID */ uint16 RtsIndex; /* RTS array index */ - RtsId = ((SC_RtsCmd_t *)CmdPacket)->RtsId; + RtsId = ((SC_RtsCmd_t *)CmdPacket)->RtsId; - /* make sure tha specified rts is valid */ - if (RtsId <= SC_NUMBER_OF_RTS) - { - /* convert RTS ID to RTS array index */ - RtsIndex = SC_RTS_ID_TO_INDEX(RtsId); + /* make sure tha specified rts is valid */ + if (RtsId <= SC_NUMBER_OF_RTS) + { + /* convert RTS ID to RTS array index */ + RtsIndex = SC_RTS_ID_TO_INDEX(RtsId); - /* disable the RTS */ - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = true; + /* disable the RTS */ + SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = true; - /* update the command status */ - SC_OperData.HkPacket.CmdCtr++; + /* update the command status */ + SC_OperData.HkPacket.CmdCtr++; - CFE_EVS_SendEvent(SC_DISABLE_RTS_DEB_EID, CFE_EVS_EventType_DEBUG, "Disabled RTS %03d", RtsId); - } - else - { /* it is not a valid RTS id */ - CFE_EVS_SendEvent(SC_DISRTS_CMD_ERR_EID, CFE_EVS_EventType_ERROR, - "Disable RTS %03d Rejected: Invalid RTS ID", RtsId); + CFE_EVS_SendEvent(SC_DISABLE_RTS_DEB_EID, CFE_EVS_EventType_DEBUG, "Disabled RTS %03d", RtsId); + } + else + { /* it is not a valid RTS id */ + CFE_EVS_SendEvent(SC_DISRTS_CMD_ERR_EID, CFE_EVS_EventType_ERROR, + "Disable RTS %03d Rejected: Invalid RTS ID", RtsId); - /* update the command error status */ - SC_OperData.HkPacket.CmdErrCtr++; - } /* end if */ + /* update the command error status */ + SC_OperData.HkPacket.CmdErrCtr++; + } /* end if */ } #if (SC_ENABLE_GROUP_COMMANDS == true) @@ -388,39 +387,39 @@ void SC_DisableRtsGrpCmd(const CFE_SB_Buffer_t *CmdPacket) uint16 RtsIndex; int32 DisableCount = 0; - FirstId = ((SC_RtsGrpCmd_t *)CmdPacket)->FirstRtsId; - LastId = ((SC_RtsGrpCmd_t *)CmdPacket)->LastRtsId; + FirstId = ((SC_RtsGrpCmd_t *)CmdPacket)->FirstRtsId; + LastId = ((SC_RtsGrpCmd_t *)CmdPacket)->LastRtsId; - /* make sure the specified group is valid */ - if ((FirstId > 0) && (LastId > 0) && (FirstId <= SC_NUMBER_OF_RTS) && (LastId <= SC_NUMBER_OF_RTS) && - (FirstId <= LastId)) - { - /* convert RTS ID to RTS array index */ - FirstIndex = SC_RTS_ID_TO_INDEX(FirstId); - LastIndex = SC_RTS_ID_TO_INDEX(LastId); + /* make sure the specified group is valid */ + if ((FirstId > 0) && (LastId > 0) && (FirstId <= SC_NUMBER_OF_RTS) && (LastId <= SC_NUMBER_OF_RTS) && + (FirstId <= LastId)) + { + /* convert RTS ID to RTS array index */ + FirstIndex = SC_RTS_ID_TO_INDEX(FirstId); + LastIndex = SC_RTS_ID_TO_INDEX(LastId); - for (RtsIndex = FirstIndex; RtsIndex <= LastIndex; RtsIndex++) + for (RtsIndex = FirstIndex; RtsIndex <= LastIndex; RtsIndex++) + { + /* count the entries that were actually disabled */ + if (SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false) { - /* count the entries that were actually disabled */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == false) - { - DisableCount++; - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = true; - } + DisableCount++; + SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = true; } - - /* success */ - CFE_EVS_SendEvent(SC_DISRTSGRP_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, - "Disable RTS group: FirstID=%d, LastID=%d, Modified=%d", FirstId, LastId, - (int)DisableCount); - SC_OperData.HkPacket.CmdCtr++; - } - else - { /* error */ - CFE_EVS_SendEvent(SC_DISRTSGRP_CMD_ERR_EID, CFE_EVS_EventType_ERROR, - "Disable RTS group error: FirstID=%d, LastID=%d", FirstId, LastId); - SC_OperData.HkPacket.CmdErrCtr++; } + + /* success */ + CFE_EVS_SendEvent(SC_DISRTSGRP_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, + "Disable RTS group: FirstID=%d, LastID=%d, Modified=%d", FirstId, LastId, + (int)DisableCount); + SC_OperData.HkPacket.CmdCtr++; + } + else + { /* error */ + CFE_EVS_SendEvent(SC_DISRTSGRP_CMD_ERR_EID, CFE_EVS_EventType_ERROR, + "Disable RTS group error: FirstID=%d, LastID=%d", FirstId, LastId); + SC_OperData.HkPacket.CmdErrCtr++; + } } #endif @@ -434,31 +433,31 @@ void SC_EnableRtsCmd(const CFE_SB_Buffer_t *CmdPacket) uint16 RtsId; /* RTS ID */ uint16 RtsIndex; /* RTS array index */ - RtsId = ((SC_RtsCmd_t *)CmdPacket)->RtsId; + RtsId = ((SC_RtsCmd_t *)CmdPacket)->RtsId; - /* make sure the specified rts is valid */ - if ((RtsId > 0) && (RtsId <= SC_NUMBER_OF_RTS)) - { - /* convert RTS ID to RTS array index */ - RtsIndex = SC_RTS_ID_TO_INDEX(RtsId); + /* make sure the specified rts is valid */ + if ((RtsId > 0) && (RtsId <= SC_NUMBER_OF_RTS)) + { + /* convert RTS ID to RTS array index */ + RtsIndex = SC_RTS_ID_TO_INDEX(RtsId); - /* re-enable the RTS */ - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = false; + /* re-enable the RTS */ + SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = false; - /* update the command status */ - SC_OperData.HkPacket.CmdCtr++; + /* update the command status */ + SC_OperData.HkPacket.CmdCtr++; - CFE_EVS_SendEvent(SC_ENABLE_RTS_DEB_EID, CFE_EVS_EventType_DEBUG, "Enabled RTS %03d", RtsId); - } - else - { /* it is not a valid RTS id */ - CFE_EVS_SendEvent(SC_ENARTS_CMD_ERR_EID, CFE_EVS_EventType_ERROR, - "Enable RTS %03d Rejected: Invalid RTS ID", RtsId); + CFE_EVS_SendEvent(SC_ENABLE_RTS_DEB_EID, CFE_EVS_EventType_DEBUG, "Enabled RTS %03d", RtsId); + } + else + { /* it is not a valid RTS id */ + CFE_EVS_SendEvent(SC_ENARTS_CMD_ERR_EID, CFE_EVS_EventType_ERROR, + "Enable RTS %03d Rejected: Invalid RTS ID", RtsId); - /* update the command error status */ - SC_OperData.HkPacket.CmdErrCtr++; + /* update the command error status */ + SC_OperData.HkPacket.CmdErrCtr++; - } /* end if */ + } /* end if */ } #if (SC_ENABLE_GROUP_COMMANDS == true) @@ -476,39 +475,39 @@ void SC_EnableRtsGrpCmd(const CFE_SB_Buffer_t *CmdPacket) uint16 RtsIndex; int32 EnableCount = 0; - FirstId = ((SC_RtsGrpCmd_t *)CmdPacket)->FirstRtsId; - LastId = ((SC_RtsGrpCmd_t *)CmdPacket)->LastRtsId; + FirstId = ((SC_RtsGrpCmd_t *)CmdPacket)->FirstRtsId; + LastId = ((SC_RtsGrpCmd_t *)CmdPacket)->LastRtsId; - /* make sure the specified group is valid */ - if ((FirstId > 0) && (LastId > 0) && (FirstId <= SC_NUMBER_OF_RTS) && (LastId <= SC_NUMBER_OF_RTS) && - (FirstId <= LastId)) - { - /* convert RTS ID to RTS array index */ - FirstIndex = SC_RTS_ID_TO_INDEX(FirstId); - LastIndex = SC_RTS_ID_TO_INDEX(LastId); + /* make sure the specified group is valid */ + if ((FirstId > 0) && (LastId > 0) && (FirstId <= SC_NUMBER_OF_RTS) && (LastId <= SC_NUMBER_OF_RTS) && + (FirstId <= LastId)) + { + /* convert RTS ID to RTS array index */ + FirstIndex = SC_RTS_ID_TO_INDEX(FirstId); + LastIndex = SC_RTS_ID_TO_INDEX(LastId); - for (RtsIndex = FirstIndex; RtsIndex <= LastIndex; RtsIndex++) + for (RtsIndex = FirstIndex; RtsIndex <= LastIndex; RtsIndex++) + { + /* count the entries that were actually enabled */ + if (SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == true) { - /* count the entries that were actually enabled */ - if (SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag == true) - { - EnableCount++; - SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = false; - } + EnableCount++; + SC_OperData.RtsInfoTblAddr[RtsIndex].DisabledFlag = false; } - - /* success */ - CFE_EVS_SendEvent(SC_ENARTSGRP_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, - "Enable RTS group: FirstID=%d, LastID=%d, Modified=%d", FirstId, LastId, - (int)EnableCount); - SC_OperData.HkPacket.CmdCtr++; - } - else - { /* error */ - CFE_EVS_SendEvent(SC_ENARTSGRP_CMD_ERR_EID, CFE_EVS_EventType_ERROR, - "Enable RTS group error: FirstID=%d, LastID=%d", FirstId, LastId); - SC_OperData.HkPacket.CmdErrCtr++; } + + /* success */ + CFE_EVS_SendEvent(SC_ENARTSGRP_CMD_INF_EID, CFE_EVS_EventType_INFORMATION, + "Enable RTS group: FirstID=%d, LastID=%d, Modified=%d", FirstId, LastId, + (int)EnableCount); + SC_OperData.HkPacket.CmdCtr++; + } + else + { /* error */ + CFE_EVS_SendEvent(SC_ENARTSGRP_CMD_ERR_EID, CFE_EVS_EventType_ERROR, + "Enable RTS group error: FirstID=%d, LastID=%d", FirstId, LastId); + SC_OperData.HkPacket.CmdErrCtr++; + } } #endif diff --git a/unit-test/sc_cmds_tests.c b/unit-test/sc_cmds_tests.c index 3805d17..464af34 100644 --- a/unit-test/sc_cmds_tests.c +++ b/unit-test/sc_cmds_tests.c @@ -2256,7 +2256,6 @@ void SC_ProcessCommand_Test_EnableRtsGrp(void) /* This function is already verified to work correctly in another file, so no verifications here. */ } - void SC_ProcessCommand_Test_StartAtsInvalidCmdLength(void) { CFE_SB_MsgId_t TestMsgId = CFE_SB_ValueToMsgId(SC_CMD_MID);