Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Dec 1, 2024
1 parent f958cc0 commit 973e150
Showing 1 changed file with 64 additions and 90 deletions.
154 changes: 64 additions & 90 deletions fsw/src/cs_table_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ CFE_Status_t CS_ValidateTablesChecksumDefinitionTable(void *TblPtr)
if (OS_strnlen(OuterEntry->Name, CFE_TBL_MAX_FULL_NAME_LEN) != 0)
{
/* Verify valid state definition */
if (((StateField == CS_STATE_EMPTY) || (StateField == CS_STATE_ENABLED) ||
(StateField == CS_STATE_DISABLED)))
if ((StateField == CS_STATE_EMPTY) || (StateField == CS_STATE_ENABLED) || (StateField == CS_STATE_DISABLED))
{
DuplicateFound = false;

Expand Down Expand Up @@ -360,8 +359,7 @@ CFE_Status_t CS_ValidateAppChecksumDefinitionTable(void *TblPtr)
else if (OS_strnlen(OuterEntry->Name, CFE_TBL_MAX_FULL_NAME_LEN) != 0)
{
/* Verify valid state definition */
if (((StateField == CS_STATE_EMPTY) || (StateField == CS_STATE_ENABLED) ||
(StateField == CS_STATE_DISABLED)))
if ((StateField == CS_STATE_EMPTY) || (StateField == CS_STATE_ENABLED) || (StateField == CS_STATE_DISABLED))
{
DuplicateFound = false;

Expand Down Expand Up @@ -436,7 +434,7 @@ CFE_Status_t CS_ValidateAppChecksumDefinitionTable(void *TblPtr)
}
}

} /* for (OuterLoop = 0; OuterLoop < CS_MAX_NUM_APPS_TABLE_ENTRIES; OuterLoop++) */
} /* for (OuterLoop = 0; OuterLoop < CS_MAX_NUM_APP_TABLE_ENTRIES; OuterLoop++) */

