From 693cb5d4fd15849d1a392241a83150adeade2d94 Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Thu, 18 Feb 2021 15:26:36 -0500 Subject: [PATCH] Fix #1153, Remove logic based on LogEnabled status --- fsw/cfe-core/src/evs/cfe_evs_log.c | 224 ++++++++++++-------------- fsw/cfe-core/src/evs/cfe_evs_task.c | 125 +++++++------- fsw/cfe-core/src/inc/cfe_error.h | 9 -- fsw/cfe-core/src/inc/cfe_evs_events.h | 45 ------ fsw/cfe-core/unit-test/evs_UT.c | 47 ++---- 5 files changed, 184 insertions(+), 266 deletions(-) diff --git a/fsw/cfe-core/src/evs/cfe_evs_log.c b/fsw/cfe-core/src/evs/cfe_evs_log.c index e5ae293d7..b8d1cc6fe 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_log.c +++ b/fsw/cfe-core/src/evs/cfe_evs_log.c @@ -54,53 +54,50 @@ void EVS_AddLog (CFE_EVS_LongEventTlm_t *EVS_PktPtr) { - if (CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled == true) - { - /* Serialize access to event log control variables */ - OS_MutSemTake(CFE_EVS_Global.EVS_SharedDataMutexID); + /* Serialize access to event log control variables */ + OS_MutSemTake(CFE_EVS_Global.EVS_SharedDataMutexID); - if ((CFE_EVS_Global.EVS_LogPtr->LogFullFlag == true) && - (CFE_EVS_Global.EVS_LogPtr->LogMode == CFE_EVS_LogMode_DISCARD)) + if ((CFE_EVS_Global.EVS_LogPtr->LogFullFlag == true) && + (CFE_EVS_Global.EVS_LogPtr->LogMode == CFE_EVS_LogMode_DISCARD)) + { + /* If log is full and in discard mode, just count the event */ + CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter++; + } + else + { + if (CFE_EVS_Global.EVS_LogPtr->LogFullFlag == true) { - /* If log is full and in discard mode, just count the event */ + /* If log is full and in wrap mode, count it and store it */ CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter++; } - else - { - if (CFE_EVS_Global.EVS_LogPtr->LogFullFlag == true) - { - /* If log is full and in wrap mode, count it and store it */ - CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter++; - } - /* Copy the event data to the next available entry in the log */ - memcpy(&CFE_EVS_Global.EVS_LogPtr->LogEntry[CFE_EVS_Global.EVS_LogPtr->Next], - EVS_PktPtr, sizeof(*EVS_PktPtr)); + /* Copy the event data to the next available entry in the log */ + memcpy(&CFE_EVS_Global.EVS_LogPtr->LogEntry[CFE_EVS_Global.EVS_LogPtr->Next], + EVS_PktPtr, sizeof(*EVS_PktPtr)); - CFE_EVS_Global.EVS_LogPtr->Next++; + CFE_EVS_Global.EVS_LogPtr->Next++; - if (CFE_EVS_Global.EVS_LogPtr->Next >= CFE_PLATFORM_EVS_LOG_MAX) - { - /* This is important, even if we are in discard mode */ - CFE_EVS_Global.EVS_LogPtr->Next = 0; - } + if (CFE_EVS_Global.EVS_LogPtr->Next >= CFE_PLATFORM_EVS_LOG_MAX) + { + /* This is important, even if we are in discard mode */ + CFE_EVS_Global.EVS_LogPtr->Next = 0; + } - /* Log count cannot exceed the number of entries in the log */ - if (CFE_EVS_Global.EVS_LogPtr->LogCount < CFE_PLATFORM_EVS_LOG_MAX) - { - CFE_EVS_Global.EVS_LogPtr->LogCount++; + /* Log count cannot exceed the number of entries in the log */ + if (CFE_EVS_Global.EVS_LogPtr->LogCount < CFE_PLATFORM_EVS_LOG_MAX) + { + CFE_EVS_Global.EVS_LogPtr->LogCount++; - if (CFE_EVS_Global.EVS_LogPtr->LogCount == CFE_PLATFORM_EVS_LOG_MAX) - { - /* The full flag and log count are somewhat redundant */ - CFE_EVS_Global.EVS_LogPtr->LogFullFlag = true; - } + if (CFE_EVS_Global.EVS_LogPtr->LogCount == CFE_PLATFORM_EVS_LOG_MAX) + { + /* The full flag and log count are somewhat redundant */ + CFE_EVS_Global.EVS_LogPtr->LogFullFlag = true; } } - - OS_MutSemGive(CFE_EVS_Global.EVS_SharedDataMutexID); } + OS_MutSemGive(CFE_EVS_Global.EVS_SharedDataMutexID); + return; } /* End EVS_AddLog */ @@ -159,99 +156,88 @@ int32 CFE_EVS_WriteLogDataFileCmd(const CFE_EVS_WriteLogDataFileCmd_t *data) CFE_FS_Header_t LogFileHdr; char LogFilename[OS_MAX_PATH_LEN]; - if (CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled == false) + /* Copy the commanded filename into local buffer to ensure size limitation and to allow for modification */ + CFE_SB_MessageStringGet(LogFilename, (const char *)CmdPtr->LogFilename, CFE_PLATFORM_EVS_DEFAULT_LOG_FILE, + sizeof(LogFilename), sizeof(CmdPtr->LogFilename)); + + /* Create the log file */ + Result = OS_OpenCreate(&LogFileHandle, LogFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + + if (Result < OS_SUCCESS) { - EVS_SendEvent(CFE_EVS_NO_LOGWR_EID, CFE_EVS_EventType_ERROR, - "Write Log Command: Event Log is Disabled"); - Result = CFE_EVS_FUNCTION_DISABLED; + EVS_SendEvent(CFE_EVS_ERR_CRLOGFILE_EID, CFE_EVS_EventType_ERROR, + "Write Log File Command Error: OS_OpenCreate = 0x%08X, filename = %s", + (unsigned int)Result, LogFilename); } else { - /* Copy the commanded filename into local buffer to ensure size limitation and to allow for modification */ - CFE_SB_MessageStringGet(LogFilename, (const char *)CmdPtr->LogFilename, CFE_PLATFORM_EVS_DEFAULT_LOG_FILE, - sizeof(LogFilename), sizeof(CmdPtr->LogFilename)); + /* Result will be overridden if everything works */ + Result = CFE_EVS_FILE_WRITE_ERROR; - /* Create the log file */ - Result = OS_OpenCreate(&LogFileHandle, LogFilename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); + /* Initialize cFE file header for an event log file */ + CFE_FS_InitHeader(&LogFileHdr, "cFE EVS Log File", CFE_FS_SubType_EVS_EVENTLOG); - if (Result < OS_SUCCESS) - { - EVS_SendEvent(CFE_EVS_ERR_CRLOGFILE_EID, CFE_EVS_EventType_ERROR, - "Write Log File Command Error: OS_OpenCreate = 0x%08X, filename = %s", - (unsigned int)Result, LogFilename); + /* Write the file header to the log file */ + BytesWritten = CFE_FS_WriteHeader(LogFileHandle, &LogFileHdr); - } - else + if (BytesWritten == sizeof(LogFileHdr)) { - /* Result will be overridden if everything works */ - Result = CFE_EVS_FILE_WRITE_ERROR; - - /* Initialize cFE file header for an event log file */ - CFE_FS_InitHeader(&LogFileHdr, "cFE EVS Log File", CFE_FS_SubType_EVS_EVENTLOG); - - /* Write the file header to the log file */ - BytesWritten = CFE_FS_WriteHeader(LogFileHandle, &LogFileHdr); + /* Serialize access to event log control variables */ + OS_MutSemTake(CFE_EVS_Global.EVS_SharedDataMutexID); - if (BytesWritten == sizeof(LogFileHdr)) + /* Is the log full? -- Doesn't matter if wrap mode is enabled */ + if (CFE_EVS_Global.EVS_LogPtr->LogCount == CFE_PLATFORM_EVS_LOG_MAX) + { + /* Start with log entry that will be overwritten next (oldest) */ + LogIndex = CFE_EVS_Global.EVS_LogPtr->Next; + } + else { - /* Serialize access to event log control variables */ - OS_MutSemTake(CFE_EVS_Global.EVS_SharedDataMutexID); + /* Start with the first entry in the log (oldest) */ + LogIndex = 0; + } - /* Is the log full? -- Doesn't matter if wrap mode is enabled */ - if (CFE_EVS_Global.EVS_LogPtr->LogCount == CFE_PLATFORM_EVS_LOG_MAX) - { - /* Start with log entry that will be overwritten next (oldest) */ - LogIndex = CFE_EVS_Global.EVS_LogPtr->Next; - } - else - { - /* Start with the first entry in the log (oldest) */ - LogIndex = 0; - } + /* Write all the "in-use" event log entries to the file */ + for (i = 0; i < CFE_EVS_Global.EVS_LogPtr->LogCount; i++) + { + BytesWritten = OS_write(LogFileHandle, + &CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex], + sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])); - /* Write all the "in-use" event log entries to the file */ - for (i = 0; i < CFE_EVS_Global.EVS_LogPtr->LogCount; i++) + if (BytesWritten == sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])) { - BytesWritten = OS_write(LogFileHandle, - &CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex], - sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])); + LogIndex++; - if (BytesWritten == sizeof(CFE_EVS_Global.EVS_LogPtr->LogEntry[LogIndex])) + if (LogIndex >= CFE_PLATFORM_EVS_LOG_MAX) { - LogIndex++; - - if (LogIndex >= CFE_PLATFORM_EVS_LOG_MAX) - { - LogIndex = 0; - } - } - else - { - break; + LogIndex = 0; } } - - OS_MutSemGive(CFE_EVS_Global.EVS_SharedDataMutexID); - - /* Process command handler success result */ - if (i == CFE_EVS_Global.EVS_LogPtr->LogCount) - { - EVS_SendEvent(CFE_EVS_WRLOG_EID, CFE_EVS_EventType_DEBUG, - "Write Log File Command: %d event log entries written to %s", - (int)CFE_EVS_Global.EVS_LogPtr->LogCount, LogFilename); - Result = CFE_SUCCESS; - } else { - EVS_SendEvent(CFE_EVS_ERR_WRLOGFILE_EID, CFE_EVS_EventType_ERROR, - "Write Log File Command Error: OS_write = 0x%08X, filename = %s", - (unsigned int)BytesWritten, LogFilename); + break; } } - OS_close(LogFileHandle); + OS_MutSemGive(CFE_EVS_Global.EVS_SharedDataMutexID); + + /* Process command handler success result */ + if (i == CFE_EVS_Global.EVS_LogPtr->LogCount) + { + EVS_SendEvent(CFE_EVS_WRLOG_EID, CFE_EVS_EventType_DEBUG, + "Write Log File Command: %d event log entries written to %s", + (int)CFE_EVS_Global.EVS_LogPtr->LogCount, LogFilename); + Result = CFE_SUCCESS; + } + else + { + EVS_SendEvent(CFE_EVS_ERR_WRLOGFILE_EID, CFE_EVS_EventType_ERROR, + "Write Log File Command Error: OS_write = 0x%08X, filename = %s", + (unsigned int)BytesWritten, LogFilename); + } } + OS_close(LogFileHandle); } return(Result); @@ -274,35 +260,25 @@ int32 CFE_EVS_SetLogModeCmd(const CFE_EVS_SetLogModeCmd_t *data) const CFE_EVS_SetLogMode_Payload_t *CmdPtr = &data->Payload; int32 Status; - if (CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled == true) + if ((CmdPtr->LogMode == CFE_EVS_LogMode_OVERWRITE) || (CmdPtr->LogMode == CFE_EVS_LogMode_DISCARD)) { - if ((CmdPtr->LogMode == CFE_EVS_LogMode_OVERWRITE) || (CmdPtr->LogMode == CFE_EVS_LogMode_DISCARD)) - { - /* Serialize access to event log control variables */ - OS_MutSemTake(CFE_EVS_Global.EVS_SharedDataMutexID); - CFE_EVS_Global.EVS_LogPtr->LogMode = CmdPtr->LogMode; - OS_MutSemGive(CFE_EVS_Global.EVS_SharedDataMutexID); + /* Serialize access to event log control variables */ + OS_MutSemTake(CFE_EVS_Global.EVS_SharedDataMutexID); + CFE_EVS_Global.EVS_LogPtr->LogMode = CmdPtr->LogMode; + OS_MutSemGive(CFE_EVS_Global.EVS_SharedDataMutexID); - EVS_SendEvent(CFE_EVS_LOGMODE_EID, CFE_EVS_EventType_DEBUG, - "Set Log Mode Command: Log Mode = %d", (int)CmdPtr->LogMode); + EVS_SendEvent(CFE_EVS_LOGMODE_EID, CFE_EVS_EventType_DEBUG, + "Set Log Mode Command: Log Mode = %d", (int)CmdPtr->LogMode); - Status = CFE_SUCCESS; - } - else - { - Status = CFE_EVS_INVALID_PARAMETER; - EVS_SendEvent(CFE_EVS_ERR_LOGMODE_EID, CFE_EVS_EventType_ERROR, - "Set Log Mode Command Error: Log Mode = %d", (int)CmdPtr->LogMode); - } + Status = CFE_SUCCESS; } else { - Status = CFE_EVS_FUNCTION_DISABLED; - EVS_SendEvent(CFE_EVS_NO_LOGSET_EID, CFE_EVS_EventType_ERROR, - "Set Log Mode Command: Event Log is Disabled"); + Status = CFE_EVS_INVALID_PARAMETER; + EVS_SendEvent(CFE_EVS_ERR_LOGMODE_EID, CFE_EVS_EventType_ERROR, + "Set Log Mode Command Error: Log Mode = %d", (int)CmdPtr->LogMode); } - return Status; } /* End CFE_EVS_SetLogModeCmd */ diff --git a/fsw/cfe-core/src/evs/cfe_evs_task.c b/fsw/cfe-core/src/evs/cfe_evs_task.c index 152b8c133..ce6efb091 100644 --- a/fsw/cfe-core/src/evs/cfe_evs_task.c +++ b/fsw/cfe-core/src/evs/cfe_evs_task.c @@ -49,6 +49,8 @@ /* Global Data */ CFE_EVS_Global_t CFE_EVS_Global; +/* Defines */ +#define CFE_EVS_PANIC_DELAY 500 /**< \brief Task delay before PSP panic */ /* ** Local function prototypes. @@ -94,9 +96,16 @@ int32 CFE_EVS_EarlyInit ( void ) /* Get a pointer to the CFE reset area from the BSP */ Status = CFE_PSP_GetResetArea(&resetAreaAddr, &resetAreaSize); + /* Panic on error */ if (Status != CFE_PSP_SUCCESS) { + /* Can't log evs messages without the reset area */ CFE_ES_WriteToSysLog("EVS call to CFE_PSP_GetResetArea failed, RC=0x%08x\n", (unsigned int)Status); + + /* Delay to allow message to be read */ + OS_TaskDelay(CFE_EVS_PANIC_DELAY); + + CFE_PSP_Panic(CFE_PSP_PANIC_MEMORY_ALLOC); } else if (resetAreaSize < sizeof(CFE_ES_ResetData_t)) { @@ -104,8 +113,18 @@ int32 CFE_EVS_EarlyInit ( void ) Status = CFE_EVS_RESET_AREA_POINTER; CFE_ES_WriteToSysLog("Unexpected size from CFE_PSP_GetResetArea: expected = 0x%08lX, actual = 0x%08lX\n", (unsigned long)sizeof(CFE_ES_ResetData_t), (unsigned long)resetAreaSize); + + /* Delay to allow message to be read */ + OS_TaskDelay(CFE_EVS_PANIC_DELAY); + + CFE_PSP_Panic(CFE_PSP_PANIC_MEMORY_ALLOC); } else + { + Status = CFE_SUCCESS; + } + + if (Status == CFE_SUCCESS) { CFE_EVS_ResetDataPtr = (CFE_ES_ResetData_t *)resetAreaAddr; /* Save pointer to the EVS portion of the CFE reset area */ @@ -117,47 +136,58 @@ int32 CFE_EVS_EarlyInit ( void ) if (Status != OS_SUCCESS) { CFE_ES_WriteToSysLog("EVS call to OS_MutSemCreate failed, RC=0x%08x\n", (unsigned int)Status); + + /* Delay to allow message to be read */ + OS_TaskDelay(CFE_EVS_PANIC_DELAY); + + CFE_PSP_Panic(CFE_PSP_PANIC_STARTUP_SEM); } else { - /* Enable access to the EVS event log */ - CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = true; + Status = CFE_SUCCESS; + } + } - /* Clear event log if power-on reset or bad contents */ - if (CFE_ES_GetResetType(NULL) == CFE_PSP_RST_TYPE_POWERON) - { - CFE_ES_WriteToSysLog("Event Log cleared following power-on reset\n"); - EVS_ClearLog(); - CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE; - } - else if (((CFE_EVS_Global.EVS_LogPtr->LogMode != CFE_EVS_LogMode_OVERWRITE) && - (CFE_EVS_Global.EVS_LogPtr->LogMode != CFE_EVS_LogMode_DISCARD)) || - ((CFE_EVS_Global.EVS_LogPtr->LogFullFlag != false) && - (CFE_EVS_Global.EVS_LogPtr->LogFullFlag != true)) || - (CFE_EVS_Global.EVS_LogPtr->Next >= CFE_PLATFORM_EVS_LOG_MAX)) - { - CFE_ES_WriteToSysLog("Event Log cleared, n=%d, c=%d, f=%d, m=%d, o=%d\n", - (int)CFE_EVS_Global.EVS_LogPtr->Next, - (int)CFE_EVS_Global.EVS_LogPtr->LogCount, - (int)CFE_EVS_Global.EVS_LogPtr->LogFullFlag, - (int)CFE_EVS_Global.EVS_LogPtr->LogMode, - (int)CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter); - EVS_ClearLog(); - CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE; - } - else - { - CFE_ES_WriteToSysLog("Event Log restored, n=%d, c=%d, f=%d, m=%d, o=%d\n", - (int)CFE_EVS_Global.EVS_LogPtr->Next, - (int)CFE_EVS_Global.EVS_LogPtr->LogCount, - (int)CFE_EVS_Global.EVS_LogPtr->LogFullFlag, - (int)CFE_EVS_Global.EVS_LogPtr->LogMode, - (int)CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter); - } + if (Status == CFE_SUCCESS) + { + + /* Report log as enabled */ + CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = true; + + /* Clear event log if power-on reset or bad contents */ + if (CFE_ES_GetResetType(NULL) == CFE_PSP_RST_TYPE_POWERON) + { + CFE_ES_WriteToSysLog("Event Log cleared following power-on reset\n"); + EVS_ClearLog(); + CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE; + } + else if (((CFE_EVS_Global.EVS_LogPtr->LogMode != CFE_EVS_LogMode_OVERWRITE) && + (CFE_EVS_Global.EVS_LogPtr->LogMode != CFE_EVS_LogMode_DISCARD)) || + ((CFE_EVS_Global.EVS_LogPtr->LogFullFlag != false) && + (CFE_EVS_Global.EVS_LogPtr->LogFullFlag != true)) || + (CFE_EVS_Global.EVS_LogPtr->Next >= CFE_PLATFORM_EVS_LOG_MAX)) + { + CFE_ES_WriteToSysLog("Event Log cleared, n=%d, c=%d, f=%d, m=%d, o=%d\n", + (int)CFE_EVS_Global.EVS_LogPtr->Next, + (int)CFE_EVS_Global.EVS_LogPtr->LogCount, + (int)CFE_EVS_Global.EVS_LogPtr->LogFullFlag, + (int)CFE_EVS_Global.EVS_LogPtr->LogMode, + (int)CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter); + EVS_ClearLog(); + CFE_EVS_Global.EVS_LogPtr->LogMode = CFE_PLATFORM_EVS_DEFAULT_LOG_MODE; + } + else + { + CFE_ES_WriteToSysLog("Event Log restored, n=%d, c=%d, f=%d, m=%d, o=%d\n", + (int)CFE_EVS_Global.EVS_LogPtr->Next, + (int)CFE_EVS_Global.EVS_LogPtr->LogCount, + (int)CFE_EVS_Global.EVS_LogPtr->LogFullFlag, + (int)CFE_EVS_Global.EVS_LogPtr->LogMode, + (int)CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter); } } - return(CFE_SUCCESS); + return(Status); } /* End CFE_EVS_EarlyInit */ @@ -658,20 +688,8 @@ int32 CFE_EVS_NoopCmd(const CFE_EVS_NoopCmd_t *data) */ int32 CFE_EVS_ClearLogCmd(const CFE_EVS_ClearLogCmd_t *data) { - int32 Status; - - if (CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled == true) - { - EVS_ClearLog(); - Status = CFE_SUCCESS; - } - else - { - EVS_SendEvent(CFE_EVS_NO_LOGCLR_EID, CFE_EVS_EventType_ERROR, - "Clear Log Command: Event Log is Disabled"); - Status = CFE_EVS_FUNCTION_DISABLED; - } - return Status; + EVS_ClearLog(); + return CFE_SUCCESS; } /* @@ -690,13 +708,10 @@ int32 CFE_EVS_ReportHousekeepingCmd (const CFE_MSG_CommandHeader_t *data) EVS_AppData_t *AppDataPtr; CFE_EVS_AppTlmData_t *AppTlmDataPtr; - if (CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled == true) - { - /* Copy hk variables that are maintained in the event log */ - CFE_EVS_Global.EVS_TlmPkt.Payload.LogFullFlag = CFE_EVS_Global.EVS_LogPtr->LogFullFlag; - CFE_EVS_Global.EVS_TlmPkt.Payload.LogMode = CFE_EVS_Global.EVS_LogPtr->LogMode; - CFE_EVS_Global.EVS_TlmPkt.Payload.LogOverflowCounter = CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter; - } + /* Copy hk variables that are maintained in the event log */ + CFE_EVS_Global.EVS_TlmPkt.Payload.LogFullFlag = CFE_EVS_Global.EVS_LogPtr->LogFullFlag; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogMode = CFE_EVS_Global.EVS_LogPtr->LogMode; + CFE_EVS_Global.EVS_TlmPkt.Payload.LogOverflowCounter = CFE_EVS_Global.EVS_LogPtr->LogOverflowCounter; /* Write event state data for registered apps to telemetry packet */ AppDataPtr = CFE_EVS_Global.AppData; diff --git a/fsw/cfe-core/src/inc/cfe_error.h b/fsw/cfe-core/src/inc/cfe_error.h index 0173faaf7..657bbc98b 100644 --- a/fsw/cfe-core/src/inc/cfe_error.h +++ b/fsw/cfe-core/src/inc/cfe_error.h @@ -263,15 +263,6 @@ typedef int32 CFE_Status_t; */ #define CFE_EVS_INVALID_PARAMETER ((CFE_Status_t)0xc2000008) -/** - * @brief Function Disabled - * - * EVS command sent that requires a feature currently turned off - * This is to differentiate between "NOT_IMPLEMENTED" where the - * feature IS implemented but it is disabled at runtime. - */ -#define CFE_EVS_FUNCTION_DISABLED ((CFE_Status_t)0xc2000009) - /** * @brief Not Implemented * diff --git a/fsw/cfe-core/src/inc/cfe_evs_events.h b/fsw/cfe-core/src/inc/cfe_evs_events.h index 5c3b0af93..20d6b1fbf 100644 --- a/fsw/cfe-core/src/inc/cfe_evs_events.h +++ b/fsw/cfe-core/src/inc/cfe_evs_events.h @@ -533,51 +533,6 @@ **/ #define CFE_EVS_WRLOG_EID 33 -/** \brief 'Set Log Mode Command: Event Log is Disabled' -** \event 'Set Log Mode Command: Event Log is Disabled' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of a "Set Log Mode" -** command when the use of the Event Log has been disabled. The EVS task -** must succeed during task initialization in acquiring a pointer to -** the cFE reset area and in the creation of a serializing semaphore to -** control access to the Event Log. -**/ -#define CFE_EVS_NO_LOGSET_EID 34 - -/** \brief 'Clear Log Command: Event Log is Disabled' -** \event 'Clear Log Command: Event Log is Disabled' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of a "Clear Log" -** command when the use of the Event Log has been disabled. The EVS task -** must succeed during task initialization in acquiring a pointer to -** the cFE reset area and in the creation of a serializing semaphore to -** control access to the Event Log. -**/ -#define CFE_EVS_NO_LOGCLR_EID 35 - -/** \brief 'Write Log Command: Event Log is Disabled' -** \event 'Write Log Command: Event Log is Disabled' -** -** \par Type: ERROR -** -** \par Cause: -** -** This event message is generated upon receipt of a "Write Log" -** command when the use of the Event Log has been disabled. The EVS task -** must succeed during task initialization in acquiring a pointer to -** the cFE reset area and in the creation of a serializing semaphore to -** control access to the Event Log. -**/ -#define CFE_EVS_NO_LOGWR_EID 36 - /** \brief 'Add Filter Command:AppName = \%s, EventID = 0x\%08x is already registered for filtering' ** \event 'Add Filter Command:AppName = \%s, EventID = 0x\%08x is already registered for filtering' ** diff --git a/fsw/cfe-core/unit-test/evs_UT.c b/fsw/cfe-core/unit-test/evs_UT.c index 08ae7b5f7..4e03b4857 100644 --- a/fsw/cfe-core/unit-test/evs_UT.c +++ b/fsw/cfe-core/unit-test/evs_UT.c @@ -419,6 +419,17 @@ void Test_Init(void) "CFE_EVS_EarlyInit", "Unexpected size returned by CFE_PSP_GetResetArea"); + /* Repeat sucessful initialization to configure log for later references */ + UT_InitData(); + UT_SetSizeofESResetArea(sizeof(CFE_ES_ResetData_t)); + UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_SUCCESS); + UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetResetType), 1, CFE_PSP_RST_TYPE_POWERON); + CFE_EVS_EarlyInit(); + UT_Report(__FILE__, __LINE__, + UT_SyslogIsInHistory(EVS_SYSLOG_MSGS[4]), + "CFE_EVS_EarlyInit", + "Early initialization successful"); + /* Test task initialization where the application registration fails */ UT_InitData(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterApp), 1, -1); @@ -1227,20 +1238,11 @@ void Test_Logging(void) CFE_EVS_Global.EVS_TlmPkt.Payload.MessageFormatMode = CFE_EVS_MsgFormat_LONG; - /* Test setting the logging mode with logging disabled */ + /* Initialize */ UT_InitData(); - CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = false; memset(&CmdBuf, 0, sizeof(CmdBuf)); - CmdBuf.modecmd.Payload.LogMode = 0xff; - UT_EVS_DoDispatchCheckEvents(&CmdBuf.modecmd, sizeof(CmdBuf.modecmd), - UT_TPID_CFE_EVS_CMD_SET_LOG_MODE_CC, - &UT_EVS_EventBuf); - UT_Report(__FILE__, __LINE__, - UT_EVS_EventBuf.EventID == CFE_EVS_NO_LOGSET_EID, - "CFE_EVS_SetLoggingModeCmd", - "Set log mode command: event log disabled"); - /* Re-enable logging and set conditions to allow complete code coverage */ + /* Enable logging and set conditions to allow complete code coverage */ CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = true; UT_SetSizeofESResetArea(sizeof(CFE_ES_ResetData_t)); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_SUCCESS); @@ -1303,30 +1305,9 @@ void Test_Logging(void) "CFE_EVS_SetLogModeCmd", "Log overfill event (overwrite mode)"); - /* Test writing to the log while it is disabled */ - UT_InitData(); - CFE_EVS_Global.EVS_TlmPkt.Payload.LogEnabled = false; - memset(&CmdBuf, 0, sizeof(CmdBuf)); - UT_EVS_DoDispatchCheckEvents(&CmdBuf.logfilecmd, sizeof(CmdBuf.logfilecmd), - UT_TPID_CFE_EVS_CMD_WRITE_LOG_DATA_FILE_CC, - &UT_EVS_EventBuf); - UT_Report(__FILE__, __LINE__, - UT_EVS_EventBuf.EventID == CFE_EVS_NO_LOGWR_EID, - "CFE_EVS_WriteLogDataFileCmd", - "Write log command with event log disabled"); - - /* Test clearing the log while it is disabled*/ - UT_InitData(); - UT_EVS_DoDispatchCheckEvents(&CmdBuf.cmd, sizeof(CmdBuf.cmd), - UT_TPID_CFE_EVS_CMD_CLEAR_LOG_CC, - &UT_EVS_EventBuf); - UT_Report(__FILE__, __LINE__, - UT_EVS_EventBuf.EventID == CFE_EVS_NO_LOGCLR_EID, - "EVS_ClearLog", - "Clear log command with event log disabled"); - /* Test sending a no op command */ UT_InitData(); + memset(&CmdBuf, 0, sizeof(CmdBuf)); UT_EVS_DoDispatchCheckEvents(&CmdBuf.cmd, sizeof(CmdBuf.cmd), UT_TPID_CFE_EVS_CMD_NOOP_CC, &UT_EVS_EventBuf);