diff --git a/README.md b/README.md index 87aa0a1a0..09962d7cf 100644 --- a/README.md +++ b/README.md @@ -8,33 +8,48 @@ This is a collection of services and associated framework to be located in the ` ## Version History +#### Development Build: 6.7.15 + +- Upon power on reset, default system log mode set to overwrite. Upon processor reset, default system log mode set to discard. +- No longer locks while locked (no issue observed on linux/posix, but user reported issue on FreeRTOS 10) +- Internal `CFE_TBL_LoadFromFile()` API changed slightly to add AppName as a parameter. Return value from `LoadFromFile()` no longer relevant for event generation. +- Updates `CFE_TBL_CleanUpApp` such that it now checks the 'used flag' prior to calling `CFE_TBL_RemoveAccessLink` for a given TblHandle. Also sets the AppId to `CFE_TBL_NOT_OWNED` after removing the access descriptor link from linked list. +- Removed `OS_FS_SUCCESS, OS_FS_ERROR , OS_FS_ERR_INVALID_POINTER, OS_FS_ERR_NO_FREE_FDS , OS_FS_ERR_INVALID_FD, and OS_FS_UNIMPLEMENTED` from `osapi-os-filesys.h` +- See https://github.com/nasa/cFE/pull/649 for more details + #### Development Build: 6.7.14 + - Exposes the `CFE_SB_IsValidMsgId()` for application usage. - `CFE_SB_GetLastSenderID` will now detect if it is being called prior to a message being sent on a given pipe. - Mismatches between PSP/BSP/OS are now detected and warned about during make prep. Only the `CFE_SYSTEM_PSPNAME` is actually required to be specified for a CFE build now. Others can be omitted. - See https://github.com/nasa/cFE/pull/635 for more details #### Development Build: 6.7.13 + - RTEMS builds without error. - Use the INTERFACE_COMPILE_DEFINITIONS and INTERFACE_INCLUDE_DIRECTORIES properties from the osal target and apply them to the entire CFE build as a directory-scope property. No impact until these are set in OSAL. - Minor other updates (see https://github.com/nasa/cFE/pull/615) #### Development Build: 6.7.12 + - Cmd code (and checksum) are always in the same place (matches GSFC spec for command secondary header) - No impact to behavior. Previously the perf log dump file frequently contained errors due to out of order or otherwise corrupted entries, which is now fixed. - Minor other updates (see https://github.com/nasa/cFE/pull/586) #### Development Build: 6.7.11 + - Improve documentation - Update makefile to report branch coverage - Minor other updates (see https://github.com/nasa/cFE/pull/566) #### Development Build: 6.7.10 + - Fix potential unit test problems with name collisions - Improve documentation - Minor other updates (see https://github.com/nasa/cFE/pull/563) #### Development Build: 6.7.9 + - No longer requires sed "hack" to change the setting in default_config.h - Minor other updates (see https://github.com/nasa/cFE/pull/544) @@ -45,41 +60,50 @@ This is a collection of services and associated framework to be located in the ` - Minor other updates (see https://github.com/nasa/cFE/pull/530) #### Development Build: 6.7.7 + - Adds a new function, CFE_SB_GetPipeIdByName, which retrieves the pipe ID given a name of a pipe. - Improvement in error reporting when using a pipe name that is already in use, or when the queue limit has been reached. - Added userguide and osalguide to the local target list to avoid makefile warning - Minor other updates (see https://github.com/nasa/cFE/pull/511) #### Development Build: 6.7.6 + - Adds OMIT_DEPRECATED prep flag - Adds and enforces strict warnings - Software Bus now increments sequence counter even if there are no subscribers - Warning, comment, and code coverage cleanup (see https://github.com/nasa/cFE/pull/490) #### Development Build: 6.7.5 + - Added CI static analysis check - Resolved static analysis warnings - Minor other updates (see https://github.com/nasa/cFE/pull/479) #### Development Build: 6.7.4 + - Minor updates (see https://github.com/nasa/cFE/pull/448) #### Development Build: 6.7.3 + - Minor updates (see https://github.com/nasa/cFE/pull/413) #### Development Build: 6.7.2 + - Minor bugs and enhancements (see https://github.com/nasa/cFE/pull/388) #### Development Build: 6.7.1 + - Fix strlen in CFE_ES_TaskInit https://github.com/nasa/cFE/pull/23 - Minor bug fixes (see https://github.com/nasa/cFE/pull/378) ### ***OFFICIAL RELEASE: 6.7.0*** + - This is a point release from an internal repository - Changes are detailed in [cFS repo](https://github.com/nasa/cFS) release documentation - Apache 2.0 ### ***OFFICIAL RELEASE: 6.6.0a*** + - This is a point release from an internal repository - Apache 2.0 - Additional release notes are found in [release notes](https://github.com/nasa/cFE/blob/v6.6.0a/docs/cFE_release_notes.md) diff --git a/cmake/sample_defs/cpu1_platform_cfg.h b/cmake/sample_defs/cpu1_platform_cfg.h index eb49f1f09..3e85be30c 100644 --- a/cmake/sample_defs/cpu1_platform_cfg.h +++ b/cmake/sample_defs/cpu1_platform_cfg.h @@ -1005,22 +1005,40 @@ #define CFE_PLATFORM_ES_DEFAULT_CDS_REG_DUMP_FILE "/ram/cfe_cds_reg.log" /** -** \cfeescfg Define Default System Log Mode +** \cfeescfg Define Default System Log Mode following Power On Reset ** ** \par Description: -** Defines the default mode for the operation of the ES System log. The log may -** operate in either Overwrite mode = 0, where once the log becomes full the -** oldest message in the log will be overwritten, or Discard mode = 1, where -** once the log becomes full the contents of the log are preserved and the new -** event is discarded. This constant may hold a value of either 0 or 1 -** depending on the desired default log mode. Overwrite Mode = 0, Discard -** Mode = 1. +** Defines the default mode for the operation of the ES System log following a power +** on reset. The log may operate in either Overwrite mode = 0, where once the +** log becomes full the oldest message in the log will be overwritten, or +** Discard mode = 1, where once the log becomes full the contents of the log are +** preserved and the new event is discarded. This constant may hold a value of +** either 0 or 1 depending on the desired default. +** Overwrite Mode = 0, Discard Mode = 1. +** +** \par Limits +** There is a lower limit of 0 and an upper limit of 1 on this configuration +** paramater. +*/ +#define CFE_PLATFORM_ES_DEFAULT_POR_SYSLOG_MODE 0 + +/** +** \cfeescfg Define Default System Log Mode following Processor Reset +** +** \par Description: +** Defines the default mode for the operation of the ES System log following a +** processor reset. The log may operate in either Overwrite mode = 0, where once +** the log becomes full the oldest message in the log will be overwritten, or +** Discard mode = 1, where once the log becomes full the contents of the log are +** preserved and the new event is discarded. This constant may hold a value of +** either 0 or 1 depending on the desired default. +** Overwrite Mode = 0, Discard Mode = 1. ** ** \par Limits ** There is a lower limit of 0 and an upper limit of 1 on this configuration ** paramater. */ -#define CFE_PLATFORM_ES_DEFAULT_SYSLOG_MODE 1 +#define CFE_PLATFORM_ES_DEFAULT_PR_SYSLOG_MODE 1 /** ** \cfeescfg Define Max Number of Performance IDs @@ -1997,7 +2015,7 @@ #define CFE_ES_DEFAULT_ER_LOG_FILE CFE_PLATFORM_ES_DEFAULT_ER_LOG_FILE #define CFE_ES_DEFAULT_PERF_DUMP_FILENAME CFE_PLATFORM_ES_DEFAULT_PERF_DUMP_FILENAME #define CFE_ES_DEFAULT_CDS_REG_DUMP_FILE CFE_PLATFORM_ES_DEFAULT_CDS_REG_DUMP_FILE -#define CFE_ES_DEFAULT_SYSLOG_MODE CFE_PLATFORM_ES_DEFAULT_SYSLOG_MODE +#define CFE_ES_DEFAULT_SYSLOG_MODE CFE_PLATFORM_ES_DEFAULT_PR_SYSLOG_MODE #define CFE_ES_PERF_MAX_IDS CFE_PLATFORM_ES_PERF_MAX_IDS #define CFE_ES_PERF_DATA_BUFFER_SIZE CFE_PLATFORM_ES_PERF_DATA_BUFFER_SIZE #define CFE_ES_PERF_FILTMASK_NONE CFE_PLATFORM_ES_PERF_FILTMASK_NONE diff --git a/fsw/cfe-core/src/es/cfe_es_apps.c b/fsw/cfe-core/src/es/cfe_es_apps.c index 0fe030b50..66fe5fe18 100644 --- a/fsw/cfe-core/src/es/cfe_es_apps.c +++ b/fsw/cfe-core/src/es/cfe_es_apps.c @@ -155,7 +155,7 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath ) while(1) { ReadStatus = OS_read(AppFile, &c, 1); - if ( ReadStatus == OS_FS_ERROR ) + if ( ReadStatus == OS_ERROR ) { CFE_ES_WriteToSysLog ("ES Startup: Error Reading Startup file. EC = 0x%08X\n",(unsigned int)ReadStatus); break; diff --git a/fsw/cfe-core/src/es/cfe_es_shell.c b/fsw/cfe-core/src/es/cfe_es_shell.c index 72a0ea1bc..adbe17e35 100644 --- a/fsw/cfe-core/src/es/cfe_es_shell.c +++ b/fsw/cfe-core/src/es/cfe_es_shell.c @@ -69,9 +69,9 @@ int32 CFE_ES_ShellOutputCommand(const char * CmdString, const char *Filename) fd = OS_creat(Filename, OS_READ_WRITE); - if (fd < OS_FS_SUCCESS) + if (fd < OS_SUCCESS) { - Result = OS_FS_ERROR; + Result = OS_ERROR; } else @@ -113,11 +113,11 @@ int32 CFE_ES_ShellOutputCommand(const char * CmdString, const char *Filename) /* seek to the end of the file to get it's size */ FileSize = OS_lseek(fd,0,OS_SEEK_END); - if (FileSize == OS_FS_ERROR) + if (FileSize == OS_ERROR) { OS_close(fd); CFE_ES_WriteToSysLog("OS_lseek call failed from CFE_ES_ShellOutputCmd 1\n"); - Result = OS_FS_ERROR; + Result = OS_ERROR; } @@ -153,11 +153,11 @@ int32 CFE_ES_ShellOutputCommand(const char * CmdString, const char *Filename) /* seek to the end of the file again to get it's new size */ FileSize = OS_lseek(fd,0,OS_SEEK_END); - if (FileSize == OS_FS_ERROR) + if (FileSize == OS_ERROR) { OS_close(fd); CFE_ES_WriteToSysLog("OS_lseek call failed from CFE_ES_ShellOutputCmd 2\n"); - Result = OS_FS_ERROR; + Result = OS_ERROR; } @@ -210,9 +210,9 @@ int32 CFE_ES_ShellOutputCommand(const char * CmdString, const char *Filename) /* Close the file descriptor */ OS_close(fd); - } /* if FilseSize == OS_FS_ERROR */ - } /* if FileSeize == OS_FS_ERROR */ - }/* if fd < OS_FS_SUCCESS */ + } /* if FilseSize == OS_ERROR */ + } /* if FileSeize == OS_ERROR */ + }/* if fd < OS_SUCCESS */ /* cppcheck-suppress duplicateExpression */ diff --git a/fsw/cfe-core/src/es/cfe_es_start.c b/fsw/cfe-core/src/es/cfe_es_start.c index 73411dbf6..e1ccc24a9 100644 --- a/fsw/cfe-core/src/es/cfe_es_start.c +++ b/fsw/cfe-core/src/es/cfe_es_start.c @@ -540,7 +540,7 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) if ( StartType == CFE_PSP_RST_TYPE_POWERON ) { RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS ); - if ( RetStatus != OS_FS_SUCCESS ) + if ( RetStatus != OS_SUCCESS ) { CFE_ES_WriteToSysLog("ES Startup: Error Creating Volatile(RAM) Volume. EC = 0x%08X\n",(unsigned int)RetStatus); @@ -558,7 +558,7 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) else { RetStatus = OS_initfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS ); - if ( RetStatus != OS_FS_SUCCESS ) + if ( RetStatus != OS_SUCCESS ) { CFE_ES_WriteToSysLog("ES Startup: Error Initializing Volatile(RAM) Volume. EC = 0x%08X\n",(unsigned int)RetStatus); CFE_ES_WriteToSysLog("ES Startup: Formatting Volatile(RAM) Volume.\n"); @@ -586,7 +586,7 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) ** Now, mount the RAM disk */ RetStatus = OS_mount("/ramdev0", CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); - if ( RetStatus != OS_FS_SUCCESS ) + if ( RetStatus != OS_SUCCESS ) { CFE_ES_WriteToSysLog("ES Startup: Error Mounting Volatile(RAM) Volume. EC = 0x%08X\n",(unsigned int)RetStatus); /* @@ -642,14 +642,14 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) ** First, unmount the disk */ RetStatus = OS_unmount(CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); - if ( RetStatus == OS_FS_SUCCESS ) + if ( RetStatus == OS_SUCCESS ) { /* ** Remove the file system from the OSAL */ RetStatus = OS_rmfs("/ramdev0"); - if ( RetStatus == OS_FS_SUCCESS ) + if ( RetStatus == OS_SUCCESS ) { /* @@ -658,13 +658,13 @@ void CFE_ES_InitializeFileSystems(uint32 StartType) RetStatus = OS_mkfs((void *)RamDiskMemoryAddress, "/ramdev0", "RAM", CFE_PLATFORM_ES_RAM_DISK_SECTOR_SIZE, CFE_PLATFORM_ES_RAM_DISK_NUM_SECTORS ); - if ( RetStatus == OS_FS_SUCCESS ) + if ( RetStatus == OS_SUCCESS ) { /* ** Last, remount the disk */ RetStatus = OS_mount("/ramdev0", CFE_PLATFORM_ES_RAM_DISK_MOUNT_STRING); - if ( RetStatus != OS_FS_SUCCESS ) + if ( RetStatus != OS_SUCCESS ) { CFE_ES_WriteToSysLog("ES Startup: Error Re-Mounting Volatile(RAM) Volume. EC = 0x%08X\n",(unsigned int)RetStatus); /* @@ -869,7 +869,7 @@ void CFE_ES_CreateObjects(void) */ if ( CFE_ES_Global.TaskTable[TaskIndex].RecordUsed == true ) { - CFE_ES_WriteToSysLog("ES Startup: CFE_ES_Global.TaskTable record used error for App: %s, continuing.\n", + CFE_ES_SysLogWrite_Unsync("ES Startup: CFE_ES_Global.TaskTable record used error for App: %s, continuing.\n", CFE_ES_ObjectTable[i].ObjectName); } else @@ -881,7 +881,7 @@ void CFE_ES_CreateObjects(void) strncpy((char *)CFE_ES_Global.TaskTable[TaskIndex].TaskName, (char *)CFE_ES_Global.AppTable[j].TaskInfo.MainTaskName, OS_MAX_API_NAME); CFE_ES_Global.TaskTable[TaskIndex].TaskName[OS_MAX_API_NAME - 1] = '\0'; - CFE_ES_WriteToSysLog("ES Startup: Core App: %s created. App ID: %d\n", + CFE_ES_SysLogWrite_Unsync("ES Startup: Core App: %s created. App ID: %d\n", CFE_ES_ObjectTable[i].ObjectName,j); /* diff --git a/fsw/cfe-core/src/es/cfe_es_task.c b/fsw/cfe-core/src/es/cfe_es_task.c index 215aa52a7..2f750536e 100644 --- a/fsw/cfe-core/src/es/cfe_es_task.c +++ b/fsw/cfe-core/src/es/cfe_es_task.c @@ -227,9 +227,16 @@ int32 CFE_ES_TaskInit(void) CFE_ES_TaskData.LimitCmd = 4; /* - ** Initialize systemlog to default mode + ** Initialize systemlog to default Power On or Processor Reset mode */ - CFE_ES_ResetDataPtr->SystemLogMode = CFE_PLATFORM_ES_DEFAULT_SYSLOG_MODE; + if (CFE_ES_GetResetType(NULL) == CFE_PSP_RST_TYPE_POWERON) + { + CFE_ES_ResetDataPtr->SystemLogMode = CFE_PLATFORM_ES_DEFAULT_POR_SYSLOG_MODE; + } + else + { + CFE_ES_ResetDataPtr->SystemLogMode = CFE_PLATFORM_ES_DEFAULT_PR_SYSLOG_MODE; + } /* ** Register event filter table. @@ -1887,7 +1894,7 @@ int32 CFE_ES_DumpCDSRegistryCmd(const CFE_ES_DumpCDSRegistry_t *data) /* Create a new dump file, overwriting anything that may have existed previously */ FileDescriptor = OS_creat(DumpFilename, OS_WRITE_ONLY); - if (FileDescriptor >= OS_FS_SUCCESS) + if (FileDescriptor >= OS_SUCCESS) { /* Initialize the standard cFE File Header for the Dump File */ CFE_FS_InitHeader(&StdFileHeader, "CDS_Registry", CFE_FS_SubType_ES_CDS_REG); diff --git a/fsw/cfe-core/src/evs/cfe_evs_log.c b/fsw/cfe-core/src/evs/cfe_evs_log.c index ae90d0d7d..20751edc7 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_log.c +++ b/fsw/cfe-core/src/evs/cfe_evs_log.c @@ -174,7 +174,7 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFile_t *data) /* Create the log file */ LogFileHandle = OS_creat(LogFilename, OS_WRITE_ONLY); - if (LogFileHandle < OS_FS_SUCCESS) + if (LogFileHandle < OS_SUCCESS) { EVS_SendEvent(CFE_EVS_ERR_CRLOGFILE_EID, CFE_EVS_EventType_ERROR, "Write Log File Command Error: OS_creat = 0x%08X, filename = %s", diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.c b/fsw/cfe-core/src/evs/cfe_evs_task.c index 22ad6a2d0..fb0721a18 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.c +++ b/fsw/cfe-core/src/evs/cfe_evs_task.c @@ -1753,7 +1753,7 @@ int32 CFE_EVS_WriteAppDataFileCmd(const CFE_EVS_WriteAppDataFile_t *data) /* Create Application Data File */ FileHandle = OS_creat(LocalName, OS_WRITE_ONLY); - if (FileHandle < OS_FS_SUCCESS) + if (FileHandle < OS_SUCCESS) { EVS_SendEvent(CFE_EVS_ERR_CRDATFILE_EID, CFE_EVS_EventType_ERROR, "Write App Data Command Error: OS_creat = 0x%08X, filename = %s", diff --git a/fsw/cfe-core/src/fs/cfe_fs_api.c b/fsw/cfe-core/src/fs/cfe_fs_api.c index 1c991ffeb..56f792350 100644 --- a/fsw/cfe-core/src/fs/cfe_fs_api.c +++ b/fsw/cfe-core/src/fs/cfe_fs_api.c @@ -191,7 +191,7 @@ int32 CFE_FS_SetTimestamp(int32 FileDes, CFE_TIME_SysTime_t NewTimestamp) if (Result == sizeof(OutTimestamp.Subseconds)) { - Result = OS_FS_SUCCESS; + Result = OS_SUCCESS; } else { diff --git a/fsw/cfe-core/src/inc/cfe_error.h b/fsw/cfe-core/src/inc/cfe_error.h index 77443ae0e..0e93b4a34 100644 --- a/fsw/cfe-core/src/inc/cfe_error.h +++ b/fsw/cfe-core/src/inc/cfe_error.h @@ -807,12 +807,12 @@ #define CFE_OS_ERR_NAME_NOT_FOUND (OS_ERR_NAME_NOT_FOUND) /**< @brief DEPRECATED @deprecated */ #define CFE_OS_ERR_SEM_NOT_FULL (OS_ERR_SEM_NOT_FULL) /**< @brief DEPRECATED @deprecated */ #define CFE_OS_ERR_INVALID_PRIORITY (OS_ERR_INVALID_PRIORITY) /**< @brief DEPRECATED @deprecated */ -#define CFE_OS_FS_ERROR (OS_FS_ERROR) /**< @brief DEPRECATED @deprecated */ -#define CFE_OS_FS_ERR_INVALID_POINTER (OS_FS_ERR_INVALID_POINTER) /**< @brief DEPRECATED @deprecated */ +#define CFE_OS_FS_ERROR (OS_ERROR) /**< @brief DEPRECATED @deprecated */ +#define CFE_OS_FS_ERR_INVALID_POINTER (OS_INVALID_POINTER) /**< @brief DEPRECATED @deprecated */ #define CFE_OS_FS_ERR_PATH_TOO_LONG (OS_FS_ERR_PATH_TOO_LONG) /**< @brief DEPRECATED @deprecated */ #define CFE_OS_FS_ERR_NAME_TOO_LONG (OS_FS_ERR_NAME_TOO_LONG) /**< @brief DEPRECATED @deprecated */ #define CFE_OS_FS_ERR_DRIVE_NOT_CREATED (OS_FS_ERR_DRIVE_NOT_CREATED) /**< @brief DEPRECATED @deprecated */ -#define CFE_OSAPI_NOT_IMPLEMENTED (OS_FS_UNIMPLEMENTED) /**< @brief DEPRECATED @deprecated */ +#define CFE_OSAPI_NOT_IMPLEMENTED (OS_ERR_NOT_IMPLEMENTED) /**< @brief DEPRECATED @deprecated */ #endif /* CFE_OMIT_DEPRECATED_6_7 */ @@ -1420,6 +1420,18 @@ */ #define CFE_TBL_MESSAGE_ERROR ((int32)0xcc00002a) +/** +** Error code indicating that the TBL file is shorter than +** indicated in the file header. +*/ +#define CFE_TBL_ERR_SHORT_FILE ((int32)0xcc00002b) + +/** +** Error code indicating that the TBL file could not be +** opened by the OS. +*/ +#define CFE_TBL_ERR_ACCESS ((int32)0xcc00002c) + /** * @brief Not Implemented diff --git a/fsw/cfe-core/src/inc/cfe_tbl_events.h b/fsw/cfe-core/src/inc/cfe_tbl_events.h index 5b1ea91c4..4f4a5f8d6 100644 --- a/fsw/cfe-core/src/inc/cfe_tbl_events.h +++ b/fsw/cfe-core/src/inc/cfe_tbl_events.h @@ -46,7 +46,7 @@ ** and when you're done adding, set this to the highest EID you used. It may ** be worthwhile to, on occasion, re-number the EID's to put them back in order. */ -#define CFE_TBL_MAX_EID 98 +#define CFE_TBL_MAX_EID 105 /******************* Macro Definitions ***********************/ /* @@ -940,19 +940,8 @@ **/ #define CFE_TBL_UNREGISTER_ERR_EID 92 -/** \brief '\%s Failed to Load '\%s' from \%s, Status=0x\%08X" -** \event '\%s Failed to Load '\%s' from \%s, Status=0x\%08X" -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated when an Application calls #CFE_TBL_Load unsuccessfully. -** -** The \c Status field of the Event Message can be used to identify the reason for the failure -** by looking it up in the cfe_error.h file -**/ -#define CFE_TBL_LOAD_ERR_EID 93 +/* TODO: document see https://github.com/nasa/cFE/issues/661 */ +#define CFE_TBL_LOAD_VAL_ERR_EID 93 /** \brief '\%s Failed to Load '\%s' (Invalid Source Type)" ** \event '\%s Failed to Load '\%s' (Invalid Source Type)" @@ -981,8 +970,8 @@ **/ #define CFE_TBL_UPDATE_ERR_EID 95 -/** \brief '\%s validation failed for Inactive '\%s', Status=0x\%08X" -** \event '\%s validation failed for Inactive '\%s', Status=0x\%08X" +/** \brief '\%s validation failed for Inactive '\%s', Status=0x\%08X' +** \event '\%s validation failed for Inactive '\%s', Status=0x\%08X' ** ** \par Type: ERROR ** @@ -1052,6 +1041,44 @@ **/ #define CFE_TBL_PROCESSOR_ID_ERR_EID 98 +/** \brief Attempted to load Dump Only Tbl '%s' +** \event Attempted to load Dump Only Tbl '%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an application attempts to load a dump-only table. +**/ +#define CFE_TBL_LOAD_DUMPONLY_ERR_EID 99 + +/** \brief Load already in progress for '%s' +** \event Load already in progress for '%s' +** +** \par Type: ERROR +** +** \par Cause: +** +** This event message is generated when an application attempts to load a table already +** in progress. Likely due to a race condition. +**/ +#define CFE_TBL_LOAD_IN_PROGRESS_ERR_EID 100 + +/* TODO: document see https://github.com/nasa/cFE/issues/661 */ +#define CFE_TBL_LOAD_SRC_TYPE_ERR_EID 101 + +/* TODO: document see https://github.com/nasa/cFE/issues/661 */ +#define CFE_TBL_LOAD_FILENAME_LONG_ERR_EID 102 + +/* TODO: document see https://github.com/nasa/cFE/issues/661 */ +#define CFE_TBL_LOAD_SHORT_FILE_ERR_EID 103 + +/* TODO: document see https://github.com/nasa/cFE/issues/661 */ +#define CFE_TBL_LOAD_TBLNAME_MISMATCH_ERR_EID 104 + +/* TODO: document see https://github.com/nasa/cFE/issues/661 */ +#define CFE_TBL_HANDLE_ACCESS_ERR_EID 105 + /** \} */ diff --git a/fsw/cfe-core/src/inc/cfe_version.h b/fsw/cfe-core/src/inc/cfe_version.h index a505c7129..d4aed9d13 100644 --- a/fsw/cfe-core/src/inc/cfe_version.h +++ b/fsw/cfe-core/src/inc/cfe_version.h @@ -95,7 +95,7 @@ */ #define CFE_MAJOR_VERSION 6 #define CFE_MINOR_VERSION 7 -#define CFE_REVISION 14 +#define CFE_REVISION 15 #endif /* _cfe_version_ */ diff --git a/fsw/cfe-core/src/sb/cfe_sb_task.c b/fsw/cfe-core/src/sb/cfe_sb_task.c index 88e4cece2..9bb69d014 100644 --- a/fsw/cfe-core/src/sb/cfe_sb_task.c +++ b/fsw/cfe-core/src/sb/cfe_sb_task.c @@ -854,7 +854,7 @@ int32 CFE_SB_SendRtgInfo(const char *Filename) CFE_SB_DestinationD_t *DestPtr; fd = OS_creat(Filename, OS_WRITE_ONLY); - if(fd < OS_FS_SUCCESS){ + if(fd < OS_SUCCESS){ CFE_EVS_SendEvent(CFE_SB_SND_RTG_ERR1_EID,CFE_EVS_EventType_ERROR, "Error creating file %s, stat=0x%x", Filename,(unsigned int)fd); @@ -964,7 +964,7 @@ int32 CFE_SB_SendPipeInfo(const char *Filename) fd = OS_creat(Filename, OS_WRITE_ONLY); - if(fd < OS_FS_SUCCESS){ + if(fd < OS_SUCCESS){ CFE_EVS_SendEvent(CFE_SB_SND_RTG_ERR1_EID,CFE_EVS_EventType_ERROR, "Error creating file %s, stat=0x%x", Filename,(unsigned int)fd); @@ -1039,7 +1039,7 @@ int32 CFE_SB_SendMapInfo(const char *Filename) fd = OS_creat(Filename, OS_WRITE_ONLY); - if (fd < OS_FS_SUCCESS){ + if (fd < OS_SUCCESS){ CFE_EVS_SendEvent(CFE_SB_SND_RTG_ERR1_EID,CFE_EVS_EventType_ERROR, "Error creating file %s, stat=0x%x", Filename,(unsigned int)fd); diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_api.c b/fsw/cfe-core/src/tbl/cfe_tbl_api.c index 118d2011b..29709871e 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_api.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_api.c @@ -678,261 +678,220 @@ int32 CFE_TBL_Load( CFE_TBL_Handle_t TblHandle, int32 Status; uint32 ThisAppId; CFE_TBL_LoadBuff_t *WorkingBufferPtr; - CFE_TBL_RegistryRec_t *RegRecPtr = NULL; - CFE_TBL_AccessDescriptor_t *AccessDescPtr; + CFE_TBL_AccessDescriptor_t *AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; + CFE_TBL_RegistryRec_t *RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; char AppName[OS_MAX_API_NAME]={"UNKNOWN"}; - uint16 EventMsgType = CFE_EVS_EventType_INFORMATION; bool FirstTime = false; + /* Verify access rights and get a valid Application ID for calling App */ + Status = CFE_TBL_ValidateAccess(TblHandle, &ThisAppId); + + /* Translate AppID of caller into App Name */ + CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); /* Initialize return pointer to NULL */ WorkingBufferPtr = NULL; - /* Verify access rights and get a valid Application ID for calling App */ - Status = CFE_TBL_ValidateAccess(TblHandle, &ThisAppId); - - if (Status == CFE_SUCCESS) + if (Status != CFE_SUCCESS) { - /* Get pointers to pertinent records in registry and handles */ - AccessDescPtr = &CFE_TBL_TaskData.Handles[TblHandle]; - RegRecPtr = &CFE_TBL_TaskData.Registry[AccessDescPtr->RegIndex]; + CFE_EVS_SendEventWithAppID(CFE_TBL_HANDLE_ACCESS_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_TBL_TaskData.TableTaskAppId, + "%s: No access to Tbl Handle=%d", AppName, (int)TblHandle); - /* Check to see if this is a dump only table */ - if (RegRecPtr->DumpOnly) - { - if ((RegRecPtr->UserDefAddr) && (!RegRecPtr->TableLoadedOnce)) - { - /* The Application is allowed to call Load once when the address */ - /* of the dump only table is being defined by the application. */ - RegRecPtr->Buffers[0].BufferPtr = (void *)SrcDataPtr; - RegRecPtr->TableLoadedOnce = true; - - snprintf(RegRecPtr->Buffers[0].DataSource, sizeof(RegRecPtr->Buffers[0].DataSource), - "Addr 0x%08lX", (unsigned long)SrcDataPtr); - RegRecPtr->Buffers[0].FileCreateTimeSecs = 0; - RegRecPtr->Buffers[0].FileCreateTimeSubSecs = 0; + return Status; + } - CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_SUCCESS_INF_EID, - CFE_EVS_EventType_DEBUG, - CFE_TBL_TaskData.TableTaskAppId, - "Successfully loaded '%s' from '%s'", - RegRecPtr->Name, - RegRecPtr->Buffers[0].DataSource); - } - else - { - Status = CFE_TBL_ERR_DUMP_ONLY; + /* Check to see if this is a dump only table */ + if (RegRecPtr->DumpOnly) + { + if ((!RegRecPtr->UserDefAddr) ||(RegRecPtr->TableLoadedOnce)) + { + CFE_EVS_SendEventWithAppID(CFE_TBL_LOADING_A_DUMP_ONLY_ERR_EID, + CFE_EVS_EventType_ERROR, CFE_TBL_TaskData.TableTaskAppId, + "%s: Attempted to load Dump Only Tbl '%s'", AppName, RegRecPtr->Name); - CFE_ES_WriteToSysLog("CFE_TBL:Load-App(%d) attempted to load Dump Only Tbl '%s'\n", - (int)ThisAppId, RegRecPtr->Name); - } + return CFE_TBL_ERR_DUMP_ONLY; } - else - { - /* Loads by an Application are not allowed if a table load is already in progress */ - if (RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS) - { - Status = CFE_TBL_ERR_LOAD_IN_PROGRESS; - CFE_ES_WriteToSysLog("CFE_TBL:Load-Tbl Load already in progress for '%s'\n", RegRecPtr->Name); - } - else - { - /* Obtain a working buffer (either the table's dedicated buffer or one of the shared buffers) */ - Status = CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, true); + /* The Application is allowed to call Load once when the address */ + /* of the dump only table is being defined by the application. */ + RegRecPtr->Buffers[0].BufferPtr = (void *)SrcDataPtr; + RegRecPtr->TableLoadedOnce = true; + + snprintf(RegRecPtr->Buffers[0].DataSource, sizeof(RegRecPtr->Buffers[0].DataSource), + "Addr 0x%08lX", (unsigned long)SrcDataPtr); + RegRecPtr->Buffers[0].FileCreateTimeSecs = 0; + RegRecPtr->Buffers[0].FileCreateTimeSubSecs = 0; - if (Status == CFE_SUCCESS) - { - /* Perform appropriate update to working buffer */ - /* Determine whether the load is to occur from a file or from a block of memory */ - if (SrcType == CFE_TBL_SRC_FILE) - { - /* Load the data from the file into the specified buffer */ - Status = CFE_TBL_LoadFromFile(WorkingBufferPtr, RegRecPtr, (const char *)SrcDataPtr); + CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_SUCCESS_INF_EID, + CFE_EVS_EventType_DEBUG, + CFE_TBL_TaskData.TableTaskAppId, + "Successfully loaded '%s' from '%s'", + RegRecPtr->Name, + RegRecPtr->Buffers[0].DataSource); - if (Status < 0) - { - CFE_ES_WriteToSysLog("CFE_TBL:Load-App(%d) Fail to load Tbl '%s' from '%s' (Stat=0x%08X)\n", - (int)ThisAppId, RegRecPtr->Name, (const char *)SrcDataPtr, (unsigned int)Status); - } - else if ((Status == CFE_TBL_WARN_PARTIAL_LOAD) && (!RegRecPtr->TableLoadedOnce)) - { - /* Uninitialized tables cannot be loaded with partial table loads */ - /* Partial loads can only occur on previously loaded tables. */ - Status = CFE_TBL_ERR_PARTIAL_LOAD; - } - } - else if (SrcType == CFE_TBL_SRC_ADDRESS) - { - /* When the source is a block of memory, it is assumed to be a complete load */ - memcpy(WorkingBufferPtr->BufferPtr, - (uint8 *)SrcDataPtr, - RegRecPtr->Size); - - snprintf(WorkingBufferPtr->DataSource, sizeof(WorkingBufferPtr->DataSource), "Addr 0x%08lX", (unsigned long)SrcDataPtr); - WorkingBufferPtr->FileCreateTimeSecs = 0; - WorkingBufferPtr->FileCreateTimeSubSecs = 0; - - /* Compute the CRC on the specified table buffer */ - WorkingBufferPtr->Crc = CFE_ES_CalculateCRC(WorkingBufferPtr->BufferPtr, - RegRecPtr->Size, - 0, - CFE_MISSION_ES_DEFAULT_CRC); - } - else - { - Status = CFE_TBL_ERR_ILLEGAL_SRC_TYPE; - CFE_ES_WriteToSysLog("CFE_TBL:Load-App(%d) attempt to load from illegal source type=%d\n", - (int)ThisAppId, (int)SrcType); - } + return CFE_SUCCESS; + } - /* If the data was successfully loaded, then validate its contents */ - if ((Status >= CFE_SUCCESS) && (RegRecPtr->ValidationFuncPtr != NULL)) - { - Status = (RegRecPtr->ValidationFuncPtr)(WorkingBufferPtr->BufferPtr); + /* Loads by an Application are not allowed if a table load is already in progress */ + if (RegRecPtr->LoadInProgress != CFE_TBL_NO_LOAD_IN_PROGRESS) + { + CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_IN_PROGRESS_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_TBL_TaskData.TableTaskAppId, + "%s: Load already in progress for '%s'", AppName, RegRecPtr->Name); - if (Status > CFE_SUCCESS) - { - CFE_ES_WriteToSysLog("CFE_TBL:Load-App(%d) Validation func return code invalid (Stat=0x%08X) for '%s'\n", - (int)ThisAppId, (unsigned int)Status, RegRecPtr->Name); - Status = -1; - } - - if (Status < 0) - { - CFE_ES_WriteToSysLog("CFE_TBL:Load-App(%d) reports load invalid (Stat=0x%08X) for '%s'\n", - (int)ThisAppId, (unsigned int)Status, RegRecPtr->Name); - - /* Zero out the buffer to remove any bad data */ - memset(WorkingBufferPtr->BufferPtr, 0, RegRecPtr->Size); - } - } + return CFE_TBL_ERR_LOAD_IN_PROGRESS; + } - /* Perform the table update to complete the load */ - if (Status >= CFE_SUCCESS) - { - FirstTime = !RegRecPtr->TableLoadedOnce; - - /* If this is not the first load, then the data must be moved from the inactive buffer */ - /* to the active buffer to complete the load. First loads are done directly to the active. */ - if (!FirstTime) - { - /* Force the table update */ - RegRecPtr->LoadPending = true; + /* Obtain a working buffer (either the table's dedicated buffer or one of the shared buffers) */ + Status = CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, true); - Status = CFE_TBL_UpdateInternal(TblHandle, RegRecPtr, AccessDescPtr); - } - else - { - /* On initial loads, make sure registry is given file/address of data source */ - strncpy(RegRecPtr->LastFileLoaded, - WorkingBufferPtr->DataSource, - OS_MAX_PATH_LEN); + if (Status != CFE_SUCCESS) + { + CFE_EVS_SendEventWithAppID(CFE_TBL_NO_WORK_BUFFERS_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_TBL_TaskData.TableTaskAppId, + "%s: Failed to get Working Buffer (Stat=%u)", AppName, (unsigned int)Status); - CFE_TBL_NotifyTblUsersOfUpdate(RegRecPtr); - - /* If the table is a critical table, update the appropriate CDS with the new data */ - if (RegRecPtr->CriticalTable == true) - { - CFE_TBL_UpdateCriticalTblCDS(RegRecPtr); - } + return Status; + } - Status = CFE_SUCCESS; - } + /* Perform appropriate update to working buffer */ + /* Determine whether the load is to occur from a file or from a block of memory */ + switch(SrcType) + { + case CFE_TBL_SRC_FILE: + /* Load the data from the file into the specified buffer */ + Status = CFE_TBL_LoadFromFile(AppName, WorkingBufferPtr, RegRecPtr, (const char *)SrcDataPtr); - if (Status != CFE_SUCCESS) - { - CFE_ES_WriteToSysLog("CFE_TBL:Load-App(%d) fail to update '%s' (Stat=0x%08X)\n", - (int)ThisAppId, RegRecPtr->Name, (unsigned int)Status); - } - else - { - /* The first time a table is loaded, the event message is DEBUG */ - /* to help eliminate a flood of events during a startup */ - if (FirstTime) - { - EventMsgType = CFE_EVS_EventType_DEBUG; - } + if ((Status == CFE_TBL_WARN_PARTIAL_LOAD) && (!RegRecPtr->TableLoadedOnce)) + { + /* Uninitialized tables cannot be loaded with partial table loads */ + /* Partial loads can only occur on previously loaded tables. */ + CFE_EVS_SendEventWithAppID(CFE_TBL_PARTIAL_LOAD_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_TBL_TaskData.TableTaskAppId, + "%s: Attempted to load from partial Tbl '%s' from '%s' (Stat=%u)", + AppName, RegRecPtr->Name, (const char *)SrcDataPtr, (unsigned int)Status); + + Status = CFE_TBL_ERR_PARTIAL_LOAD; + } - CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_SUCCESS_INF_EID, - EventMsgType, - CFE_TBL_TaskData.TableTaskAppId, - "Successfully loaded '%s' from '%s'", - RegRecPtr->Name, - RegRecPtr->LastFileLoaded); - - /* Save the index of the table for housekeeping telemetry */ - CFE_TBL_TaskData.LastTblUpdated = AccessDescPtr->RegIndex; - } - } - else - { - /* The load has had a problem, free the working buffer for another attempt */ - if ((!RegRecPtr->DoubleBuffered) && (RegRecPtr->TableLoadedOnce == true)) - { - /* For single buffered tables, freeing entails resetting flag */ - CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].Taken = false; - } + break; + case CFE_TBL_SRC_ADDRESS: + /* When the source is a block of memory, it is assumed to be a complete load */ + memcpy(WorkingBufferPtr->BufferPtr, + (uint8 *)SrcDataPtr, + RegRecPtr->Size); - /* For double buffered tables, freeing buffer is simple */ - RegRecPtr->LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; - } - } - else - { - CFE_ES_WriteToSysLog("CFE_TBL:Load-App(%d) Failed to get Working Buffer (Stat=0x%08X)\n", - (int)ThisAppId, (unsigned int)Status); - } - } + snprintf(WorkingBufferPtr->DataSource, sizeof(WorkingBufferPtr->DataSource), "Addr 0x%08lX", (unsigned long)SrcDataPtr); + WorkingBufferPtr->FileCreateTimeSecs = 0; + WorkingBufferPtr->FileCreateTimeSubSecs = 0; + + /* Compute the CRC on the specified table buffer */ + WorkingBufferPtr->Crc = CFE_ES_CalculateCRC(WorkingBufferPtr->BufferPtr, + RegRecPtr->Size, + 0, + CFE_MISSION_ES_DEFAULT_CRC); + + break; + default: + CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_TYPE_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_TBL_TaskData.TableTaskAppId, + "%s: Attempted to load from illegal source type=%d", AppName, (int)SrcType); + + Status = CFE_TBL_ERR_ILLEGAL_SRC_TYPE; + } + + /* If the data was successfully loaded, then validate its contents */ + if ((Status >= CFE_SUCCESS) && (RegRecPtr->ValidationFuncPtr != NULL)) + { + Status = (RegRecPtr->ValidationFuncPtr)(WorkingBufferPtr->BufferPtr); + + if (Status > CFE_SUCCESS) + { + CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_VAL_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_TBL_TaskData.TableTaskAppId, + "%s: Validation func return code invalid (Stat=%u) for '%s'", + AppName, (unsigned int)Status, RegRecPtr->Name); + + Status = -1; + } + + if (Status < 0) + { + CFE_EVS_SendEventWithAppID(CFE_TBL_VALIDATION_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_TBL_TaskData.TableTaskAppId, + "%s: Validation func reports table invalid (Stat=%u) for '%s'", + AppName, (unsigned int)Status, RegRecPtr->Name); + + /* Zero out the buffer to remove any bad data */ + memset(WorkingBufferPtr->BufferPtr, 0, RegRecPtr->Size); } } - else + + /* Perform the table update to complete the load */ + if (Status < CFE_SUCCESS) { - CFE_ES_WriteToSysLog("CFE_TBL:Load-App(%d) does not have access to Tbl Handle=%d\n", - (int)ThisAppId, (int)TblHandle); + /* The load has had a problem, free the working buffer for another attempt */ + if ((!RegRecPtr->DoubleBuffered) && (RegRecPtr->TableLoadedOnce == true)) + { + /* For single buffered tables, freeing entails resetting flag */ + CFE_TBL_TaskData.LoadBuffs[RegRecPtr->LoadInProgress].Taken = false; + } + + /* For double buffered tables, freeing buffer is simple */ + RegRecPtr->LoadInProgress = CFE_TBL_NO_LOAD_IN_PROGRESS; + + return Status; } - /* On Error conditions, notify ground of screw up */ - if (Status < 0) + FirstTime = !RegRecPtr->TableLoadedOnce; + + /* If this is not the first load, then the data must be moved from the inactive buffer */ + /* to the active buffer to complete the load. First loads are done directly to the active. */ + if (!FirstTime) { - /* Translate AppID of caller into App Name */ - CFE_ES_GetAppName(AppName, ThisAppId, OS_MAX_API_NAME); + /* Force the table update */ + RegRecPtr->LoadPending = true; - if (RegRecPtr == NULL) + Status = CFE_TBL_UpdateInternal(TblHandle, RegRecPtr, AccessDescPtr); + + if (Status != CFE_SUCCESS) { - CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_ERR_EID, - CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, - "%s Failed to Load '?', Status=0x%08X", - AppName, (unsigned int)Status); + CFE_EVS_SendEventWithAppID(CFE_TBL_UPDATE_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_TBL_TaskData.TableTaskAppId, + "%s: Failed to update '%s' (Stat=%u)", + AppName, RegRecPtr->Name, (unsigned int)Status); } - else + } + else + { + /* On initial loads, make sure registry is given file/address of data source */ + strncpy(RegRecPtr->LastFileLoaded, + WorkingBufferPtr->DataSource, + OS_MAX_PATH_LEN); + + CFE_TBL_NotifyTblUsersOfUpdate(RegRecPtr); + + /* If the table is a critical table, update the appropriate CDS with the new data */ + if (RegRecPtr->CriticalTable == true) { - if (SrcType == CFE_TBL_SRC_ADDRESS) - { - CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_ERR_EID, - CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, - "%s Failed to Load '%s' from Addr 0x%08lX, Status=0x%08X", - AppName, RegRecPtr->Name, (unsigned long)SrcDataPtr, (unsigned int)Status); - } - else if (SrcType == CFE_TBL_SRC_FILE) - { - CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_ERR_EID, - CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, - "%s Failed to Load '%s' from '%s', Status=0x%08X", - AppName, RegRecPtr->Name, (const char *)SrcDataPtr, (unsigned int)Status); - } - else - { - CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_TYPE_ERR_EID, - CFE_EVS_EventType_ERROR, - CFE_TBL_TaskData.TableTaskAppId, - "%s Failed to Load '%s' (Invalid Source Type)", - AppName, RegRecPtr->Name); - } + CFE_TBL_UpdateCriticalTblCDS(RegRecPtr); } + + Status = CFE_SUCCESS; + } + + if (Status == CFE_SUCCESS) + { + /* The first time a table is loaded, the event message is DEBUG */ + /* to help eliminate a flood of events during a startup */ + CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_SUCCESS_INF_EID, + FirstTime ? CFE_EVS_EventType_DEBUG : CFE_EVS_EventType_INFORMATION, + CFE_TBL_TaskData.TableTaskAppId, "Successfully loaded '%s' from '%s'", + RegRecPtr->Name, RegRecPtr->LastFileLoaded); + + /* Save the index of the table for housekeeping telemetry */ + CFE_TBL_TaskData.LastTblUpdated = AccessDescPtr->RegIndex; } return Status; diff --git a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c index 5a4cf0b9d..e7a00a065 100644 --- a/fsw/cfe-core/src/tbl/cfe_tbl_internal.c +++ b/fsw/cfe-core/src/tbl/cfe_tbl_internal.c @@ -125,7 +125,6 @@ int32 CFE_TBL_EarlyInit (void) CFE_TBL_MUT_REG_VALUE); if(Status != OS_SUCCESS) { - CFE_ES_WriteToSysLog("CFE_TBL:Registry mutex creation failed! RC=0x%08x\n",(unsigned int)Status); return Status; }/* end if */ @@ -137,7 +136,6 @@ int32 CFE_TBL_EarlyInit (void) CFE_TBL_MUT_WORK_VALUE); if(Status != OS_SUCCESS) { - CFE_ES_WriteToSysLog("CFE_TBL:Working buffer mutex creation failed! RC=0x%08x\n",(unsigned int)Status); return Status; }/* end if */ @@ -162,7 +160,6 @@ int32 CFE_TBL_EarlyInit (void) if(Status < 0) { - CFE_ES_WriteToSysLog("CFE_TBL:InitBuffers PoolCreate fail Status=0x%X\n", (unsigned int)Status); return Status; } else @@ -178,7 +175,6 @@ int32 CFE_TBL_EarlyInit (void) if (Status < CFE_PLATFORM_TBL_MAX_SNGL_TABLE_SIZE) { - CFE_ES_WriteToSysLog("CFE_TBL:InitBuffers GetPoolBuf Fail Index=%d, Status=0x%X\n", (int)j, (unsigned int)Status); return Status; } else @@ -317,26 +313,20 @@ void CFE_TBL_InitRegistryRecord (CFE_TBL_RegistryRec_t *RegRecPtr) int32 CFE_TBL_ValidateHandle(CFE_TBL_Handle_t TblHandle) { - int32 Status = CFE_SUCCESS; - /* Is the handle out of range? */ if (TblHandle >= CFE_PLATFORM_TBL_MAX_NUM_HANDLES) { - Status = CFE_TBL_ERR_INVALID_HANDLE; - - CFE_ES_WriteToSysLog("CFE_TBL:ValidateHandle-Table Handle=%d is > %d\n", TblHandle, CFE_PLATFORM_TBL_MAX_NUM_HANDLES); + return CFE_TBL_ERR_INVALID_HANDLE; } else { /* Check to see if the Handle is no longer valid for this Table */ if (CFE_TBL_TaskData.Handles[TblHandle].UsedFlag == false) { - Status = CFE_TBL_ERR_INVALID_HANDLE; - - CFE_ES_WriteToSysLog("CFE_TBL:ValidateHandle-Table Handle=%d is for unused Table Handle\n", TblHandle); + return CFE_TBL_ERR_INVALID_HANDLE; } } - return Status; + return CFE_SUCCESS; } /* End of CFE_TBL_ValidateHandle() */ /******************************************************************* @@ -354,16 +344,9 @@ int32 CFE_TBL_ValidateAppID(uint32 *AppIdPtr) { if (*AppIdPtr >= CFE_PLATFORM_ES_MAX_APPLICATIONS) { - Status = CFE_TBL_ERR_BAD_APP_ID; - - CFE_ES_WriteToSysLog("CFE_TBL:ValidateAppID-AppId=%d > Max Apps (%d)\n", - (int)(*AppIdPtr), CFE_PLATFORM_ES_MAX_APPLICATIONS); + return CFE_TBL_ERR_BAD_APP_ID; } } - else - { - CFE_ES_WriteToSysLog("CFE_TBL:ValidateAppID-GetAppID failed (Stat=0x%08X)\n", (unsigned int)Status); - } return Status; } /* End of CFE_TBL_ValidateAppID() */ @@ -382,31 +365,21 @@ int32 CFE_TBL_ValidateAccess(CFE_TBL_Handle_t TblHandle, uint32 *AppIdPtr) /* Check to make sure App ID is legit */ Status = CFE_TBL_ValidateAppID(AppIdPtr); - if (Status == CFE_SUCCESS) + if (Status != CFE_SUCCESS) { - /* Check table handle validity */ - Status = CFE_TBL_ValidateHandle(TblHandle); + return Status; + } - if (Status == CFE_SUCCESS) - { - Status = CFE_TBL_CheckAccessRights(TblHandle, *AppIdPtr); + /* Check table handle validity */ + Status = CFE_TBL_ValidateHandle(TblHandle); - if (Status != CFE_SUCCESS) - { - CFE_ES_WriteToSysLog("CFE_TBL:ValidateAccess-App(%d) no access to Tbl Handle=%d (Stat=0x%08X)\n", - (int)(*AppIdPtr), (int)TblHandle, (unsigned int)Status); - } - } - else - { - CFE_ES_WriteToSysLog("CFE_TBL:ValidateAccess-Invalid Tbl Handle=%d\n", (int)TblHandle); - } - } - else + if (Status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("CFE_TBL:ValidateAccess-Bad AppId=%d\n", (int)(*AppIdPtr)); + return Status; } + Status = CFE_TBL_CheckAccessRights(TblHandle, *AppIdPtr); + return Status; } /* End of CFE_TBL_ValidateAccess() */ @@ -937,7 +910,7 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, ** NOTE: For complete prolog information, see 'cfe_tbl_internal.h' ********************************************************************/ -int32 CFE_TBL_LoadFromFile(CFE_TBL_LoadBuff_t *WorkingBufferPtr, +int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBufferPtr, CFE_TBL_RegistryRec_t *RegRecPtr, const char *Filename) { @@ -951,87 +924,121 @@ int32 CFE_TBL_LoadFromFile(CFE_TBL_LoadBuff_t *WorkingBufferPtr, if (FilenameLen > (OS_MAX_PATH_LEN-1)) { - Status = CFE_TBL_ERR_FILENAME_TOO_LONG; + CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_FILENAME_LONG_ERR_EID, + CFE_EVS_EventType_ERROR, CFE_TBL_TaskData.TableTaskAppId, + "%s: Filename is too long ('%s' (%lu) > %lu)", + AppName, Filename, (long unsigned int)FilenameLen, + (long unsigned int)OS_MAX_PATH_LEN-1); + + return CFE_TBL_ERR_FILENAME_TOO_LONG; } - else + + /* Try to open the specified table file */ + FileDescriptor = OS_open(Filename, OS_READ_ONLY, 0); + + if (FileDescriptor < 0) { - /* Try to open the specified table file */ - FileDescriptor = OS_open(Filename, OS_READ_ONLY, 0); + CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_ACCESS_ERR_EID, + CFE_EVS_EventType_ERROR, CFE_TBL_TaskData.TableTaskAppId, + "%s: Unable to open file (FileDescriptor=%d)", + AppName, (int)FileDescriptor); - if (FileDescriptor >= 0) - { - Status = CFE_TBL_ReadHeaders(FileDescriptor, &StdFileHeader, &TblFileHeader, Filename); + return CFE_TBL_ERR_ACCESS; + } - if (Status == CFE_SUCCESS) - { - /* Verify that the specified file has compatible data for specified table */ - if (strcmp(RegRecPtr->Name, TblFileHeader.TableName) == 0) - { - if ((TblFileHeader.Offset + TblFileHeader.NumBytes) > RegRecPtr->Size) - { - Status = CFE_TBL_ERR_FILE_TOO_LARGE; - } - else - { - /* Any Table load that starts beyond the first byte is a "partial load" */ - /* But a file that starts with the first byte and ends before filling */ - /* the whole table is just considered "short". */ - if (TblFileHeader.Offset > 0) - { - Status = CFE_TBL_WARN_PARTIAL_LOAD; - } - else if (TblFileHeader.NumBytes < RegRecPtr->Size) - { - Status = CFE_TBL_WARN_SHORT_FILE; - } + Status = CFE_TBL_ReadHeaders(FileDescriptor, &StdFileHeader, &TblFileHeader, Filename); - NumBytes = OS_read(FileDescriptor, - ((uint8*)WorkingBufferPtr->BufferPtr) + TblFileHeader.Offset, - TblFileHeader.NumBytes); + if (Status != CFE_SUCCESS) + { + /* CFE_TBL_ReadHeaders() generates its own events */ - if (NumBytes != TblFileHeader.NumBytes) - { - Status = CFE_TBL_ERR_LOAD_INCOMPLETE; - } - - /* Check to see if the file is too large (ie - more data than header claims) */ - NumBytes = OS_read(FileDescriptor, &ExtraByte, 1); - - /* If successfully read another byte, then file must have too much data */ - if (NumBytes == 1) - { - Status = CFE_TBL_ERR_FILE_TOO_LARGE; - } + OS_close (FileDescriptor); + return Status; + } - memset(WorkingBufferPtr->DataSource, 0, OS_MAX_PATH_LEN); - strncpy(WorkingBufferPtr->DataSource, Filename, OS_MAX_PATH_LEN); - - /* Save file creation time for later storage into Registry */ - WorkingBufferPtr->FileCreateTimeSecs = StdFileHeader.TimeSeconds; - WorkingBufferPtr->FileCreateTimeSubSecs = StdFileHeader.TimeSubSeconds; - - /* Compute the CRC on the specified table buffer */ - WorkingBufferPtr->Crc = CFE_ES_CalculateCRC(WorkingBufferPtr->BufferPtr, - RegRecPtr->Size, - 0, - CFE_MISSION_ES_DEFAULT_CRC); - } - } - else - { - Status = CFE_TBL_ERR_FILE_FOR_WRONG_TABLE; - } - } + /* Verify that the specified file has compatible data for specified table */ + if (strcmp(RegRecPtr->Name, TblFileHeader.TableName) != 0) + { + CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_TBLNAME_MISMATCH_ERR_EID, + CFE_EVS_EventType_ERROR, CFE_TBL_TaskData.TableTaskAppId, + "%s: Table name mismatch (exp=%s, tblfilhdr=%s)", + AppName, RegRecPtr->Name, TblFileHeader.TableName); - OS_close(FileDescriptor); - } - else - { - /* Return error code obtained from OS_open */ - Status = FileDescriptor; - } + OS_close(FileDescriptor); + return CFE_TBL_ERR_FILE_FOR_WRONG_TABLE; } + if ((TblFileHeader.Offset + TblFileHeader.NumBytes) > RegRecPtr->Size) + { + CFE_EVS_SendEventWithAppID(CFE_TBL_LOAD_EXCEEDS_SIZE_ERR_EID, + CFE_EVS_EventType_ERROR, CFE_TBL_TaskData.TableTaskAppId, + "%s: File reports size larger than expected (file=%lu, exp=%lu)", + AppName, + (long unsigned int)(TblFileHeader.Offset + TblFileHeader.NumBytes), + (long unsigned int)RegRecPtr->Size); + + OS_close(FileDescriptor); + return CFE_TBL_ERR_FILE_TOO_LARGE; + } + + /* Any Table load that starts beyond the first byte is a "partial load" */ + /* But a file that starts with the first byte and ends before filling */ + /* the whole table is just considered "short". */ + if (TblFileHeader.Offset > 0) + { + Status = CFE_TBL_WARN_PARTIAL_LOAD; + } + else if (TblFileHeader.NumBytes < RegRecPtr->Size) + { + Status = CFE_TBL_WARN_SHORT_FILE; + } + + NumBytes = OS_read(FileDescriptor, + ((uint8*)WorkingBufferPtr->BufferPtr) + TblFileHeader.Offset, + TblFileHeader.NumBytes); + + if (NumBytes != TblFileHeader.NumBytes) + { + CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_INCOMPLETE_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_TBL_TaskData.TableTaskAppId, + "%s: File load incomplete (exp=%lu, read=%lu)", + AppName, (long unsigned int)TblFileHeader.NumBytes, + (long unsigned int)NumBytes); + + OS_close(FileDescriptor); + return CFE_TBL_ERR_LOAD_INCOMPLETE; + } + + /* Check to see if the file is too large (ie - more data than header claims) */ + NumBytes = OS_read(FileDescriptor, &ExtraByte, 1); + + /* If successfully read another byte, then file must have too much data */ + if (NumBytes == 1) + { + CFE_EVS_SendEventWithAppID(CFE_TBL_FILE_TOO_BIG_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_TBL_TaskData.TableTaskAppId, + "%s: File load too long (file length > %lu)", + AppName, (long unsigned int)TblFileHeader.NumBytes); + + OS_close(FileDescriptor); + return CFE_TBL_ERR_FILE_TOO_LARGE; + } + + memset(WorkingBufferPtr->DataSource, 0, OS_MAX_PATH_LEN); + strncpy(WorkingBufferPtr->DataSource, Filename, OS_MAX_PATH_LEN); + + /* Save file creation time for later storage into Registry */ + WorkingBufferPtr->FileCreateTimeSecs = StdFileHeader.TimeSeconds; + WorkingBufferPtr->FileCreateTimeSubSecs = StdFileHeader.TimeSubSeconds; + + /* Compute the CRC on the specified table buffer */ + WorkingBufferPtr->Crc = CFE_ES_CalculateCRC(WorkingBufferPtr->BufferPtr, + RegRecPtr->Size, + 0, + CFE_MISSION_ES_DEFAULT_CRC); + + OS_close(FileDescriptor); + return Status; } /* End of CFE_TBL_LoadFromFile() */ @@ -1391,7 +1398,7 @@ int32 CFE_TBL_CleanUpApp(uint32 AppId) for (i=0; iDumpBufferPtr->DataSource); @@ -757,7 +757,7 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile( const char *DumpFilename, const char *T /* Create a new dump file, overwriting anything that may have existed previously */ FileDescriptor = OS_creat(DumpFilename, OS_WRITE_ONLY); - if (FileDescriptor >= OS_FS_SUCCESS) + if (FileDescriptor >= OS_SUCCESS) { /* Initialize the standard cFE File Header for the Dump File */ CFE_FS_InitHeader(&StdFileHeader, "Table Dump Image", CFE_FS_SubType_TBL_IMG); @@ -1147,7 +1147,7 @@ int32 CFE_TBL_DumpRegistryCmd(const CFE_TBL_DumpRegistry_t *data) /* Create a new dump file, overwriting anything that may have existed previously */ FileDescriptor = OS_creat(DumpFilename, OS_WRITE_ONLY); - if (FileDescriptor >= OS_FS_SUCCESS) + if (FileDescriptor >= OS_SUCCESS) { /* Initialize the standard cFE File Header for the Dump File */ CFE_FS_InitHeader(&StdFileHeader, "Table Registry", CFE_FS_SubType_TBL_REG); diff --git a/fsw/cfe-core/unit-test/es_UT.c b/fsw/cfe-core/unit-test/es_UT.c index 1963ded0d..e0a7a7ab3 100644 --- a/fsw/cfe-core/unit-test/es_UT.c +++ b/fsw/cfe-core/unit-test/es_UT.c @@ -2528,15 +2528,27 @@ void TestTask(void) "CFE_ES_TaskInit", "Checksum fail"); - /* Test successful task main process loop */ + /* Test successful task main process loop - Power On Reset Path */ ES_ResetUnitTest(); CFE_ES_Global.TaskTable[1].RecordUsed = true; /* this is needed so CFE_ES_GetAppId works */ CFE_ES_Global.TaskTable[1].AppId = 1; + CFE_ES_ResetDataPtr->ResetVars.ResetType = 2; UT_Report(__FILE__, __LINE__, CFE_ES_TaskInit() == CFE_SUCCESS && CFE_ES_TaskData.HkPacket.Payload.CFECoreChecksum != 0xFFFF, "CFE_ES_TaskInit", - "Checksum success"); + "Checksum success, POR Path"); + + /* Test successful task main process loop - Processor Reset Path */ + ES_ResetUnitTest(); + CFE_ES_Global.TaskTable[1].RecordUsed = true; /* this is needed so CFE_ES_GetAppId works */ + CFE_ES_Global.TaskTable[1].AppId = 1; + CFE_ES_ResetDataPtr->ResetVars.ResetType = 1; + UT_Report(__FILE__, __LINE__, + CFE_ES_TaskInit() == CFE_SUCCESS && + CFE_ES_TaskData.HkPacket.Payload.CFECoreChecksum != 0xFFFF, + "CFE_ES_TaskInit", + "Checksum success, PR Path"); /* Test task main process loop with a register app failure */ ES_ResetUnitTest(); @@ -3056,7 +3068,7 @@ void TestTask(void) /* Test write of all app data to file with a write header failure */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, OS_FS_ERROR); + UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, OS_ERROR); UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CFE_ES_QueryAll_t), UT_TPID_CFE_ES_CMD_QUERY_ALL_CC); UT_Report(__FILE__, __LINE__, @@ -3233,7 +3245,7 @@ void TestTask(void) /* Test writing the system log with a write header failure */ ES_ResetUnitTest(); - UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, OS_FS_ERROR); + UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, OS_ERROR); UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CFE_ES_WriteSyslog_t), UT_TPID_CFE_ES_CMD_WRITE_SYSLOG_CC); UT_Report(__FILE__, __LINE__, @@ -3292,7 +3304,7 @@ void TestTask(void) /* Test writing the E&R log with a write header failure */ ES_ResetUnitTest(); memset(&CmdBuf, 0, sizeof(CmdBuf)); - UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, OS_FS_ERROR); + UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, OS_ERROR); UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CFE_ES_WriteERLog_t), UT_TPID_CFE_ES_CMD_WRITE_ER_LOG_CC); UT_Report(__FILE__, __LINE__, diff --git a/fsw/cfe-core/unit-test/fs_UT.c b/fsw/cfe-core/unit-test/fs_UT.c index e24754f52..3993bed71 100644 --- a/fsw/cfe-core/unit-test/fs_UT.c +++ b/fsw/cfe-core/unit-test/fs_UT.c @@ -112,7 +112,7 @@ void Test_CFE_FS_ReadHeader(void) /* Test successfully reading the header */ UT_InitData(); - UT_SetDeferredRetcode(UT_KEY(OS_lseek), 1, OS_FS_SUCCESS); + UT_SetDeferredRetcode(UT_KEY(OS_lseek), 1, OS_SUCCESS); UT_SetForceFail(UT_KEY(OS_read), OS_ERROR); UT_Report(__FILE__, __LINE__, CFE_FS_ReadHeader(&Hdr, FileDes) != sizeof(CFE_FS_Header_t), @@ -142,10 +142,10 @@ void Test_CFE_FS_WriteHeader(void) /* Test successfully writing the header */ UT_InitData(); - UT_SetDeferredRetcode(UT_KEY(OS_lseek), 1, OS_FS_SUCCESS); - UT_SetDeferredRetcode(UT_KEY(OS_write), 1, OS_FS_SUCCESS); + UT_SetDeferredRetcode(UT_KEY(OS_lseek), 1, OS_SUCCESS); + UT_SetDeferredRetcode(UT_KEY(OS_write), 1, OS_SUCCESS); UT_Report(__FILE__, __LINE__, - CFE_FS_WriteHeader(FileDes, &Hdr) == OS_FS_SUCCESS, + CFE_FS_WriteHeader(FileDes, &Hdr) == OS_SUCCESS, "CFE_FS_WriteHeader", "Header write - successful"); } @@ -166,7 +166,7 @@ void Test_CFE_FS_SetTimestamp(void) UT_InitData(); UT_SetForceFail(UT_KEY(OS_lseek), OS_ERROR); UT_Report(__FILE__, __LINE__, - CFE_FS_SetTimestamp(FileDes, NewTimestamp) == OS_FS_ERROR, + CFE_FS_SetTimestamp(FileDes, NewTimestamp) == OS_ERROR, "CFE_FS_SetTimestamp", "Failed to lseek time fields"); @@ -189,7 +189,7 @@ void Test_CFE_FS_SetTimestamp(void) /* Test successfully setting the time stamp */ UT_InitData(); UT_Report(__FILE__, __LINE__, - CFE_FS_SetTimestamp(FileDes, NewTimestamp) == OS_FS_SUCCESS, + CFE_FS_SetTimestamp(FileDes, NewTimestamp) == OS_SUCCESS, "CFE_FS_SetTimestamp", "Write time stamp - successful"); } @@ -506,7 +506,7 @@ void Test_CFE_FS_Decompress(void) /* Test filling the input buffer with a FS error */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(OS_read), 1, 4); - UT_SetDeferredRetcode(UT_KEY(OS_read), 1, OS_FS_ERROR); + UT_SetDeferredRetcode(UT_KEY(OS_read), 1, OS_ERROR); UT_Report(__FILE__, __LINE__, FS_gz_fill_inbuf_Reentrant(&UT_FS_Decompress_State) == EOF, "FS_gz_fill_inbuf", diff --git a/fsw/cfe-core/unit-test/tbl_UT.c b/fsw/cfe-core/unit-test/tbl_UT.c index c972db553..4164d8bd4 100644 --- a/fsw/cfe-core/unit-test/tbl_UT.c +++ b/fsw/cfe-core/unit-test/tbl_UT.c @@ -1761,7 +1761,7 @@ void Test_CFE_TBL_HousekeepingCmd(void) /* Test response to a file time stamp failure */ UT_InitData(); CFE_TBL_TaskData.DumpControlBlocks[0].State = CFE_TBL_DUMP_PERFORMED; - UT_SetDeferredRetcode(UT_KEY(CFE_FS_SetTimestamp), 1, OS_FS_SUCCESS - 1); + UT_SetDeferredRetcode(UT_KEY(CFE_FS_SetTimestamp), 1, OS_SUCCESS - 1); UT_Report(__FILE__, __LINE__, CFE_TBL_HousekeepingCmd(NULL) == CFE_TBL_DONT_INC_CTR, "CFE_TBL_HousekeepingCmd", @@ -2804,7 +2804,7 @@ void Test_CFE_TBL_Load(void) RtnCode = CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_FILE, "TblSrcFileName.dat"); - EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_ERR_EID) == true && + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_PARTIAL_LOAD_ERR_EID) == true && UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_PARTIAL_LOAD && EventsCorrect, @@ -2825,7 +2825,7 @@ void Test_CFE_TBL_Load(void) RtnCode = CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_FILE, "TblSrcFileName.dat"); - EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_ERR_EID) == false && + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_PARTIAL_LOAD_ERR_EID) == false && UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_SUCCESS && EventsCorrect, @@ -2857,7 +2857,7 @@ void Test_CFE_TBL_Load(void) RtnCode = CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_FILE, "TblSrcFileName.dat"); - EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_ERR_EID) == true && + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_TBLNAME_MISMATCH_ERR_EID) == true && UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_FILE_FOR_WRONG_TABLE && EventsCorrect, @@ -2909,7 +2909,7 @@ void Test_CFE_TBL_Load(void) RtnCode = CFE_TBL_Load(App1TblHandle2, CFE_TBL_SRC_FILE, "TblSrcFileName.dat"); - EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_ERR_EID) == true && + EventsCorrect = (UT_EventIsInHistory(CFE_SUCCESS) == true && UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_FILE_FOR_WRONG_TABLE && EventsCorrect, @@ -2948,7 +2948,7 @@ void Test_CFE_TBL_Load(void) UT_InitData(); UT_SetDeferredRetcode(UT_KEY(Test_CFE_TBL_ValidationFunc), 1, -1); RtnCode = CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_ADDRESS, &TestTable1); - EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_ERR_EID) == true && + EventsCorrect = (UT_EventIsInHistory(CFE_SUCCESS) == true && UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == -1 && EventsCorrect, @@ -2961,8 +2961,8 @@ void Test_CFE_TBL_Load(void) UT_InitData(); UT_SetDeferredRetcode(UT_KEY(Test_CFE_TBL_ValidationFunc), 1, 1); RtnCode = CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_ADDRESS, &TestTable1); - EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_ERR_EID) == true && - UT_GetNumEventsSent() == 1); + EventsCorrect = (UT_EventIsInHistory(CFE_SUCCESS) == true && + UT_GetNumEventsSent() == 2); UT_Report(__FILE__, __LINE__, RtnCode == -1 && EventsCorrect, "CFE_TBL_Load", @@ -2973,7 +2973,7 @@ void Test_CFE_TBL_Load(void) RtnCode = CFE_TBL_Load(CFE_PLATFORM_TBL_MAX_NUM_HANDLES, CFE_TBL_SRC_ADDRESS, &TestTable1); - EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_ERR_EID) == true && + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_HANDLE_ACCESS_ERR_EID) == true && UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_INVALID_HANDLE && EventsCorrect, @@ -2998,7 +2998,7 @@ void Test_CFE_TBL_Load(void) RtnCode = CFE_TBL_Load(DumpOnlyTblHandle, CFE_TBL_SRC_ADDRESS, &TestTable1); - EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_ERR_EID) == true && + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOADING_A_DUMP_ONLY_ERR_EID) == true && UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_DUMP_ONLY && EventsCorrect, @@ -3014,7 +3014,7 @@ void Test_CFE_TBL_Load(void) RtnCode = CFE_TBL_Load(DumpOnlyTblHandle, CFE_TBL_SRC_ADDRESS, &TestTable1); - EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_ERR_EID) == true && + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOADING_A_DUMP_ONLY_ERR_EID) == true && UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_DUMP_ONLY && EventsCorrect, @@ -3068,7 +3068,7 @@ void Test_CFE_TBL_Load(void) UT_InitData(); UT_SetAppID(1); RtnCode = CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_ADDRESS, &TestTable1); - EventsCorrect = (UT_GetNumEventsSent() == 0); + EventsCorrect = (UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_INFO_TABLE_LOCKED && EventsCorrect, "CFE_TBL_Load", @@ -3356,7 +3356,7 @@ void Test_CFE_TBL_Manage(void) RtnCode = CFE_TBL_GetWorkingBuffer(&WorkingBufferPtr, RegRecPtr, false); UT_SetAppID(1); RtnCode = CFE_TBL_Load(App1TblHandle1, CFE_TBL_SRC_ADDRESS, &TestTable1); - EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_ERR_EID) == true && + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_IN_PROGRESS_ERR_EID) == true && UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_LOAD_IN_PROGRESS && EventsCorrect, @@ -4141,8 +4141,9 @@ void Test_CFE_TBL_Internal(void) } Filename[i] = '\0'; /* Null terminate file name string */ - RtnCode = CFE_TBL_LoadFromFile(WorkingBufferPtr, RegRecPtr, Filename); - EventsCorrect = (UT_GetNumEventsSent() == 0); + RtnCode = CFE_TBL_LoadFromFile("UT", WorkingBufferPtr, RegRecPtr, Filename); + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_FILENAME_LONG_ERR_EID) == true && + UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_FILENAME_TOO_LONG && EventsCorrect, "CFE_TBL_LoadFromFile", @@ -4171,8 +4172,9 @@ void Test_CFE_TBL_Internal(void) UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); - RtnCode = CFE_TBL_LoadFromFile(WorkingBufferPtr, RegRecPtr, Filename); - EventsCorrect = (UT_GetNumEventsSent() == 0); + RtnCode = CFE_TBL_LoadFromFile("UT", WorkingBufferPtr, RegRecPtr, Filename); + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_EXCEEDS_SIZE_ERR_EID) == true && + UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_FILE_TOO_LARGE && EventsCorrect, "CFE_TBL_LoadFromFile", @@ -4199,7 +4201,8 @@ void Test_CFE_TBL_Internal(void) UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); UT_SetDeferredRetcode(UT_KEY(OS_read), 2, sizeof(UT_Table1_t)); - RtnCode = CFE_TBL_LoadFromFile(WorkingBufferPtr, RegRecPtr, Filename); + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_FILE_TOO_BIG_ERR_EID) == true && + UT_GetNumEventsSent() == 1); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_FILE_TOO_LARGE && EventsCorrect, @@ -4228,8 +4231,9 @@ void Test_CFE_TBL_Internal(void) UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); UT_SetDeferredRetcode(UT_KEY(OS_read), 2, sizeof(UT_Table1_t) - 1); UT_SetDeferredRetcode(UT_KEY(OS_read), 1, 0); - RtnCode = CFE_TBL_LoadFromFile(WorkingBufferPtr, RegRecPtr, Filename); - EventsCorrect = (UT_GetNumEventsSent() == 0); + RtnCode = CFE_TBL_LoadFromFile("UT", WorkingBufferPtr, RegRecPtr, Filename); + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_FILE_INCOMPLETE_ERR_EID) == true && + UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_LOAD_INCOMPLETE && EventsCorrect, "CFE_TBL_LoadFromFile", @@ -4256,8 +4260,9 @@ void Test_CFE_TBL_Internal(void) UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); UT_SetDeferredRetcode(UT_KEY(OS_read), 3, 0); - RtnCode = CFE_TBL_LoadFromFile(WorkingBufferPtr, RegRecPtr, Filename); - EventsCorrect = (UT_GetNumEventsSent() == 0); + RtnCode = CFE_TBL_LoadFromFile("UT", WorkingBufferPtr, RegRecPtr, Filename); + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_TBLNAME_MISMATCH_ERR_EID) == true && + UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_FILE_FOR_WRONG_TABLE && EventsCorrect, "CFE_TBL_LoadFromFile", @@ -4282,10 +4287,11 @@ void Test_CFE_TBL_Internal(void) UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); UT_SetForceFail(UT_KEY(OS_open), OS_ERROR); - RtnCode = CFE_TBL_LoadFromFile(WorkingBufferPtr, RegRecPtr, Filename); - EventsCorrect = (UT_GetNumEventsSent() == 0); + RtnCode = CFE_TBL_LoadFromFile("UT", WorkingBufferPtr, RegRecPtr, Filename); + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_FILE_ACCESS_ERR_EID) == true && + UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, - RtnCode == OS_ERROR && EventsCorrect, + RtnCode == CFE_TBL_ERR_ACCESS && EventsCorrect, "CFE_TBL_LoadFromFile", "OS open error"); @@ -4308,7 +4314,7 @@ void Test_CFE_TBL_Internal(void) UT_SetReadBuffer(&TblFileHeader, sizeof(TblFileHeader)); UT_SetReadHeader(&StdFileHeader, sizeof(StdFileHeader)); UT_SetDeferredRetcode(UT_KEY(OS_read), 3, 0); - RtnCode = CFE_TBL_LoadFromFile(WorkingBufferPtr, RegRecPtr, Filename); + RtnCode = CFE_TBL_LoadFromFile("UT", WorkingBufferPtr, RegRecPtr, Filename); EventsCorrect = (UT_GetNumEventsSent() == 0); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_WARN_SHORT_FILE && EventsCorrect, @@ -4691,7 +4697,7 @@ void Test_CFE_TBL_Internal(void) RtnCode = CFE_TBL_Load(App1TblHandle2, CFE_TBL_SRC_FILE, "TblSrcFileName.dat"); EventsCorrect = - (UT_EventIsInHistory(CFE_TBL_LOAD_ERR_EID) == true && + (UT_EventIsInHistory(CFE_TBL_NO_WORK_BUFFERS_ERR_EID) == true && UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_NO_BUFFER_AVAIL && EventsCorrect, @@ -4917,7 +4923,7 @@ void Test_CFE_TBL_Internal(void) UT_SetDeferredRetcode(UT_KEY(CFE_ES_CopyToCDS), 2, CFE_ES_ERR_MEM_HANDLE); RtnCode = CFE_TBL_Load(App1TblHandle2, CFE_TBL_SRC_FILE, "TblSrcFileName.dat"); - EventsCorrect = (UT_EventIsInHistory(CFE_TBL_LOAD_ERR_EID) == true && + EventsCorrect = (UT_EventIsInHistory(CFE_TBL_HANDLE_ACCESS_ERR_EID) == true && UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_INVALID_HANDLE && EventsCorrect, @@ -4987,7 +4993,7 @@ void Test_CFE_TBL_Internal(void) /* Test CFE_TBL_LoadFromFile response to an invalid header length */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(CFE_FS_ReadHeader), 1, sizeof(CFE_FS_Header_t) - 1); - RtnCode = CFE_TBL_LoadFromFile(WorkingBufferPtr, RegRecPtr, Filename); + RtnCode = CFE_TBL_LoadFromFile("UT", WorkingBufferPtr, RegRecPtr, Filename); EventsCorrect = (UT_GetNumEventsSent() == 1); UT_Report(__FILE__, __LINE__, RtnCode == CFE_TBL_ERR_NO_STD_HEADER && EventsCorrect, diff --git a/fsw/cfe-core/ut-stubs/ut_fs_stubs.c b/fsw/cfe-core/ut-stubs/ut_fs_stubs.c index 6c7df8335..3b553fa42 100644 --- a/fsw/cfe-core/ut-stubs/ut_fs_stubs.c +++ b/fsw/cfe-core/ut-stubs/ut_fs_stubs.c @@ -146,13 +146,13 @@ int32 CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, int32 FileDes) ** being called. If the value FSSetTimestampRtn.count is greater than ** zero then the counter is decremented; if it then equals zero the ** return value is set to the user-defined value -** FSSetTimestampRtn.value. OS_FS_SUCCESS is returned otherwise. +** FSSetTimestampRtn.value. OS_SUCCESS is returned otherwise. ** ** \par Assumptions, External Events, and Notes: ** None ** ** \returns -** Returns either a user-defined status flag or OS_FS_SUCCESS. +** Returns either a user-defined status flag or OS_SUCCESS. ** ******************************************************************************/ int32 CFE_FS_SetTimestamp(int32 FileDes, CFE_TIME_SysTime_t NewTimestamp)