CFE_EVS_SendEvent(CS_VAL_APP_INF_EID, CFE_EVS_EventType_INFORMATION,
"CS Apps Table verification results: good = %d, bad = %d, unused = %d", (int)GoodCount,
Expand All @@ -454,36 +452,31 @@ void CS_ProcessNewEepromMemoryDefinitionTable(const CS_Def_EepromMemory_Table_En
const CS_Res_EepromMemory_Table_Entry_t *ResultsTblPtr, uint16 NumEntries,
uint16 Table)
{
CS_Def_EepromMemory_Table_Entry_t *StartOfDefTable = NULL;
CS_Def_EepromMemory_Table_Entry_t *DefEntry = NULL;
CS_Res_EepromMemory_Table_Entry_t *StartOfResultsTable = NULL;
CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL;
uint16 Loop = 0;
uint16 NumRegionsInTable = 0;
uint16 PreviousState = CS_STATE_EMPTY;
const CS_Def_EepromMemory_Table_Entry_t *DefEntry = NULL;
const CS_Res_EepromMemory_Table_Entry_t *ResultsEntry = NULL;
uint16 Loop = 0;
uint16 NumRegionsInTable = 0;
uint16 PreviousState = CS_STATE_EMPTY;
char TableType[CS_TABLETYPE_NAME_SIZE];

memcpy(&StartOfResultsTable, ResultsTblPtr, sizeof(StartOfResultsTable));
memcpy(&StartOfDefTable, DefinitionTblPtr, sizeof(StartOfDefTable));

snprintf(&TableType[0], CS_TABLETYPE_NAME_SIZE, "%s", "Undef Tbl"); /* Init the table type string */
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "Undef Tbl"); /* Init the table type string */

/* We don't want to be doing chekcksums while changing the table out */
if (Table == CS_EEPROM_TABLE)
{
PreviousState = CS_AppData.HkPacket.Payload.EepromCSState;
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;
PreviousState = CS_AppData.HkPacket.Payload.MemoryCSState;
CS_AppData.HkPacket.Payload.MemoryCSState = CS_STATE_DISABLED;
}

for (Loop = 0; Loop < NumEntries; Loop++)
{
DefEntry = &(StartOfDefTable[Loop]);
ResultsEntry = &(StartOfResultsTable[Loop]);
DefEntry = &(DefinitionTblPtr[Loop]);
ResultsEntry = &(ResultsTblPtr[Loop]);

if (DefEntry->State != CS_STATE_EMPTY)
{
Expand Down Expand Up @@ -528,11 +521,11 @@ void CS_ProcessNewEepromMemoryDefinitionTable(const CS_Def_EepromMemory_Table_En
{
if (Table == CS_EEPROM_TABLE)
{
snprintf(&TableType[0], CS_TABLETYPE_NAME_SIZE, "%s", "EEPROM");
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "EEPROM");
}
if (Table == CS_MEMORY_TABLE)
else if (Table == CS_MEMORY_TABLE)
{
snprintf(&TableType[0], CS_TABLETYPE_NAME_SIZE, "%s", "Memory");
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "Memory");
}

CFE_EVS_SendEvent(CS_PROCESS_EEPROM_MEMORY_NO_ENTRIES_INF_EID, CFE_EVS_EventType_INFORMATION,
Expand All @@ -548,31 +541,26 @@ void CS_ProcessNewEepromMemoryDefinitionTable(const CS_Def_EepromMemory_Table_En
void CS_ProcessNewTablesDefinitionTable(const CS_Def_Tables_Table_Entry_t *DefinitionTblPtr,
const CS_Res_Tables_Table_Entry_t *ResultsTblPtr)
{
CS_Def_Tables_Table_Entry_t *StartOfDefTable = NULL;
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;
const CS_Def_Tables_Table_Entry_t *DefEntry = NULL;
const 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;
char AppName[OS_MAX_API_NAME];
char TableAppName[OS_MAX_API_NAME];
char TableTableName[CFE_MISSION_TBL_MAX_NAME_LENGTH];

memcpy(&StartOfResultsTable, ResultsTblPtr, sizeof(StartOfResultsTable));
memcpy(&StartOfDefTable, DefinitionTblPtr, sizeof(StartOfDefTable));

CFE_ES_GetAppID(&AppID);
CFE_ES_GetAppName(AppName, AppID, OS_MAX_API_NAME);

/* We don't want to be doing chekcksums while changing the table out */
PreviousState = CS_AppData.HkPacket.Payload.TablesCSState;
PreviousState = CS_AppData.HkPacket.Payload.TablesCSState;
CS_AppData.HkPacket.Payload.TablesCSState = CS_STATE_DISABLED;

/* Assume none of the CS tables are listed in the new Tables table */
Expand All @@ -583,9 +571,8 @@ void CS_ProcessNewTablesDefinitionTable(const CS_Def_Tables_Table_Entry_t *Defin

for (Loop = 0; Loop < CS_MAX_NUM_TABLES_TABLE_ENTRIES; Loop++)
{
DefEntry = &(StartOfDefTable[Loop]);

ResultsEntry = &(StartOfResultsTable[Loop]);
DefEntry = &(DefinitionTblPtr[Loop]);
ResultsEntry = &(ResultsTblPtr[Loop]);

if (DefEntry->State != CS_STATE_EMPTY)
{
Expand Down Expand Up @@ -640,54 +627,49 @@ void CS_ProcessNewTablesDefinitionTable(const CS_Def_Tables_Table_Entry_t *Defin
TableTableName[TableNameIndex] = '\0';

TableHandle = CFE_TBL_BAD_TABLE_HANDLE;
Owned = false;

Owned = false;

/* if the table's owner's name is CS */
if (strncmp(TableAppName, AppName, OS_MAX_API_NAME) == 0)
{
Owned = true;

if (strncmp(TableTableName, CS_DEF_EEPROM_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
{
TableHandle = CS_AppData.DefEepromTableHandle;
CS_AppData.EepResTablesTblPtr = ResultsEntry;
Owned = true;
}
if (strncmp(TableTableName, CS_DEF_MEMORY_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
else if (strncmp(TableTableName, CS_DEF_MEMORY_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
{
TableHandle = CS_AppData.DefMemoryTableHandle;
CS_AppData.MemResTablesTblPtr = ResultsEntry;
Owned = true;
}
if (strncmp(TableTableName, CS_DEF_TABLES_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
else if (strncmp(TableTableName, CS_DEF_TABLES_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
{
TableHandle = CS_AppData.DefTablesTableHandle;
CS_AppData.TblResTablesTblPtr = ResultsEntry;
Owned = true;
}
if (strncmp(TableTableName, CS_DEF_APP_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
else if (strncmp(TableTableName, CS_DEF_APP_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
{
TableHandle = CS_AppData.DefAppTableHandle;
CS_AppData.AppResTablesTblPtr = ResultsEntry;
Owned = true;
}
if (strncmp(TableTableName, CS_RESULTS_EEPROM_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
else if (strncmp(TableTableName, CS_RESULTS_EEPROM_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
{
TableHandle = CS_AppData.ResEepromTableHandle;
Owned = true;
}
if (strncmp(TableTableName, CS_RESULTS_MEMORY_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
else if (strncmp(TableTableName, CS_RESULTS_MEMORY_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
{
TableHandle = CS_AppData.ResMemoryTableHandle;
Owned = true;
}
if (strncmp(TableTableName, CS_RESULTS_TABLES_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
else if (strncmp(TableTableName, CS_RESULTS_TABLES_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
{
TableHandle = CS_AppData.ResTablesTableHandle;
Owned = true;
}
if (strncmp(TableTableName, CS_RESULTS_APP_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
else if (strncmp(TableTableName, CS_RESULTS_APP_TABLE_NAME, CFE_MISSION_TBL_MAX_NAME_LENGTH) == 0)
{
TableHandle = CS_AppData.ResAppTableHandle;
Owned = true;
}
}

Expand Down Expand Up @@ -741,27 +723,21 @@ void CS_ProcessNewTablesDefinitionTable(const CS_Def_Tables_Table_Entry_t *Defin
void CS_ProcessNewAppDefinitionTable(const CS_Def_App_Table_Entry_t *DefinitionTblPtr,
const CS_Res_App_Table_Entry_t *ResultsTblPtr)
{
CS_Def_App_Table_Entry_t *StartOfDefTable = NULL;
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;
const CS_Def_App_Table_Entry_t *DefEntry = NULL;
const CS_Res_App_Table_Entry_t *ResultsEntry = NULL;
uint16 Loop = 0;
uint16 NumRegionsInTable = 0;
uint16 PreviousState = CS_STATE_EMPTY;

memcpy(&StartOfResultsTable, ResultsTblPtr, sizeof(StartOfResultsTable));
memcpy(&StartOfDefTable, DefinitionTblPtr, sizeof(StartOfDefTable));
/* We don't want to be doing checksums while changing the table out */

/* We don't want to be doing chekcksums while changing the table out */

PreviousState = CS_AppData.HkPacket.Payload.AppCSState;
PreviousState = CS_AppData.HkPacket.Payload.AppCSState;
CS_AppData.HkPacket.Payload.AppCSState = CS_STATE_DISABLED;

for (Loop = 0; Loop < CS_MAX_NUM_APP_TABLE_ENTRIES; Loop++)
{
DefEntry = &(StartOfDefTable[Loop]);

ResultsEntry = &(StartOfResultsTable[Loop]);
DefEntry = &(DefinitionTblPtr[Loop]);
ResultsEntry = &(ResultsTblPtr[Loop]);

if (DefEntry->State != CS_STATE_EMPTY)
{
Expand Down Expand Up @@ -821,7 +797,6 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl
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];

Expand Down Expand Up @@ -849,11 +824,10 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl

if (OS_Status == OS_SUCCESS)
{
ValidFile = true;
OS_close(Fd);
}

if ((Result == CFE_SUCCESS) && (ValidFile == true))
if ((Result == CFE_SUCCESS) && (OS_Status == OS_SUCCESS))
{
Result = CFE_TBL_Load(*DefinitionTableHandle, CFE_TBL_SRC_FILE, DefinitionTableFileName);
ResultFromLoad = Result;
Expand All @@ -871,7 +845,7 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl
{
Result = CFE_TBL_GetAddress(DefinitionTblPtr, *DefinitionTableHandle);

if ((Result == CFE_TBL_INFO_UPDATED))
if (Result == CFE_TBL_INFO_UPDATED)
{
if (Table == CS_APP_TABLE)
{
Expand All @@ -893,7 +867,7 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl
}
}

} /* end if (Result == CFE_TBL_INFO_UPDATED) || (Result == CFE_SUCCESS) */
} /* end if (Result == CFE_TBL_INFO_UPDATED) */
}

if (Result >= CFE_SUCCESS)
Expand All @@ -904,19 +878,19 @@ CFE_Status_t CS_TableInit(CFE_TBL_Handle_t *DefinitionTableHandle, CFE_TBL_Handl
{
if (Table == CS_EEPROM_TABLE)
{
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "%s", "EEPROM");
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "EEPROM");
}
if (Table == CS_MEMORY_TABLE)
else if (Table == CS_MEMORY_TABLE)
{
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "%s", "Memory");
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "Memory");
}
if (Table == CS_TABLES_TABLE)
else if (Table == CS_TABLES_TABLE)
{
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "%s", "Tables");
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "Tables");
}
if (Table == CS_APP_TABLE)
else if (Table == CS_APP_TABLE)
{
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "%s", "Apps");
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "Apps");
}

CFE_EVS_SendEvent(CS_TBL_INIT_ERR_EID, CFE_EVS_EventType_ERROR,
Expand Down Expand Up @@ -988,7 +962,7 @@ CFE_Status_t CS_HandleTableUpdate(void *DefinitionTblPtr, void *ResultsTblPtr, C
Result = GetResult2;
}

if ((Result == CFE_TBL_INFO_UPDATED))
if (Result == CFE_TBL_INFO_UPDATED)
{
if (Table == CS_TABLES_TABLE)
{
Expand Down Expand Up @@ -1033,15 +1007,15 @@ CFE_Status_t CS_HandleTableUpdate(void *DefinitionTblPtr, void *ResultsTblPtr, C
{
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "%s", "EEPROM");
}
if (Table == CS_MEMORY_TABLE)
else if (Table == CS_MEMORY_TABLE)
{
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "%s", "Memory");
}
if (Table == CS_TABLES_TABLE)
else if (Table == CS_TABLES_TABLE)
{
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "%s", "Table");
}
if (Table == CS_APP_TABLE)
else if (Table == CS_APP_TABLE)
{
snprintf(TableType, CS_TABLETYPE_NAME_SIZE, "%s", "App");
}
Expand Down

0 comments on commit 973e150

Please sign in to comment.