diff --git a/.github/workflows/codeql-build.yml b/.github/workflows/codeql-build.yml index 263da4f..1b2781a 100644 --- a/.github/workflows/codeql-build.yml +++ b/.github/workflows/codeql-build.yml @@ -4,7 +4,6 @@ on: push: pull_request: - jobs: codeql: name: Codeql Analysis diff --git a/fsw/inc/cs_tbldefs.h b/fsw/inc/cs_tbldefs.h index 51c2640..efb892c 100644 --- a/fsw/inc/cs_tbldefs.h +++ b/fsw/inc/cs_tbldefs.h @@ -339,7 +339,7 @@ void CS_ProcessNewAppDefinitionTable(const CS_Def_App_Table_Entry_t *DefinitionT * \param [in] SizeofDefinitionTableEntry The sizeof an entry in the * definition table * - * \param [in] SizeofResultsTableEntry The size of an enrty in the + * \param [in] SizeofResultsTableEntry The size of an entry in the * results table * * \param [in] CallBackFunction A pointer to a function used to @@ -367,7 +367,7 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl void *DefinitionTblPtr, void *ResultsTblPtr, const uint16 Table, const char *DefinitionTableName, const char *ResultsTableName, const uint16 NumEntries, const char *DefinitionTableFileName, const void *DefaultDefTableAddress, - const uint16 SizeofDefinitionTableEntry, const uint16 SizeofResultsTableEntry, + const size_t SizeofDefinitionTableEntry, const size_t SizeofResultsTableEntry, const CFE_TBL_CallbackFuncPtr_t CallBackFunction); /** diff --git a/fsw/src/cs_app.c b/fsw/src/cs_app.c index 3492e49..ba437fe 100644 --- a/fsw/src/cs_app.c +++ b/fsw/src/cs_app.c @@ -58,7 +58,7 @@ CS_AppData_t CS_AppData; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_AppMain(void) { - CFE_Status_t Result = 0; + CFE_Status_t Result; CFE_SB_Buffer_t *BufPtr = NULL; /* Performance Log (start time counter) */ @@ -147,7 +147,7 @@ void CS_AppMain(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_AppInit(void) { - CFE_Status_t Result = CFE_SUCCESS; + CFE_Status_t Result; /* Register for event services */ Result = CFE_EVS_Register(NULL, 0, 0); @@ -264,8 +264,8 @@ CFE_Status_t CS_AppPipe(const CFE_SB_Buffer_t *BufPtr) void CS_ProcessCmd(const CFE_SB_Buffer_t *BufPtr) { - CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; - uint16 CommandCode = 0; + CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; + CFE_MSG_FcnCode_t CommandCode = 0; CFE_MSG_GetMsgId(&BufPtr->Msg, &MessageID); diff --git a/fsw/src/cs_app_cmds.c b/fsw/src/cs_app_cmds.c index 8854dd5..b474a99 100644 --- a/fsw/src/cs_app_cmds.c +++ b/fsw/src/cs_app_cmds.c @@ -46,18 +46,18 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_DisableAppCmd(const CS_NoArgsCmd_t *CmdPtr) { - if (CS_CheckRecomputeOneshot() == false) - { - CS_AppData.HkPacket.Payload.AppCSState = CS_STATE_DISABLED; - CS_ZeroAppTempValues(); + if (CS_CheckRecomputeOneshot() == false) + { + CS_AppData.HkPacket.Payload.AppCSState = CS_STATE_DISABLED; + CS_ZeroAppTempValues(); #if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true) - CS_UpdateCDS(); + CS_UpdateCDS(); #endif - CFE_EVS_SendEvent(CS_DISABLE_APP_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of App is Disabled"); - CS_AppData.HkPacket.Payload.CmdCounter++; - } + CFE_EVS_SendEvent(CS_DISABLE_APP_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of App is Disabled"); + CS_AppData.HkPacket.Payload.CmdCounter++; + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -67,17 +67,17 @@ void CS_DisableAppCmd(const CS_NoArgsCmd_t *CmdPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_EnableAppCmd(const CS_NoArgsCmd_t *CmdPtr) { - if (CS_CheckRecomputeOneshot() == false) - { - CS_AppData.HkPacket.Payload.AppCSState = CS_STATE_ENABLED; + if (CS_CheckRecomputeOneshot() == false) + { + CS_AppData.HkPacket.Payload.AppCSState = CS_STATE_ENABLED; #if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true) - CS_UpdateCDS(); + CS_UpdateCDS(); #endif - CFE_EVS_SendEvent(CS_ENABLE_APP_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of App is Enabled"); - CS_AppData.HkPacket.Payload.CmdCounter++; - } + CFE_EVS_SendEvent(CS_ENABLE_APP_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of App is Enabled"); + CS_AppData.HkPacket.Payload.CmdCounter++; + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -91,31 +91,34 @@ void CS_ReportBaselineAppCmd(const CS_AppNameCmd_t *CmdPtr) CS_Res_App_Table_Entry_t *ResultsEntry; uint32 Baseline; char Name[OS_MAX_API_NAME]; + bool Status; - strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); - Name[sizeof(Name) - 1] = '\0'; + strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); + Name[sizeof(Name) - 1] = '\0'; - if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) + Status = CS_GetAppResTblEntryByName(&ResultsEntry, Name); + + if (Status) + { + if (ResultsEntry->ComputedYet == true) { - if (ResultsEntry->ComputedYet == true) - { - Baseline = ResultsEntry->ComparisonValue; - CFE_EVS_SendEvent(CS_BASELINE_APP_INF_EID, CFE_EVS_EventType_INFORMATION, - "Report baseline of app %s is 0x%08X", Name, (unsigned int)Baseline); - } - else - { - CFE_EVS_SendEvent(CS_NO_BASELINE_APP_INF_EID, CFE_EVS_EventType_INFORMATION, - "Report baseline of app %s has not been computed yet", Name); - } - CS_AppData.HkPacket.Payload.CmdCounter++; + Baseline = ResultsEntry->ComparisonValue; + CFE_EVS_SendEvent(CS_BASELINE_APP_INF_EID, CFE_EVS_EventType_INFORMATION, + "Report baseline of app %s is 0x%08X", Name, (unsigned int)Baseline); } else { - CFE_EVS_SendEvent(CS_BASELINE_INVALID_NAME_APP_ERR_EID, CFE_EVS_EventType_ERROR, - "App report baseline failed, app %s not found", Name); - CS_AppData.HkPacket.Payload.CmdErrCounter++; + CFE_EVS_SendEvent(CS_NO_BASELINE_APP_INF_EID, CFE_EVS_EventType_INFORMATION, + "Report baseline of app %s has not been computed yet", Name); } + CS_AppData.HkPacket.Payload.CmdCounter++; + } + else + { + CFE_EVS_SendEvent(CS_BASELINE_INVALID_NAME_APP_ERR_EID, CFE_EVS_EventType_ERROR, + "App report baseline failed, app %s not found", Name); + CS_AppData.HkPacket.Payload.CmdErrCounter++; + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -130,54 +133,58 @@ void CS_RecomputeBaselineAppCmd(const CS_AppNameCmd_t *CmdPtr) CFE_Status_t Status; CS_Res_App_Table_Entry_t *ResultsEntry; char Name[OS_MAX_API_NAME]; + bool Result; + + if (CS_AppData.HkPacket.Payload.RecomputeInProgress == false && + CS_AppData.HkPacket.Payload.OneShotInProgress == false) + { + strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); + Name[sizeof(Name) - 1] = '\0'; - if (CS_AppData.HkPacket.Payload.RecomputeInProgress == false && CS_AppData.HkPacket.Payload.OneShotInProgress == false) + /* make sure the entry is a valid number and is defined in the table */ + Result = CS_GetAppResTblEntryByName(&ResultsEntry, Name); + + if (Result) { - strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); - Name[sizeof(Name) - 1] = '\0'; + /* There is no child task running right now, we can use it*/ + CS_AppData.HkPacket.Payload.RecomputeInProgress = true; + + /* fill in child task variables */ + CS_AppData.ChildTaskTable = CS_APP_TABLE; + + CS_AppData.RecomputeAppEntryPtr = ResultsEntry; - /* make sure the entry is a valid number and is defined in the table */ - if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) + Status = CFE_ES_CreateChildTask(&ChildTaskID, CS_RECOMP_APP_TASK_NAME, CS_RecomputeAppChildTask, NULL, + CFE_PLATFORM_ES_DEFAULT_STACK_SIZE, CS_CHILD_TASK_PRIORITY, 0); + if (Status == CFE_SUCCESS) { - /* There is no child task running right now, we can use it*/ - CS_AppData.HkPacket.Payload.RecomputeInProgress = true; - - /* fill in child task variables */ - CS_AppData.ChildTaskTable = CS_APP_TABLE; - - CS_AppData.RecomputeAppEntryPtr = ResultsEntry; - - Status = CFE_ES_CreateChildTask(&ChildTaskID, CS_RECOMP_APP_TASK_NAME, CS_RecomputeAppChildTask, NULL, - CFE_PLATFORM_ES_DEFAULT_STACK_SIZE, CS_CHILD_TASK_PRIORITY, 0); - if (Status == CFE_SUCCESS) - { - CFE_EVS_SendEvent(CS_RECOMPUTE_APP_STARTED_DBG_EID, CFE_EVS_EventType_DEBUG, - "Recompute baseline of app %s started", Name); - CS_AppData.HkPacket.Payload.CmdCounter++; - } - else /* child task creation failed */ - { - CFE_EVS_SendEvent(CS_RECOMPUTE_APP_CREATE_CHDTASK_ERR_EID, CFE_EVS_EventType_ERROR, - "Recompute baseline of app %s failed, CFE_ES_CreateChildTask returned: 0x%08X", - Name, (unsigned int)Status); - CS_AppData.HkPacket.Payload.CmdErrCounter++; - CS_AppData.HkPacket.Payload.RecomputeInProgress = false; - } + CFE_EVS_SendEvent(CS_RECOMPUTE_APP_STARTED_DBG_EID, CFE_EVS_EventType_DEBUG, + "Recompute baseline of app %s started", Name); + CS_AppData.HkPacket.Payload.CmdCounter++; } - else + else /* child task creation failed */ { - CFE_EVS_SendEvent(CS_RECOMPUTE_UNKNOWN_NAME_APP_ERR_EID, CFE_EVS_EventType_ERROR, - "App recompute baseline failed, app %s not found", Name); + CFE_EVS_SendEvent(CS_RECOMPUTE_APP_CREATE_CHDTASK_ERR_EID, CFE_EVS_EventType_ERROR, + "Recompute baseline of app %s failed, CFE_ES_CreateChildTask returned: 0x%08X", Name, + (unsigned int)Status); CS_AppData.HkPacket.Payload.CmdErrCounter++; + CS_AppData.HkPacket.Payload.RecomputeInProgress = false; } } else { - /*send event that we can't start another task right now */ - CFE_EVS_SendEvent(CS_RECOMPUTE_APP_CHDTASK_ERR_EID, CFE_EVS_EventType_ERROR, - "App recompute baseline for app %s failed: child task in use", Name); + CFE_EVS_SendEvent(CS_RECOMPUTE_UNKNOWN_NAME_APP_ERR_EID, CFE_EVS_EventType_ERROR, + "App recompute baseline failed, app %s not found", Name); CS_AppData.HkPacket.Payload.CmdErrCounter++; } + } + else + { + /*send event that we can't start another task right now */ + CFE_EVS_SendEvent(CS_RECOMPUTE_APP_CHDTASK_ERR_EID, CFE_EVS_EventType_ERROR, + "App recompute baseline for app %s failed: child task in use", Name); + CS_AppData.HkPacket.Payload.CmdErrCounter++; + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -191,43 +198,47 @@ void CS_DisableNameAppCmd(const CS_AppNameCmd_t *CmdPtr) CS_Res_App_Table_Entry_t *ResultsEntry; CS_Def_App_Table_Entry_t *DefinitionEntry; char Name[OS_MAX_API_NAME]; + bool Status; - if (CS_CheckRecomputeOneshot() == false) + if (CS_CheckRecomputeOneshot() == false) + { + strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); + Name[sizeof(Name) - 1] = '\0'; + + Status = CS_GetAppResTblEntryByName(&ResultsEntry, Name); + + if (Status) { - strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); - Name[sizeof(Name) - 1] = '\0'; + ResultsEntry->State = CS_STATE_DISABLED; + ResultsEntry->TempChecksumValue = 0; + ResultsEntry->ByteOffset = 0; - if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) - { - ResultsEntry->State = CS_STATE_DISABLED; - ResultsEntry->TempChecksumValue = 0; - ResultsEntry->ByteOffset = 0; - - CFE_EVS_SendEvent(CS_DISABLE_APP_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, - "Checksumming of app %s is Disabled", Name); - - if (CS_GetAppDefTblEntryByName(&DefinitionEntry, Name)) - { - DefinitionEntry->State = CS_STATE_DISABLED; - CS_ResetTablesTblResultEntry(CS_AppData.AppResTablesTblPtr); - CFE_TBL_Modified(CS_AppData.DefAppTableHandle); - } - else - { - CFE_EVS_SendEvent(CS_DISABLE_APP_DEF_NOT_FOUND_DBG_EID, CFE_EVS_EventType_DEBUG, - "CS unable to update apps definition table for entry %s", Name); - } + CFE_EVS_SendEvent(CS_DISABLE_APP_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, + "Checksumming of app %s is Disabled", Name); - CS_AppData.HkPacket.Payload.CmdCounter++; - } + Status = CS_GetAppDefTblEntryByName(&DefinitionEntry, Name); + if (Status) + { + DefinitionEntry->State = CS_STATE_DISABLED; + CS_ResetTablesTblResultEntry(CS_AppData.AppResTablesTblPtr); + CFE_TBL_Modified(CS_AppData.DefAppTableHandle); + } else { - CFE_EVS_SendEvent(CS_DISABLE_APP_UNKNOWN_NAME_ERR_EID, CFE_EVS_EventType_ERROR, - "App disable app command failed, app %s not found", Name); - CS_AppData.HkPacket.Payload.CmdErrCounter++; + CFE_EVS_SendEvent(CS_DISABLE_APP_DEF_NOT_FOUND_DBG_EID, CFE_EVS_EventType_DEBUG, + "CS unable to update apps definition table for entry %s", Name); } - } /* end InProgress if */ + + CS_AppData.HkPacket.Payload.CmdCounter++; + } + else + { + CFE_EVS_SendEvent(CS_DISABLE_APP_UNKNOWN_NAME_ERR_EID, CFE_EVS_EventType_ERROR, + "App disable app command failed, app %s not found", Name); + CS_AppData.HkPacket.Payload.CmdErrCounter++; + } + } /* end InProgress if */ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -241,38 +252,43 @@ void CS_EnableNameAppCmd(const CS_AppNameCmd_t *CmdPtr) CS_Res_App_Table_Entry_t *ResultsEntry; CS_Def_App_Table_Entry_t *DefinitionEntry; char Name[OS_MAX_API_NAME]; + bool Status; + + if (CS_CheckRecomputeOneshot() == false) + { + strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); + Name[sizeof(Name) - 1] = '\0'; + + Status = CS_GetAppResTblEntryByName(&ResultsEntry, Name); - if (CS_CheckRecomputeOneshot() == false) + if (Status) { - strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); - Name[sizeof(Name) - 1] = '\0'; + ResultsEntry->State = CS_STATE_ENABLED; - if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) - { - ResultsEntry->State = CS_STATE_ENABLED; - - CFE_EVS_SendEvent(CS_ENABLE_APP_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, - "Checksumming of app %s is Enabled", Name); - - if (CS_GetAppDefTblEntryByName(&DefinitionEntry, Name)) - { - DefinitionEntry->State = CS_STATE_ENABLED; - CS_ResetTablesTblResultEntry(CS_AppData.AppResTablesTblPtr); - CFE_TBL_Modified(CS_AppData.DefAppTableHandle); - } - else - { - CFE_EVS_SendEvent(CS_ENABLE_APP_DEF_NOT_FOUND_DBG_EID, CFE_EVS_EventType_DEBUG, - "CS unable to update apps definition table for entry %s", Name); - } + CFE_EVS_SendEvent(CS_ENABLE_APP_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, + "Checksumming of app %s is Enabled", Name); - CS_AppData.HkPacket.Payload.CmdCounter++; + Status = CS_GetAppDefTblEntryByName(&DefinitionEntry, Name); + + if (Status) + { + DefinitionEntry->State = CS_STATE_ENABLED; + CS_ResetTablesTblResultEntry(CS_AppData.AppResTablesTblPtr); + CFE_TBL_Modified(CS_AppData.DefAppTableHandle); } else { - CFE_EVS_SendEvent(CS_ENABLE_APP_UNKNOWN_NAME_ERR_EID, CFE_EVS_EventType_ERROR, - "App enable app command failed, app %s not found", Name); - CS_AppData.HkPacket.Payload.CmdErrCounter++; + CFE_EVS_SendEvent(CS_ENABLE_APP_DEF_NOT_FOUND_DBG_EID, CFE_EVS_EventType_DEBUG, + "CS unable to update apps definition table for entry %s", Name); } - } /* end InProgress if */ + + CS_AppData.HkPacket.Payload.CmdCounter++; + } + else + { + CFE_EVS_SendEvent(CS_ENABLE_APP_UNKNOWN_NAME_ERR_EID, CFE_EVS_EventType_ERROR, + "App enable app command failed, app %s not found", Name); + CS_AppData.HkPacket.Payload.CmdErrCounter++; + } + } /* end InProgress if */ } diff --git a/fsw/src/cs_compute.c b/fsw/src/cs_compute.c index ae23c96..1e8224b 100644 --- a/fsw/src/cs_compute.c +++ b/fsw/src/cs_compute.c @@ -125,9 +125,9 @@ CFE_Status_t CS_ComputeTables(CS_Res_Tables_Table_Entry_t *ResultsEntry, uint32 uint32 NewChecksumValue = 0; CFE_Status_t Status = CFE_SUCCESS; CFE_Status_t Result = CFE_SUCCESS; - CFE_Status_t ResultShare = 0; - CFE_Status_t ResultGetInfo = 0; - CFE_Status_t ResultGetAddress = 0; + CFE_Status_t ResultShare; + CFE_Status_t ResultGetInfo = 0; + CFE_Status_t ResultGetAddress = 0; /* variables to get the table address */ CFE_TBL_Handle_t LocalTblHandle = CFE_TBL_BAD_TABLE_HANDLE; @@ -313,7 +313,7 @@ CFE_Status_t CS_ComputeApp(CS_Res_App_Table_Entry_t *ResultsEntry, uint32 *Compu uint32 NewChecksumValue = 0; CFE_Status_t Status = CFE_SUCCESS; CFE_Status_t Result; - CFE_Status_t ResultGetResourceID = CS_ERROR; + CFE_Status_t ResultGetResourceID; CFE_Status_t ResultGetResourceInfo = CS_ERROR; int32 ResultAddressValid = false; @@ -781,11 +781,11 @@ void CS_RecomputeTablesChildTask(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_OneShotChildTask(void) { - uint32 NewChecksumValue = 0; - uint32 NumBytesRemainingCycles = 0; - uint32 NumBytesThisCycle = 0; - cpuaddr FirstAddrThisCycle = 0; - uint32 MaxBytesPerCycle = 0; + uint32 NewChecksumValue; + uint32 NumBytesRemainingCycles; + uint32 NumBytesThisCycle; + cpuaddr FirstAddrThisCycle; + uint32 MaxBytesPerCycle; NewChecksumValue = 0; NumBytesRemainingCycles = CS_AppData.HkPacket.Payload.LastOneShotSize; diff --git a/fsw/src/cs_compute.h b/fsw/src/cs_compute.h index 2e33273..6f89bd9 100644 --- a/fsw/src/cs_compute.h +++ b/fsw/src/cs_compute.h @@ -40,7 +40,6 @@ * function is used to compute checksums for EEPROM, Memory, the * OS code segment and the cFE core code segment * - * * \par Assumptions, External Events, and Notes: * None * diff --git a/fsw/src/cs_eeprom_cmds.c b/fsw/src/cs_eeprom_cmds.c index 39c4170..2bd742c 100644 --- a/fsw/src/cs_eeprom_cmds.c +++ b/fsw/src/cs_eeprom_cmds.c @@ -48,20 +48,20 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_DisableEepromCmd(const CS_NoArgsCmd_t *CmdPtr) { - if (CS_CheckRecomputeOneshot() == false) - { - CS_AppData.HkPacket.Payload.EepromCSState = CS_STATE_DISABLED; - CS_ZeroEepromTempValues(); + if (CS_CheckRecomputeOneshot() == false) + { + CS_AppData.HkPacket.Payload.EepromCSState = CS_STATE_DISABLED; + CS_ZeroEepromTempValues(); #if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true) - CS_UpdateCDS(); + CS_UpdateCDS(); #endif - CFE_EVS_SendEvent(CS_DISABLE_EEPROM_INF_EID, CFE_EVS_EventType_INFORMATION, - "Checksumming of EEPROM is Disabled"); + CFE_EVS_SendEvent(CS_DISABLE_EEPROM_INF_EID, CFE_EVS_EventType_INFORMATION, + "Checksumming of EEPROM is Disabled"); - CS_AppData.HkPacket.Payload.CmdCounter++; - } + CS_AppData.HkPacket.Payload.CmdCounter++; + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -71,19 +71,18 @@ void CS_DisableEepromCmd(const CS_NoArgsCmd_t *CmdPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_EnableEepromCmd(const CS_NoArgsCmd_t *CmdPtr) { - if (CS_CheckRecomputeOneshot() == false) - { - CS_AppData.HkPacket.Payload.EepromCSState = CS_STATE_ENABLED; + if (CS_CheckRecomputeOneshot() == false) + { + CS_AppData.HkPacket.Payload.EepromCSState = CS_STATE_ENABLED; #if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true) - CS_UpdateCDS(); + CS_UpdateCDS(); #endif - CFE_EVS_SendEvent(CS_ENABLE_EEPROM_INF_EID, CFE_EVS_EventType_INFORMATION, - "Checksumming of EEPROM is Enabled"); + CFE_EVS_SendEvent(CS_ENABLE_EEPROM_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of EEPROM is Enabled"); - CS_AppData.HkPacket.Payload.CmdCounter++; - } + CS_AppData.HkPacket.Payload.CmdCounter++; + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -99,43 +98,42 @@ void CS_ReportBaselineEntryIDEepromCmd(const CS_EntryCmd_t *CmdPtr) uint16 State = CS_STATE_EMPTY; CS_Res_EepromMemory_Table_Entry_t ResultsEntry; - EntryID = CmdPtr->Payload.EntryID; + EntryID = CmdPtr->Payload.EntryID; - if ((EntryID < CS_MAX_NUM_EEPROM_TABLE_ENTRIES) && - (CS_AppData.ResEepromTblPtr[EntryID].State != CS_STATE_EMPTY)) - { - ResultsEntry = CS_AppData.ResEepromTblPtr[EntryID]; + if ((EntryID < CS_MAX_NUM_EEPROM_TABLE_ENTRIES) && (CS_AppData.ResEepromTblPtr[EntryID].State != CS_STATE_EMPTY)) + { + ResultsEntry = CS_AppData.ResEepromTblPtr[EntryID]; - if (ResultsEntry.ComputedYet == true) - { - Baseline = ResultsEntry.ComparisonValue; + if (ResultsEntry.ComputedYet == true) + { + Baseline = ResultsEntry.ComparisonValue; - CFE_EVS_SendEvent(CS_BASELINE_EEPROM_INF_EID, CFE_EVS_EventType_INFORMATION, - "Report baseline of EEPROM Entry %d is 0x%08X", EntryID, (unsigned int)Baseline); - } - else - { - CFE_EVS_SendEvent(CS_NO_BASELINE_EEPROM_INF_EID, CFE_EVS_EventType_INFORMATION, - "Report baseline of EEPROM Entry %d has not been computed yet", EntryID); - } - CS_AppData.HkPacket.Payload.CmdCounter++; + CFE_EVS_SendEvent(CS_BASELINE_EEPROM_INF_EID, CFE_EVS_EventType_INFORMATION, + "Report baseline of EEPROM Entry %d is 0x%08X", EntryID, (unsigned int)Baseline); } else { - if (EntryID >= CS_MAX_NUM_EEPROM_TABLE_ENTRIES) - { - State = CS_STATE_UNDEFINED; - } - else - { - State = CS_AppData.ResEepromTblPtr[EntryID].State; - } - - CFE_EVS_SendEvent(CS_BASELINE_INVALID_ENTRY_EEPROM_ERR_EID, CFE_EVS_EventType_ERROR, - "EEPROM report baseline failed, Entry ID invalid: %d, State: %d Max ID: %d", EntryID, - State, (CS_MAX_NUM_EEPROM_TABLE_ENTRIES - 1)); - CS_AppData.HkPacket.Payload.CmdErrCounter++; + CFE_EVS_SendEvent(CS_NO_BASELINE_EEPROM_INF_EID, CFE_EVS_EventType_INFORMATION, + "Report baseline of EEPROM Entry %d has not been computed yet", EntryID); + } + CS_AppData.HkPacket.Payload.CmdCounter++; + } + else + { + if (EntryID >= CS_MAX_NUM_EEPROM_TABLE_ENTRIES) + { + State = CS_STATE_UNDEFINED; + } + else + { + State = CS_AppData.ResEepromTblPtr[EntryID].State; } + + CFE_EVS_SendEvent(CS_BASELINE_INVALID_ENTRY_EEPROM_ERR_EID, CFE_EVS_EventType_ERROR, + "EEPROM report baseline failed, Entry ID invalid: %d, State: %d Max ID: %d", EntryID, State, + (CS_MAX_NUM_EEPROM_TABLE_ENTRIES - 1)); + CS_AppData.HkPacket.Payload.CmdErrCounter++; + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -147,72 +145,71 @@ void CS_RecomputeBaselineEepromCmd(const CS_EntryCmd_t *CmdPtr) { /* command verification variables */ CFE_ES_TaskId_t ChildTaskID = CFE_ES_TASKID_UNDEFINED; - CFE_Status_t Status = CS_ERROR; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + CFE_Status_t Status; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; - EntryID = CmdPtr->Payload.EntryID; + EntryID = CmdPtr->Payload.EntryID; - if (CS_AppData.HkPacket.Payload.RecomputeInProgress == false && CS_AppData.HkPacket.Payload.OneShotInProgress == false) + if (CS_AppData.HkPacket.Payload.RecomputeInProgress == false && + CS_AppData.HkPacket.Payload.OneShotInProgress == false) + { + /* make sure the entry is a valid number and is defined in the table */ + if ((EntryID < CS_MAX_NUM_EEPROM_TABLE_ENTRIES) && + (CS_AppData.ResEepromTblPtr[EntryID].State != CS_STATE_EMPTY)) { - /* make sure the entry is a valid number and is defined in the table */ - if ((EntryID < CS_MAX_NUM_EEPROM_TABLE_ENTRIES) && - (CS_AppData.ResEepromTblPtr[EntryID].State != CS_STATE_EMPTY)) + /* There is no child task running right now, we can use it*/ + CS_AppData.HkPacket.Payload.RecomputeInProgress = true; + + /* fill in child task variables */ + CS_AppData.ChildTaskTable = CS_EEPROM_TABLE; + CS_AppData.ChildTaskEntryID = EntryID; + + CS_AppData.RecomputeEepromMemoryEntryPtr = &CS_AppData.ResEepromTblPtr[EntryID]; + + Status = CFE_ES_CreateChildTask(&ChildTaskID, CS_RECOMP_EEPROM_TASK_NAME, CS_RecomputeEepromMemoryChildTask, + NULL, CFE_PLATFORM_ES_DEFAULT_STACK_SIZE, CS_CHILD_TASK_PRIORITY, 0); + if (Status == CFE_SUCCESS) { - /* There is no child task running right now, we can use it*/ - CS_AppData.HkPacket.Payload.RecomputeInProgress = true; - - /* fill in child task variables */ - CS_AppData.ChildTaskTable = CS_EEPROM_TABLE; - CS_AppData.ChildTaskEntryID = EntryID; - - CS_AppData.RecomputeEepromMemoryEntryPtr = &CS_AppData.ResEepromTblPtr[EntryID]; - - Status = - CFE_ES_CreateChildTask(&ChildTaskID, CS_RECOMP_EEPROM_TASK_NAME, CS_RecomputeEepromMemoryChildTask, - NULL, CFE_PLATFORM_ES_DEFAULT_STACK_SIZE, CS_CHILD_TASK_PRIORITY, 0); - if (Status == CFE_SUCCESS) - { - CFE_EVS_SendEvent(CS_RECOMPUTE_EEPROM_STARTED_DBG_EID, CFE_EVS_EventType_DEBUG, - "Recompute baseline of EEPROM Entry ID %d started", EntryID); - CS_AppData.HkPacket.Payload.CmdCounter++; - } - else /* child task creation failed */ - { - CFE_EVS_SendEvent( - CS_RECOMPUTE_EEPROM_CREATE_CHDTASK_ERR_EID, CFE_EVS_EventType_ERROR, - "Recompute baseline of EEPROM Entry ID %d failed, CFE_ES_CreateChildTask returned: 0x%08X", - EntryID, (unsigned int)Status); - CS_AppData.HkPacket.Payload.CmdErrCounter++; - CS_AppData.HkPacket.Payload.RecomputeInProgress = false; - } + CFE_EVS_SendEvent(CS_RECOMPUTE_EEPROM_STARTED_DBG_EID, CFE_EVS_EventType_DEBUG, + "Recompute baseline of EEPROM Entry ID %d started", EntryID); + CS_AppData.HkPacket.Payload.CmdCounter++; } - else + else /* child task creation failed */ { - if (EntryID >= CS_MAX_NUM_EEPROM_TABLE_ENTRIES) - { - State = CS_STATE_UNDEFINED; - } - else - { - State = CS_AppData.ResEepromTblPtr[EntryID].State; - } - CFE_EVS_SendEvent( - CS_RECOMPUTE_INVALID_ENTRY_EEPROM_ERR_EID, CFE_EVS_EventType_ERROR, - "EEPROM recompute baseline of entry failed, Entry ID invalid: %d, State: %d, Max ID: %d", EntryID, - State, (CS_MAX_NUM_EEPROM_TABLE_ENTRIES - 1)); - + CS_RECOMPUTE_EEPROM_CREATE_CHDTASK_ERR_EID, CFE_EVS_EventType_ERROR, + "Recompute baseline of EEPROM Entry ID %d failed, CFE_ES_CreateChildTask returned: 0x%08X", + EntryID, (unsigned int)Status); CS_AppData.HkPacket.Payload.CmdErrCounter++; + CS_AppData.HkPacket.Payload.RecomputeInProgress = false; } } else { - /*send event that we can't start another task right now */ - CFE_EVS_SendEvent(CS_RECOMPUTE_EEPROM_CHDTASK_ERR_EID, CFE_EVS_EventType_ERROR, - "Recompute baseline of EEPROM Entry ID %d failed: child task in use", EntryID); + if (EntryID >= CS_MAX_NUM_EEPROM_TABLE_ENTRIES) + { + State = CS_STATE_UNDEFINED; + } + else + { + State = CS_AppData.ResEepromTblPtr[EntryID].State; + } + + CFE_EVS_SendEvent(CS_RECOMPUTE_INVALID_ENTRY_EEPROM_ERR_EID, CFE_EVS_EventType_ERROR, + "EEPROM recompute baseline of entry failed, Entry ID invalid: %d, State: %d, Max ID: %d", + EntryID, State, (CS_MAX_NUM_EEPROM_TABLE_ENTRIES - 1)); + CS_AppData.HkPacket.Payload.CmdErrCounter++; } + } + else + { + /*send event that we can't start another task right now */ + CFE_EVS_SendEvent(CS_RECOMPUTE_EEPROM_CHDTASK_ERR_EID, CFE_EVS_EventType_ERROR, + "Recompute baseline of EEPROM Entry ID %d failed: child task in use", EntryID); + CS_AppData.HkPacket.Payload.CmdErrCounter++; + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -224,55 +221,55 @@ void CS_EnableEntryIDEepromCmd(const CS_EntryCmd_t *CmdPtr) { /* command verification variables */ CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; - if (CS_CheckRecomputeOneshot() == false) + if (CS_CheckRecomputeOneshot() == false) + { + EntryID = CmdPtr->Payload.EntryID; + + if ((EntryID < CS_MAX_NUM_EEPROM_TABLE_ENTRIES) && + (CS_AppData.ResEepromTblPtr[EntryID].State != CS_STATE_EMPTY)) { - EntryID = CmdPtr->Payload.EntryID; + ResultsEntry = &CS_AppData.ResEepromTblPtr[EntryID]; - if ((EntryID < CS_MAX_NUM_EEPROM_TABLE_ENTRIES) && - (CS_AppData.ResEepromTblPtr[EntryID].State != CS_STATE_EMPTY)) + ResultsEntry->State = CS_STATE_ENABLED; + + CFE_EVS_SendEvent(CS_ENABLE_EEPROM_ENTRY_INF_EID, CFE_EVS_EventType_INFORMATION, + "Checksumming of EEPROM Entry ID %d is Enabled", EntryID); + + if (CS_AppData.DefEepromTblPtr[EntryID].State != CS_STATE_EMPTY) + { + CS_AppData.DefEepromTblPtr[EntryID].State = CS_STATE_ENABLED; + CS_ResetTablesTblResultEntry(CS_AppData.EepResTablesTblPtr); + CFE_TBL_Modified(CS_AppData.DefEepromTableHandle); + } + else { - ResultsEntry = &CS_AppData.ResEepromTblPtr[EntryID]; - - ResultsEntry->State = CS_STATE_ENABLED; - - CFE_EVS_SendEvent(CS_ENABLE_EEPROM_ENTRY_INF_EID, CFE_EVS_EventType_INFORMATION, - "Checksumming of EEPROM Entry ID %d is Enabled", EntryID); - - if (CS_AppData.DefEepromTblPtr[EntryID].State != CS_STATE_EMPTY) - { - CS_AppData.DefEepromTblPtr[EntryID].State = CS_STATE_ENABLED; - CS_ResetTablesTblResultEntry(CS_AppData.EepResTablesTblPtr); - CFE_TBL_Modified(CS_AppData.DefEepromTableHandle); - } - else - { - CFE_EVS_SendEvent(CS_ENABLE_EEPROM_DEF_EMPTY_DBG_EID, CFE_EVS_EventType_DEBUG, - "CS unable to update EEPROM definition table for entry %d, State: %d", EntryID, - State); - } + CFE_EVS_SendEvent(CS_ENABLE_EEPROM_DEF_EMPTY_DBG_EID, CFE_EVS_EventType_DEBUG, + "CS unable to update EEPROM definition table for entry %d, State: %d", EntryID, + State); + } - CS_AppData.HkPacket.Payload.CmdCounter++; + CS_AppData.HkPacket.Payload.CmdCounter++; + } + else + { + if (EntryID >= CS_MAX_NUM_EEPROM_TABLE_ENTRIES) + { + State = CS_STATE_UNDEFINED; } else { - if (EntryID >= CS_MAX_NUM_EEPROM_TABLE_ENTRIES) - { - State = CS_STATE_UNDEFINED; - } - else - { - State = CS_AppData.ResEepromTblPtr[EntryID].State; - } - - CFE_EVS_SendEvent(CS_ENABLE_EEPROM_INVALID_ENTRY_ERR_EID, CFE_EVS_EventType_ERROR, - "Enable EEPROM entry failed, invalid Entry ID: %d, State: %d, Max ID: %d", EntryID, - State, (CS_MAX_NUM_EEPROM_TABLE_ENTRIES - 1)); - CS_AppData.HkPacket.Payload.CmdErrCounter++; + State = CS_AppData.ResEepromTblPtr[EntryID].State; } - } /* end InProgress if */ + + CFE_EVS_SendEvent(CS_ENABLE_EEPROM_INVALID_ENTRY_ERR_EID, CFE_EVS_EventType_ERROR, + "Enable EEPROM entry failed, invalid Entry ID: %d, State: %d, Max ID: %d", EntryID, + State, (CS_MAX_NUM_EEPROM_TABLE_ENTRIES - 1)); + CS_AppData.HkPacket.Payload.CmdErrCounter++; + } + } /* end InProgress if */ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -284,58 +281,58 @@ void CS_DisableEntryIDEepromCmd(const CS_EntryCmd_t *CmdPtr) { /* command verification variables */ CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; - if (CS_CheckRecomputeOneshot() == false) + if (CS_CheckRecomputeOneshot() == false) + { + EntryID = CmdPtr->Payload.EntryID; + + if ((EntryID < CS_MAX_NUM_EEPROM_TABLE_ENTRIES) && + (CS_AppData.ResEepromTblPtr[EntryID].State != CS_STATE_EMPTY)) { - EntryID = CmdPtr->Payload.EntryID; + ResultsEntry = &CS_AppData.ResEepromTblPtr[EntryID]; - if ((EntryID < CS_MAX_NUM_EEPROM_TABLE_ENTRIES) && - (CS_AppData.ResEepromTblPtr[EntryID].State != CS_STATE_EMPTY)) - { - ResultsEntry = &CS_AppData.ResEepromTblPtr[EntryID]; - - ResultsEntry->State = CS_STATE_DISABLED; - ResultsEntry->TempChecksumValue = 0; - ResultsEntry->ByteOffset = 0; - - CFE_EVS_SendEvent(CS_DISABLE_EEPROM_ENTRY_INF_EID, CFE_EVS_EventType_INFORMATION, - "Checksumming of EEPROM Entry ID %d is Disabled", EntryID); - - if (CS_AppData.DefEepromTblPtr[EntryID].State != CS_STATE_EMPTY) - { - CS_AppData.DefEepromTblPtr[EntryID].State = CS_STATE_DISABLED; - CS_ResetTablesTblResultEntry(CS_AppData.EepResTablesTblPtr); - CFE_TBL_Modified(CS_AppData.DefEepromTableHandle); - } - else - { - CFE_EVS_SendEvent(CS_DISABLE_EEPROM_DEF_EMPTY_DBG_EID, CFE_EVS_EventType_DEBUG, - "CS unable to update EEPROM definition table for entry %d, State: %d", EntryID, - State); - } + ResultsEntry->State = CS_STATE_DISABLED; + ResultsEntry->TempChecksumValue = 0; + ResultsEntry->ByteOffset = 0; - CS_AppData.HkPacket.Payload.CmdCounter++; + CFE_EVS_SendEvent(CS_DISABLE_EEPROM_ENTRY_INF_EID, CFE_EVS_EventType_INFORMATION, + "Checksumming of EEPROM Entry ID %d is Disabled", EntryID); + + if (CS_AppData.DefEepromTblPtr[EntryID].State != CS_STATE_EMPTY) + { + CS_AppData.DefEepromTblPtr[EntryID].State = CS_STATE_DISABLED; + CS_ResetTablesTblResultEntry(CS_AppData.EepResTablesTblPtr); + CFE_TBL_Modified(CS_AppData.DefEepromTableHandle); } else { - if (EntryID >= CS_MAX_NUM_EEPROM_TABLE_ENTRIES) - { - State = CS_STATE_UNDEFINED; - } - else - { - State = CS_AppData.ResEepromTblPtr[EntryID].State; - } - - CFE_EVS_SendEvent(CS_DISABLE_EEPROM_INVALID_ENTRY_ERR_EID, CFE_EVS_EventType_ERROR, - "Disable EEPROM entry failed, invalid Entry ID: %d, State: %d, Max ID: %d", EntryID, - State, (CS_MAX_NUM_EEPROM_TABLE_ENTRIES - 1)); + CFE_EVS_SendEvent(CS_DISABLE_EEPROM_DEF_EMPTY_DBG_EID, CFE_EVS_EventType_DEBUG, + "CS unable to update EEPROM definition table for entry %d, State: %d", EntryID, + State); + } - CS_AppData.HkPacket.Payload.CmdErrCounter++; + CS_AppData.HkPacket.Payload.CmdCounter++; + } + else + { + if (EntryID >= CS_MAX_NUM_EEPROM_TABLE_ENTRIES) + { + State = CS_STATE_UNDEFINED; + } + else + { + State = CS_AppData.ResEepromTblPtr[EntryID].State; } - } /* end InProgress if */ + + CFE_EVS_SendEvent(CS_DISABLE_EEPROM_INVALID_ENTRY_ERR_EID, CFE_EVS_EventType_ERROR, + "Disable EEPROM entry failed, invalid Entry ID: %d, State: %d, Max ID: %d", EntryID, + State, (CS_MAX_NUM_EEPROM_TABLE_ENTRIES - 1)); + + CS_AppData.HkPacket.Payload.CmdErrCounter++; + } + } /* end InProgress if */ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -347,30 +344,31 @@ void CS_GetEntryIDEepromCmd(const CS_GetEntryIDCmd_t *CmdPtr) { /* command verification variables */ CS_Res_EepromMemory_Table_Entry_t *StartOfResultsTable = NULL; - uint16 Loop = 0; - bool EntryFound = false; + uint16 Loop; + bool EntryFound = false; CS_Res_EepromMemory_Table_Entry_t ResultsEntry; - StartOfResultsTable = CS_AppData.ResEepromTblPtr; + StartOfResultsTable = CS_AppData.ResEepromTblPtr; - for (Loop = 0; Loop < CS_MAX_NUM_EEPROM_TABLE_ENTRIES; Loop++) - { - ResultsEntry = StartOfResultsTable[Loop]; + for (Loop = 0; Loop < CS_MAX_NUM_EEPROM_TABLE_ENTRIES; Loop++) + { + ResultsEntry = StartOfResultsTable[Loop]; - if ((ResultsEntry.StartAddress <= CmdPtr->Payload.Address) && - CmdPtr->Payload.Address <= (ResultsEntry.StartAddress + ResultsEntry.NumBytesToChecksum) && - ResultsEntry.State != CS_STATE_EMPTY) - { - CFE_EVS_SendEvent(CS_GET_ENTRY_ID_EEPROM_INF_EID, CFE_EVS_EventType_INFORMATION, - "EEPROM Found Address 0x%08X in Entry ID %d", (unsigned int)(CmdPtr->Payload.Address), Loop); - EntryFound = true; - } - } - - if (EntryFound == false) + if ((ResultsEntry.StartAddress <= CmdPtr->Payload.Address) && + CmdPtr->Payload.Address <= (ResultsEntry.StartAddress + ResultsEntry.NumBytesToChecksum) && + ResultsEntry.State != CS_STATE_EMPTY) { - CFE_EVS_SendEvent(CS_GET_ENTRY_ID_EEPROM_NOT_FOUND_INF_EID, CFE_EVS_EventType_INFORMATION, - "Address 0x%08X was not found in EEPROM table", (unsigned int)(CmdPtr->Payload.Address)); + CFE_EVS_SendEvent(CS_GET_ENTRY_ID_EEPROM_INF_EID, CFE_EVS_EventType_INFORMATION, + "EEPROM Found Address 0x%08X in Entry ID %d", (unsigned int)(CmdPtr->Payload.Address), + Loop); + EntryFound = true; } - CS_AppData.HkPacket.Payload.CmdCounter++; + } + + if (EntryFound == false) + { + CFE_EVS_SendEvent(CS_GET_ENTRY_ID_EEPROM_NOT_FOUND_INF_EID, CFE_EVS_EventType_INFORMATION, + "Address 0x%08X was not found in EEPROM table", (unsigned int)(CmdPtr->Payload.Address)); + } + CS_AppData.HkPacket.Payload.CmdCounter++; } diff --git a/fsw/src/cs_init.c b/fsw/src/cs_init.c index 0e85746..47c2b2d 100644 --- a/fsw/src/cs_init.c +++ b/fsw/src/cs_init.c @@ -39,7 +39,7 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_SbInit(void) { - CFE_Status_t Result = CFE_SUCCESS; + CFE_Status_t Result; /* Initialize app configuration data */ strncpy(CS_AppData.PipeName, CS_CMD_PIPE_NAME, CS_CMD_PIPE_NAME_LEN); @@ -99,7 +99,7 @@ CFE_Status_t CS_SbInit(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_InitAllTables(void) { - CFE_Status_t ResultInit = CFE_SUCCESS; + CFE_Status_t ResultInit; ResultInit = CS_TableInit(&CS_AppData.DefEepromTableHandle, &CS_AppData.ResEepromTableHandle, (void *)&CS_AppData.DefEepromTblPtr, (void *)&CS_AppData.ResEepromTblPtr, CS_EEPROM_TABLE, @@ -174,7 +174,7 @@ CFE_Status_t CS_InitAllTables(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_InitSegments(void) { - int32 ResultSegment = OS_SUCCESS; + int32 ResultSegment; uint32 CFESize; cpuaddr CFEAddress; uint32 KernelSize; diff --git a/fsw/src/cs_memory_cmds.c b/fsw/src/cs_memory_cmds.c index 41a698d..c806e40 100644 --- a/fsw/src/cs_memory_cmds.c +++ b/fsw/src/cs_memory_cmds.c @@ -95,9 +95,9 @@ void CS_ReportBaselineEntryIDMemoryCmd(const CS_EntryCmd_t *CmdPtr) { /* command verification variables */ CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL; - uint32 Baseline = 0; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + uint32 Baseline; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; EntryID = CmdPtr->Payload.EntryID; @@ -147,9 +147,9 @@ void CS_RecomputeBaselineMemoryCmd(const CS_EntryCmd_t *CmdPtr) { /* command verification variables */ CFE_ES_TaskId_t ChildTaskID = CFE_ES_TASKID_UNDEFINED; - CFE_Status_t Status = CS_ERROR; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + CFE_Status_t Status; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; EntryID = CmdPtr->Payload.EntryID; @@ -224,8 +224,8 @@ void CS_EnableEntryIDMemoryCmd(const CS_EntryCmd_t *CmdPtr) { /* command verification variables */ CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; if (CS_CheckRecomputeOneshot() == false) { @@ -284,8 +284,8 @@ void CS_DisableEntryIDMemoryCmd(const CS_EntryCmd_t *CmdPtr) { /* command verification variables */ CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL; - uint16 EntryID = 0; - uint16 State = CS_STATE_EMPTY; + uint16 EntryID; + uint16 State = CS_STATE_EMPTY; if (CS_CheckRecomputeOneshot() == false) { @@ -348,8 +348,8 @@ void CS_GetEntryIDMemoryCmd(const CS_GetEntryIDCmd_t *CmdPtr) /* command verification variables */ CS_Res_EepromMemory_Table_Entry_t *StartOfResultsTable = NULL; CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL; - uint16 Loop = 0; - bool EntryFound = false; + uint16 Loop; + bool EntryFound = false; StartOfResultsTable = CS_AppData.ResMemoryTblPtr; diff --git a/fsw/src/cs_memory_cmds.h b/fsw/src/cs_memory_cmds.h index f8ec7d7..c5a6ed6 100644 --- a/fsw/src/cs_memory_cmds.h +++ b/fsw/src/cs_memory_cmds.h @@ -157,7 +157,6 @@ void CS_EnableEntryIDMemoryCmd(const CS_EntryCmd_t *CmdPtr); * \par Assumptions, External Events, and Notes: * None * - * * \param[in] CmdPtr Command pointer, verified non-null in CS_AppMain * * \sa #CS_GET_ENTRY_ID_MEMORY_CC diff --git a/fsw/src/cs_table_cmds.c b/fsw/src/cs_table_cmds.c index 80e3112..9e42c96 100644 --- a/fsw/src/cs_table_cmds.c +++ b/fsw/src/cs_table_cmds.c @@ -46,19 +46,19 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_DisableTablesCmd(const CS_NoArgsCmd_t *CmdPtr) { - if (CS_CheckRecomputeOneshot() == false) - { - CS_AppData.HkPacket.Payload.TablesCSState = CS_STATE_DISABLED; - CS_ZeroTablesTempValues(); + if (CS_CheckRecomputeOneshot() == false) + { + CS_AppData.HkPacket.Payload.TablesCSState = CS_STATE_DISABLED; + CS_ZeroTablesTempValues(); #if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true) - CS_UpdateCDS(); + CS_UpdateCDS(); #endif - CFE_EVS_SendEvent(CS_DISABLE_TABLES_INF_EID, CFE_EVS_EventType_INFORMATION, - "Checksumming of Tables is Disabled"); - CS_AppData.HkPacket.Payload.CmdCounter++; - } + CFE_EVS_SendEvent(CS_DISABLE_TABLES_INF_EID, CFE_EVS_EventType_INFORMATION, + "Checksumming of Tables is Disabled"); + CS_AppData.HkPacket.Payload.CmdCounter++; + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -68,18 +68,17 @@ void CS_DisableTablesCmd(const CS_NoArgsCmd_t *CmdPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_EnableTablesCmd(const CS_NoArgsCmd_t *CmdPtr) { - if (CS_CheckRecomputeOneshot() == false) - { - CS_AppData.HkPacket.Payload.TablesCSState = CS_STATE_ENABLED; + if (CS_CheckRecomputeOneshot() == false) + { + CS_AppData.HkPacket.Payload.TablesCSState = CS_STATE_ENABLED; #if (CS_PRESERVE_STATES_ON_PROCESSOR_RESET == true) - CS_UpdateCDS(); + CS_UpdateCDS(); #endif - CFE_EVS_SendEvent(CS_ENABLE_TABLES_INF_EID, CFE_EVS_EventType_INFORMATION, - "Checksumming of Tables is Enabled"); - CS_AppData.HkPacket.Payload.CmdCounter++; - } + CFE_EVS_SendEvent(CS_ENABLE_TABLES_INF_EID, CFE_EVS_EventType_INFORMATION, "Checksumming of Tables is Enabled"); + CS_AppData.HkPacket.Payload.CmdCounter++; + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -92,31 +91,34 @@ void CS_ReportBaselineTablesCmd(const CS_TableNameCmd_t *CmdPtr) CS_Res_Tables_Table_Entry_t *ResultsEntry; uint32 Baseline; char Name[CFE_TBL_MAX_FULL_NAME_LEN]; + bool Status; - strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); - Name[sizeof(Name) - 1] = '\0'; + strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); + Name[sizeof(Name) - 1] = '\0'; + + Status = CS_GetTableResTblEntryByName(&ResultsEntry, Name); - if (CS_GetTableResTblEntryByName(&ResultsEntry, Name)) + if (Status) + { + if (ResultsEntry->ComputedYet == true) { - if (ResultsEntry->ComputedYet == true) - { - Baseline = ResultsEntry->ComparisonValue; - CFE_EVS_SendEvent(CS_BASELINE_TABLES_INF_EID, CFE_EVS_EventType_INFORMATION, - "Report baseline of table %s is 0x%08X", Name, (unsigned int)Baseline); - } - else - { - CFE_EVS_SendEvent(CS_NO_BASELINE_TABLES_INF_EID, CFE_EVS_EventType_INFORMATION, - "Report baseline of table %s has not been computed yet", Name); - } - CS_AppData.HkPacket.Payload.CmdCounter++; + Baseline = ResultsEntry->ComparisonValue; + CFE_EVS_SendEvent(CS_BASELINE_TABLES_INF_EID, CFE_EVS_EventType_INFORMATION, + "Report baseline of table %s is 0x%08X", Name, (unsigned int)Baseline); } else { - CFE_EVS_SendEvent(CS_BASELINE_INVALID_NAME_TABLES_ERR_EID, CFE_EVS_EventType_ERROR, - "Tables report baseline failed, table %s not found", Name); - CS_AppData.HkPacket.Payload.CmdErrCounter++; + CFE_EVS_SendEvent(CS_NO_BASELINE_TABLES_INF_EID, CFE_EVS_EventType_INFORMATION, + "Report baseline of table %s has not been computed yet", Name); } + CS_AppData.HkPacket.Payload.CmdCounter++; + } + else + { + CFE_EVS_SendEvent(CS_BASELINE_INVALID_NAME_TABLES_ERR_EID, CFE_EVS_EventType_ERROR, + "Tables report baseline failed, table %s not found", Name); + CS_AppData.HkPacket.Payload.CmdErrCounter++; + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -130,54 +132,58 @@ void CS_RecomputeBaselineTablesCmd(const CS_TableNameCmd_t *CmdPtr) CFE_Status_t Status; CS_Res_Tables_Table_Entry_t *ResultsEntry; char Name[CFE_TBL_MAX_FULL_NAME_LEN]; + bool Result; - if (CS_AppData.HkPacket.Payload.RecomputeInProgress == false && CS_AppData.HkPacket.Payload.OneShotInProgress == false) + if (CS_AppData.HkPacket.Payload.RecomputeInProgress == false && + CS_AppData.HkPacket.Payload.OneShotInProgress == false) + { + strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); + Name[sizeof(Name) - 1] = '\0'; + + /* make sure the entry is a valid number and is defined in the table */ + Result = CS_GetTableResTblEntryByName(&ResultsEntry, Name); + + if (Result) { - strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); - Name[sizeof(Name) - 1] = '\0'; + /* There is no child task running right now, we can use it*/ + CS_AppData.HkPacket.Payload.RecomputeInProgress = true; + + /* fill in child task variables */ + CS_AppData.ChildTaskTable = CS_TABLES_TABLE; - /* make sure the entry is a valid number and is defined in the table */ - if (CS_GetTableResTblEntryByName(&ResultsEntry, Name)) + CS_AppData.RecomputeTablesEntryPtr = ResultsEntry; + + Status = CFE_ES_CreateChildTask(&ChildTaskID, CS_RECOMP_TABLES_TASK_NAME, CS_RecomputeTablesChildTask, NULL, + CFE_PLATFORM_ES_DEFAULT_STACK_SIZE, CS_CHILD_TASK_PRIORITY, 0); + if (Status == CFE_SUCCESS) { - /* There is no child task running right now, we can use it*/ - CS_AppData.HkPacket.Payload.RecomputeInProgress = true; - - /* fill in child task variables */ - CS_AppData.ChildTaskTable = CS_TABLES_TABLE; - - CS_AppData.RecomputeTablesEntryPtr = ResultsEntry; - - Status = CFE_ES_CreateChildTask(&ChildTaskID, CS_RECOMP_TABLES_TASK_NAME, CS_RecomputeTablesChildTask, - NULL, CFE_PLATFORM_ES_DEFAULT_STACK_SIZE, CS_CHILD_TASK_PRIORITY, 0); - if (Status == CFE_SUCCESS) - { - CFE_EVS_SendEvent(CS_RECOMPUTE_TABLES_STARTED_DBG_EID, CFE_EVS_EventType_DEBUG, - "Recompute baseline of table %s started", Name); - CS_AppData.HkPacket.Payload.CmdCounter++; - } - else /* child task creation failed */ - { - CFE_EVS_SendEvent(CS_RECOMPUTE_TABLES_CREATE_CHDTASK_ERR_EID, CFE_EVS_EventType_ERROR, - "Recompute baseline of table %s failed, CFE_ES_CreateChildTask returned: 0x%08X", - Name, (unsigned int)Status); - CS_AppData.HkPacket.Payload.CmdErrCounter++; - CS_AppData.HkPacket.Payload.RecomputeInProgress = false; - } + CFE_EVS_SendEvent(CS_RECOMPUTE_TABLES_STARTED_DBG_EID, CFE_EVS_EventType_DEBUG, + "Recompute baseline of table %s started", Name); + CS_AppData.HkPacket.Payload.CmdCounter++; } - else + else /* child task creation failed */ { - CFE_EVS_SendEvent(CS_RECOMPUTE_UNKNOWN_NAME_TABLES_ERR_EID, CFE_EVS_EventType_ERROR, - "Tables recompute baseline failed, table %s not found", Name); + CFE_EVS_SendEvent(CS_RECOMPUTE_TABLES_CREATE_CHDTASK_ERR_EID, CFE_EVS_EventType_ERROR, + "Recompute baseline of table %s failed, CFE_ES_CreateChildTask returned: 0x%08X", + Name, (unsigned int)Status); CS_AppData.HkPacket.Payload.CmdErrCounter++; + CS_AppData.HkPacket.Payload.RecomputeInProgress = false; } } else { - /*send event that we can't start another task right now */ - CFE_EVS_SendEvent(CS_RECOMPUTE_TABLES_CHDTASK_ERR_EID, CFE_EVS_EventType_ERROR, - "Tables recompute baseline for table %s failed: child task in use", Name); + CFE_EVS_SendEvent(CS_RECOMPUTE_UNKNOWN_NAME_TABLES_ERR_EID, CFE_EVS_EventType_ERROR, + "Tables recompute baseline failed, table %s not found", Name); CS_AppData.HkPacket.Payload.CmdErrCounter++; } + } + else + { + /*send event that we can't start another task right now */ + CFE_EVS_SendEvent(CS_RECOMPUTE_TABLES_CHDTASK_ERR_EID, CFE_EVS_EventType_ERROR, + "Tables recompute baseline for table %s failed: child task in use", Name); + CS_AppData.HkPacket.Payload.CmdErrCounter++; + } } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -190,42 +196,47 @@ void CS_DisableNameTablesCmd(const CS_TableNameCmd_t *CmdPtr) CS_Res_Tables_Table_Entry_t *ResultsEntry; CS_Def_Tables_Table_Entry_t *DefinitionEntry; char Name[CFE_TBL_MAX_FULL_NAME_LEN]; + bool Status; + + if (CS_CheckRecomputeOneshot() == false) + { + strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); + Name[sizeof(Name) - 1] = '\0'; + + Status = CS_GetTableResTblEntryByName(&ResultsEntry, Name); - if (CS_CheckRecomputeOneshot() == false) + if (Status) { - strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); - Name[sizeof(Name) - 1] = '\0'; + ResultsEntry->State = CS_STATE_DISABLED; + ResultsEntry->TempChecksumValue = 0; + ResultsEntry->ByteOffset = 0; - if (CS_GetTableResTblEntryByName(&ResultsEntry, Name)) - { - ResultsEntry->State = CS_STATE_DISABLED; - ResultsEntry->TempChecksumValue = 0; - ResultsEntry->ByteOffset = 0; - - CFE_EVS_SendEvent(CS_DISABLE_TABLES_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, - "Checksumming of table %s is Disabled", Name); - - if (CS_GetTableDefTblEntryByName(&DefinitionEntry, Name)) - { - DefinitionEntry->State = CS_STATE_DISABLED; - CS_ResetTablesTblResultEntry(CS_AppData.TblResTablesTblPtr); - CFE_TBL_Modified(CS_AppData.DefTablesTableHandle); - } - else - { - CFE_EVS_SendEvent(CS_DISABLE_TABLE_DEF_NOT_FOUND_DBG_EID, CFE_EVS_EventType_DEBUG, - "CS unable to update tables definition table for entry %s", Name); - } + CFE_EVS_SendEvent(CS_DISABLE_TABLES_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, + "Checksumming of table %s is Disabled", Name); - CS_AppData.HkPacket.Payload.CmdCounter++; + Status = CS_GetTableDefTblEntryByName(&DefinitionEntry, Name); + + if (Status) + { + DefinitionEntry->State = CS_STATE_DISABLED; + CS_ResetTablesTblResultEntry(CS_AppData.TblResTablesTblPtr); + CFE_TBL_Modified(CS_AppData.DefTablesTableHandle); } else { - CFE_EVS_SendEvent(CS_DISABLE_TABLES_UNKNOWN_NAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Tables disable table command failed, table %s not found", Name); - CS_AppData.HkPacket.Payload.CmdErrCounter++; + CFE_EVS_SendEvent(CS_DISABLE_TABLE_DEF_NOT_FOUND_DBG_EID, CFE_EVS_EventType_DEBUG, + "CS unable to update tables definition table for entry %s", Name); } - } /* end InProgress if */ + + CS_AppData.HkPacket.Payload.CmdCounter++; + } + else + { + CFE_EVS_SendEvent(CS_DISABLE_TABLES_UNKNOWN_NAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Tables disable table command failed, table %s not found", Name); + CS_AppData.HkPacket.Payload.CmdErrCounter++; + } + } /* end InProgress if */ } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -238,38 +249,43 @@ void CS_EnableNameTablesCmd(const CS_TableNameCmd_t *CmdPtr) CS_Res_Tables_Table_Entry_t *ResultsEntry; CS_Def_Tables_Table_Entry_t *DefinitionEntry; char Name[CFE_TBL_MAX_FULL_NAME_LEN]; + bool Status; + + if (CS_CheckRecomputeOneshot() == false) + { + strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); + Name[sizeof(Name) - 1] = '\0'; + + Status = CS_GetTableResTblEntryByName(&ResultsEntry, Name); - if (CS_CheckRecomputeOneshot() == false) + if (Status) { - strncpy(Name, CmdPtr->Payload.Name, sizeof(Name) - 1); - Name[sizeof(Name) - 1] = '\0'; + ResultsEntry->State = CS_STATE_ENABLED; - if (CS_GetTableResTblEntryByName(&ResultsEntry, Name)) - { - ResultsEntry->State = CS_STATE_ENABLED; - - CFE_EVS_SendEvent(CS_ENABLE_TABLES_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, - "Checksumming of table %s is Enabled", Name); - - if (CS_GetTableDefTblEntryByName(&DefinitionEntry, Name)) - { - DefinitionEntry->State = CS_STATE_ENABLED; - CS_ResetTablesTblResultEntry(CS_AppData.TblResTablesTblPtr); - CFE_TBL_Modified(CS_AppData.DefTablesTableHandle); - } - else - { - CFE_EVS_SendEvent(CS_ENABLE_TABLE_DEF_NOT_FOUND_DBG_EID, CFE_EVS_EventType_DEBUG, - "CS unable to update tables definition table for entry %s", Name); - } + CFE_EVS_SendEvent(CS_ENABLE_TABLES_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, + "Checksumming of table %s is Enabled", Name); - CS_AppData.HkPacket.Payload.CmdCounter++; + Status = CS_GetTableDefTblEntryByName(&DefinitionEntry, Name); + + if (Status) + { + DefinitionEntry->State = CS_STATE_ENABLED; + CS_ResetTablesTblResultEntry(CS_AppData.TblResTablesTblPtr); + CFE_TBL_Modified(CS_AppData.DefTablesTableHandle); } else { - CFE_EVS_SendEvent(CS_ENABLE_TABLES_UNKNOWN_NAME_ERR_EID, CFE_EVS_EventType_ERROR, - "Tables enable table command failed, table %s not found", Name); - CS_AppData.HkPacket.Payload.CmdErrCounter++; + CFE_EVS_SendEvent(CS_ENABLE_TABLE_DEF_NOT_FOUND_DBG_EID, CFE_EVS_EventType_DEBUG, + "CS unable to update tables definition table for entry %s", Name); } - } /* end InProgress if */ + + CS_AppData.HkPacket.Payload.CmdCounter++; + } + else + { + CFE_EVS_SendEvent(CS_ENABLE_TABLES_UNKNOWN_NAME_ERR_EID, CFE_EVS_EventType_ERROR, + "Tables enable table command failed, table %s not found", Name); + CS_AppData.HkPacket.Payload.CmdErrCounter++; + } + } /* end InProgress if */ } diff --git a/fsw/src/cs_table_processing.c b/fsw/src/cs_table_processing.c index 405c714..af0bfdc 100644 --- a/fsw/src/cs_table_processing.c +++ b/fsw/src/cs_table_processing.c @@ -47,17 +47,17 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_ValidateEepromChecksumDefinitionTable(void *TblPtr) { - CFE_Status_t Result = CFE_SUCCESS; - CFE_Status_t Status = OS_ERROR; + CFE_Status_t Result = CFE_SUCCESS; + CFE_Status_t Status; CS_Def_EepromMemory_Table_Entry_t *StartOfTable = NULL; CS_Def_EepromMemory_Table_Entry_t *OuterEntry = NULL; - int32 OuterLoop = 0; - uint32 StateField = 0; - cpuaddr Address = 0; - uint32 Size = 0; - int32 GoodCount = 0; - int32 BadCount = 0; - int32 EmptyCount = 0; + int32 OuterLoop; + uint32 StateField; + cpuaddr Address; + uint32 Size; + int32 GoodCount = 0; + int32 BadCount = 0; + int32 EmptyCount = 0; StartOfTable = (CS_Def_EepromMemory_Table_Entry_t *)TblPtr; @@ -127,22 +127,20 @@ CFE_Status_t CS_ValidateEepromChecksumDefinitionTable(void *TblPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_ValidateMemoryChecksumDefinitionTable(void *TblPtr) { - CFE_Status_t Result = CFE_SUCCESS; - CFE_Status_t Status = OS_ERROR; + CFE_Status_t Result = CFE_SUCCESS; + CFE_Status_t Status; CS_Def_EepromMemory_Table_Entry_t *StartOfTable = NULL; CS_Def_EepromMemory_Table_Entry_t *OuterEntry = NULL; - int32 OuterLoop = 0; - uint32 StateField = 0; - cpuaddr Address = 0; - uint32 Size = 0; - int32 GoodCount = 0; - int32 BadCount = 0; - int32 EmptyCount = 0; + int32 OuterLoop; + uint32 StateField; + cpuaddr Address; + uint32 Size; + int32 GoodCount = 0; + int32 BadCount = 0; + int32 EmptyCount = 0; StartOfTable = (CS_Def_EepromMemory_Table_Entry_t *)TblPtr; - Result = CFE_SUCCESS; - for (OuterLoop = 0; OuterLoop < CS_MAX_NUM_MEMORY_TABLE_ENTRIES; OuterLoop++) { OuterEntry = &StartOfTable[OuterLoop]; @@ -211,16 +209,16 @@ CFE_Status_t CS_ValidateMemoryChecksumDefinitionTable(void *TblPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_ValidateTablesChecksumDefinitionTable(void *TblPtr) { - CFE_Status_t Result = CFE_SUCCESS; - CS_Def_Tables_Table_Entry_t *StartOfTable = NULL; - CS_Def_Tables_Table_Entry_t *OuterEntry = NULL; - int32 OuterLoop = 0; - int32 InnerLoop = 0; - uint32 StateField = 0; - int32 GoodCount = 0; - int32 BadCount = 0; - int32 EmptyCount = 0; - bool DuplicateFound = false; + CFE_Status_t Result = CFE_SUCCESS; + CS_Def_Tables_Table_Entry_t *StartOfTable = NULL; + CS_Def_Tables_Table_Entry_t *OuterEntry = NULL; + int32 OuterLoop; + int32 InnerLoop; + uint32 StateField; + int32 GoodCount = 0; + int32 BadCount = 0; + int32 EmptyCount = 0; + bool DuplicateFound; StartOfTable = (CS_Def_Tables_Table_Entry_t *)TblPtr; @@ -474,6 +472,7 @@ void CS_ProcessNewEepromMemoryDefinitionTable(const CS_Def_EepromMemory_Table_En PreviousState = CS_AppData.HkPacket.Payload.EepromCSState; CS_AppData.HkPacket.Payload.EepromCSState = CS_STATE_DISABLED; } + if (Table == CS_MEMORY_TABLE) { PreviousState = CS_AppData.HkPacket.Payload.MemoryCSState; @@ -552,15 +551,15 @@ void CS_ProcessNewTablesDefinitionTable(const CS_Def_Tables_Table_Entry_t *Defin CS_Def_Tables_Table_Entry_t *DefEntry = NULL; CS_Res_Tables_Table_Entry_t *StartOfResultsTable = NULL; CS_Res_Tables_Table_Entry_t *ResultsEntry = NULL; - uint16 Loop = 0; - uint16 NumRegionsInTable = 0; - uint16 PreviousState = CS_STATE_EMPTY; - CFE_ES_AppId_t AppID = CFE_ES_APPID_UNDEFINED; - CFE_TBL_Handle_t TableHandle = CFE_TBL_BAD_TABLE_HANDLE; - bool Owned = false; - uint16 DefNameIndex = 0; - uint16 AppNameIndex = 0; - uint16 TableNameIndex = 0; + uint16 Loop; + uint16 NumRegionsInTable = 0; + uint16 PreviousState; + CFE_ES_AppId_t AppID = CFE_ES_APPID_UNDEFINED; + CFE_TBL_Handle_t TableHandle; + bool Owned; + uint16 DefNameIndex; + uint16 AppNameIndex; + uint16 TableNameIndex; char AppName[OS_MAX_API_NAME]; char TableAppName[OS_MAX_API_NAME]; char TableTableName[CFE_MISSION_TBL_MAX_NAME_LENGTH]; @@ -745,9 +744,9 @@ void CS_ProcessNewAppDefinitionTable(const CS_Def_App_Table_Entry_t *DefinitionT CS_Def_App_Table_Entry_t *DefEntry = NULL; CS_Res_App_Table_Entry_t *StartOfResultsTable = NULL; CS_Res_App_Table_Entry_t *ResultsEntry = NULL; - uint16 Loop = 0; - uint16 NumRegionsInTable = 0; - uint16 PreviousState = CS_STATE_EMPTY; + uint16 Loop; + uint16 NumRegionsInTable = 0; + uint16 PreviousState; memcpy(&StartOfResultsTable, ResultsTblPtr, sizeof(StartOfResultsTable)); memcpy(&StartOfDefTable, DefinitionTblPtr, sizeof(StartOfDefTable)); @@ -813,17 +812,17 @@ void CS_ProcessNewAppDefinitionTable(const CS_Def_App_Table_Entry_t *DefinitionT CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handle_t *ResultsTableHandle, void *DefinitionTblPtr, void *ResultsTblPtr, uint16 Table, const char *DefinitionTableName, const char *ResultsTableName, uint16 NumEntries, const char *DefinitionTableFileName, - const void *DefaultDefTableAddress, uint16 SizeofDefinitionTableEntry, - uint16 SizeofResultsTableEntry, CFE_TBL_CallbackFuncPtr_t CallBackFunction) + const void *DefaultDefTableAddress, const size_t SizeofDefinitionTableEntry, + const size_t SizeofResultsTableEntry, CFE_TBL_CallbackFuncPtr_t CallBackFunction) { - CFE_Status_t Result = CFE_SUCCESS; - int32 OS_Status = -1; - CFE_Status_t ResultFromLoad = OS_ERROR; - int32 SizeOfTable = 0; - bool LoadedFromMemory = false; - bool ValidFile = false; - osal_id_t Fd = OS_OBJECT_ID_UNDEFINED; - char TableType[CS_TABLETYPE_NAME_SIZE]; + CFE_Status_t Result; + osal_status_t OS_Status = OS_ERROR; + CFE_Status_t ResultFromLoad = CS_ERROR; + size_t SizeOfTable; + bool LoadedFromMemory = false; + bool ValidFile = false; + osal_id_t Fd = OS_OBJECT_ID_UNDEFINED; + char TableType[CS_TABLETYPE_NAME_SIZE]; strncpy(TableType, "Undef Tbl", CS_TABLETYPE_NAME_SIZE); /* Init table type */ @@ -957,14 +956,14 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl CFE_Status_t CS_HandleTableUpdate(void *DefinitionTblPtr, void *ResultsTblPtr, CFE_TBL_Handle_t DefinitionTableHandle, CFE_TBL_Handle_t ResultsTableHandle, uint16 Table, uint16 NumEntries) { - CFE_Status_t ReleaseResult1 = CFE_SUCCESS; - CFE_Status_t ManageResult1 = CFE_SUCCESS; - CFE_Status_t GetResult1 = CFE_SUCCESS; - CFE_Status_t ReleaseResult2 = CFE_SUCCESS; - CFE_Status_t ManageResult2 = CFE_SUCCESS; - CFE_Status_t GetResult2 = CFE_SUCCESS; - CFE_Status_t Result = CFE_SUCCESS; - int32 Loop = 0; + CFE_Status_t ReleaseResult1; + CFE_Status_t ManageResult1; + CFE_Status_t GetResult1; + CFE_Status_t ReleaseResult2; + CFE_Status_t ManageResult2; + CFE_Status_t GetResult2 = CFE_SUCCESS; + CFE_Status_t Result; + int32 Loop; char TableType[CS_TABLETYPE_NAME_SIZE]; strncpy(TableType, "Undef Tbl", CS_TABLETYPE_NAME_SIZE); /* Init table type */ diff --git a/fsw/src/cs_utils.c b/fsw/src/cs_utils.c index 41f13d4..1aa4152 100644 --- a/fsw/src/cs_utils.c +++ b/fsw/src/cs_utils.c @@ -210,6 +210,7 @@ bool CS_GetTableResTblEntryByName(CS_Res_Tables_Table_Entry_t **EntryPtr, const break; } } + return Status; } @@ -241,6 +242,7 @@ bool CS_GetTableDefTblEntryByName(CS_Def_Tables_Table_Entry_t **EntryPtr, const break; } } + return Status; } @@ -271,6 +273,7 @@ bool CS_GetAppResTblEntryByName(CS_Res_App_Table_Entry_t **EntryPtr, const char break; } } + return Status; } @@ -301,6 +304,7 @@ bool CS_GetAppDefTblEntryByName(CS_Def_App_Table_Entry_t **EntryPtr, const char break; } } + return Status; } @@ -405,6 +409,7 @@ bool CS_FindEnabledTablesEntry(uint16 *EnabledEntry) return EnabledEntries; } + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* CS Get the next CS-enabled entry of this table */ @@ -466,6 +471,7 @@ bool CS_VerifyCmdLength(const CFE_MSG_Message_t *msg, size_t ExpectedLength) Result = false; CS_AppData.HkPacket.Payload.CmdErrCounter++; } + return Result; } @@ -617,10 +623,13 @@ bool CS_BackgroundEeprom(void) uint32 EntireEepromCS; uint16 CurrEntry; CFE_Status_t Status; + bool Result; if (CS_AppData.HkPacket.Payload.EepromCSState == CS_STATE_ENABLED) { - if (CS_FindEnabledEepromEntry(&CurrEntry) == true) + Result = CS_FindEnabledEepromEntry(&CurrEntry); + + if (Result) { /* we found an enabled entry to checksum */ StartOfResultsTable = CS_AppData.ResEepromTblPtr; @@ -690,12 +699,15 @@ bool CS_BackgroundMemory(void) uint32 ComputedCSValue = 0; uint16 CurrEntry; CFE_Status_t Status; + bool Result; if (CS_AppData.HkPacket.Payload.MemoryCSState == CS_STATE_ENABLED) { /* If we complete an entry's checksum, this function will update it for us */ - if (CS_FindEnabledMemoryEntry(&CurrEntry) == true) + Result = CS_FindEnabledMemoryEntry(&CurrEntry); + + if (Result) { /* we found an enabled entry to checksum */ StartOfResultsTable = CS_AppData.ResMemoryTblPtr; @@ -759,12 +771,15 @@ bool CS_BackgroundTables(void) uint32 ComputedCSValue = 0; uint16 CurrEntry; CFE_Status_t Status; + bool Result; if (CS_AppData.HkPacket.Payload.TablesCSState == CS_STATE_ENABLED) { /* If we complete an entry's checksum, this function will update it for us */ - if (CS_FindEnabledTablesEntry(&CurrEntry) == true) + Result = CS_FindEnabledTablesEntry(&CurrEntry); + + if (Result) { /* we found an enabled entry to checksum */ @@ -836,10 +851,13 @@ bool CS_BackgroundApp(void) uint32 ComputedCSValue = 0; uint16 CurrEntry; CFE_Status_t Status; + bool Result; if (CS_AppData.HkPacket.Payload.AppCSState == CS_STATE_ENABLED) { - if (CS_FindEnabledAppEntry(&CurrEntry) == true) + Result = CS_FindEnabledAppEntry(&CurrEntry); + + if (Result) { /* we found an enabled entry to checksum */ @@ -893,6 +911,7 @@ bool CS_BackgroundApp(void) { CS_GoToNextTable(); } + return DoneWithCycle; } @@ -919,8 +938,8 @@ void CS_ResetTablesTblResultEntry(CS_Res_Tables_Table_Entry_t *TablesTblResultEn /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t CS_HandleRoutineTableUpdates(void) { - CFE_Status_t Result = CFE_SUCCESS; - CFE_Status_t ErrorCode = CFE_SUCCESS; + CFE_Status_t Result; + CFE_Status_t ReturnCode = CFE_SUCCESS; if (!((CS_AppData.HkPacket.Payload.RecomputeInProgress == true) && (CS_AppData.HkPacket.Payload.OneShotInProgress == false) && (CS_AppData.ChildTaskTable == CS_EEPROM_TABLE))) @@ -935,7 +954,7 @@ CFE_Status_t CS_HandleRoutineTableUpdates(void) Result = CFE_EVS_SendEvent(CS_UPDATE_EEPROM_ERR_EID, CFE_EVS_EventType_ERROR, "Table update failed for EEPROM: 0x%08X, checksumming EEPROM is disabled", (unsigned int)Result); - ErrorCode = Result; + ReturnCode = Result; } } @@ -952,9 +971,9 @@ CFE_Status_t CS_HandleRoutineTableUpdates(void) "Table update failed for Memory: 0x%08X, checksumming Memory is disabled", (unsigned int)Result); - if (ErrorCode == CFE_SUCCESS) + if (ReturnCode == CFE_SUCCESS) { - ErrorCode = Result; + ReturnCode = Result; } } } @@ -971,9 +990,9 @@ CFE_Status_t CS_HandleRoutineTableUpdates(void) Result = CFE_EVS_SendEvent(CS_UPDATE_APP_ERR_EID, CFE_EVS_EventType_ERROR, "Table update failed for Apps: 0x%08X, checksumming Apps is disabled", (unsigned int)Result); - if (ErrorCode == CFE_SUCCESS) + if (ReturnCode == CFE_SUCCESS) { - ErrorCode = Result; + ReturnCode = Result; } } } @@ -991,18 +1010,18 @@ CFE_Status_t CS_HandleRoutineTableUpdates(void) Result = CFE_EVS_SendEvent(CS_UPDATE_TABLES_ERR_EID, CFE_EVS_EventType_ERROR, "Table update failed for Tables: 0x%08X, checksumming Tables is disabled", (unsigned int)Result); - if (ErrorCode == CFE_SUCCESS) + if (ReturnCode == CFE_SUCCESS) { - ErrorCode = Result; + ReturnCode = Result; } } } - return ErrorCode; + return ReturnCode; } CFE_Status_t CS_AttemptTableReshare(CS_Res_Tables_Table_Entry_t *ResultsEntry, CFE_TBL_Handle_t *LocalTblHandle, - CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, int32 *ResultGetInfo) + CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, CFE_Status_t *ResultGetInfo) { CFE_Status_t Result; @@ -1042,5 +1061,6 @@ bool CS_CheckRecomputeOneshot(void) Result = true; } + return Result; } diff --git a/fsw/src/cs_utils.h b/fsw/src/cs_utils.h index bea8470..6c10828 100644 --- a/fsw/src/cs_utils.h +++ b/fsw/src/cs_utils.h @@ -498,7 +498,7 @@ CFE_Status_t CS_HandleRoutineTableUpdates(void); * \retval #CFE_SUCCESS \copybrief CFE_SUCCESS */ CFE_Status_t CS_AttemptTableReshare(CS_Res_Tables_Table_Entry_t *ResultsEntry, CFE_TBL_Handle_t *LocalTblHandle, - CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, int32 *ResultGetInfo); + CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, CFE_Status_t *ResultGetInfo); bool CS_CheckRecomputeOneshot(void); diff --git a/unit-test/cs_utils_tests.c b/unit-test/cs_utils_tests.c index b594219..0df776f 100644 --- a/unit-test/cs_utils_tests.c +++ b/unit-test/cs_utils_tests.c @@ -581,7 +581,7 @@ void CS_ResetTablesTblResultEntry_Test(void) void CS_HandleRoutineTableUpdates_Test(void) { uint16 ChildTaskTable[] = {CS_CFECORE, CS_EEPROM_TABLE, CS_MEMORY_TABLE, CS_APP_TABLE, CS_TABLES_TABLE}; - uint16 TblMax = sizeof(ChildTaskTable) / sizeof(ChildTaskTable[0]); + size_t TblMax = sizeof(ChildTaskTable) / sizeof(ChildTaskTable[0]); uint16 i; /* Cycle through each all true case */ diff --git a/unit-test/stubs/cs_table_processing_stubs.c b/unit-test/stubs/cs_table_processing_stubs.c index cca9fe9..3e3acd9 100644 --- a/unit-test/stubs/cs_table_processing_stubs.c +++ b/unit-test/stubs/cs_table_processing_stubs.c @@ -92,7 +92,7 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl void *DefinitionTblPtr, void *ResultsTblPtr, const uint16 Table, const char *DefinitionTableName, const char *ResultsTableName, const uint16 NumEntries, const char *DefinitionTableFileName, const void *DefaultDefTableAddress, - const uint16 SizeofDefinitionTableEntry, const uint16 SizeofResultsTableEntry, + const size_t SizeofDefinitionTableEntry, const size_t SizeofResultsTableEntry, const CFE_TBL_CallbackFuncPtr_t CallBackFunction) { diff --git a/unit-test/stubs/cs_utils_stubs.c b/unit-test/stubs/cs_utils_stubs.c index 0e553ef..5eb1829 100644 --- a/unit-test/stubs/cs_utils_stubs.c +++ b/unit-test/stubs/cs_utils_stubs.c @@ -175,7 +175,7 @@ CFE_Status_t CS_HandleRoutineTableUpdates(void) } CFE_Status_t CS_AttemptTableReshare(CS_Res_Tables_Table_Entry_t *ResultsEntry, CFE_TBL_Handle_t *LocalTblHandle, - CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, int32 *ResultGetInfo) + CFE_TBL_Info_t *TblInfo, cpuaddr *LocalAddress, CFE_Status_t *ResultGetInfo) { UT_Stub_RegisterContext(UT_KEY(CS_AttemptTableReshare), ResultsEntry); UT_Stub_RegisterContext(UT_KEY(CS_AttemptTableReshare), LocalTblHandle);