From dd57c8a959b8406e361ae6d19914183844d3e01e Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 15:43:22 -0500 Subject: [PATCH 01/13] Issue #159, Create CDS data structure --- fsw/src/lc_app.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fsw/src/lc_app.h b/fsw/src/lc_app.h index cef4a9d..3ddfde9 100644 --- a/fsw/src/lc_app.h +++ b/fsw/src/lc_app.h @@ -126,6 +126,15 @@ typedef struct LC_MListTag * Type Definitions ************************************************************************/ +typedef struct +{ + LC_HkPacket_t HkPacket; /**< \brief Housekeeping telemetry packet */ + LC_WRTEntry_t *WRTPtr; /**< \brief Watchpoint Results Table Pointer */ + LC_ARTEntry_t *ARTPtr; /**< \brief Actionpoint Results Table Pointer */ + LC_WDTEntry_t *WDTPtr; /**< \brief Watchpoint Definition Table Pointer */ + LC_ADTEntry_t *ADTPtr; /**< \brief Actionpoint Definition Table Pointer */ +} LC_CDS_Data_t; + /** * \brief LC Operational Data Structure * From 9253fe48899b824e0c482a9d357493d4cb254f43 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 15:44:11 -0500 Subject: [PATCH 02/13] Issue #159, Set up a single handle for CDS --- fsw/src/lc_app.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fsw/src/lc_app.h b/fsw/src/lc_app.h index 3ddfde9..76bc41f 100644 --- a/fsw/src/lc_app.h +++ b/fsw/src/lc_app.h @@ -39,9 +39,7 @@ * \name LC CDS Buffer Strings * \{ */ -#define LC_WRT_CDSNAME "LC_CDS_WRT" -#define LC_ART_CDSNAME "LC_CDS_ART" -#define LC_APPDATA_CDSNAME "LC_CDS_AppData" +#define LC_CDS_NAME "LC_CDS" /**\}*/ /** @@ -156,10 +154,8 @@ typedef struct CFE_TBL_Handle_t WRTHandle; /**< \brief Watchpoint Results Table Handle */ CFE_TBL_Handle_t ARTHandle; /**< \brief Actionpoint Results Table Handle */ - CFE_ES_CDSHandle_t WRTDataCDSHandle; /**< \brief Watchpoint Results Table CDS Handle */ - CFE_ES_CDSHandle_t ARTDataCDSHandle; /**< \brief Actionpoint Results Table CDS Handle */ - - CFE_ES_CDSHandle_t AppDataCDSHandle; /**< \brief Application Data CDS Handle */ + CFE_ES_CDSHandle_t CDS_Handle; /**< \brief LC CDS Handle */ + LC_CDS_Data_t CDS_Data; /**< \brief Data structure to interface with CDS */ uint16 WatchpointCount; /**< \brief Count of in-use watchpoints defined in the Watchpoint Definition Table */ From ce63fe2298148848d4829dfa99d709bb378d0429 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 15:44:48 -0500 Subject: [PATCH 03/13] Issue #159, Simplify CDS registering and restoration process --- fsw/src/lc_app.c | 137 ++++++++++++----------------------------------- 1 file changed, 34 insertions(+), 103 deletions(-) diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index 13e99cd..81c7719 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -776,129 +776,60 @@ CFE_Status_t LC_CreateDefinitionTables(void) CFE_Status_t LC_CreateTaskCDS(void) { - CFE_Status_t Result; - uint32 DataSize; - - /* - ** Create CDS and try to restore Watchpoint Results Table (WRT) data - */ - DataSize = LC_MAX_WATCHPOINTS * sizeof(LC_WRTEntry_t); - Result = CFE_ES_RegisterCDS(&LC_OperData.WRTDataCDSHandle, DataSize, LC_WRT_CDSNAME); - - if (Result == CFE_SUCCESS) - { - /* - ** Normal result after a power on reset (cold boot) - continue with next CDS area - */ - LC_OperData.TableResults |= LC_WRT_CDS_CREATED; - } - else if (Result == CFE_ES_CDS_ALREADY_EXISTS) - { - /* - ** Normal result after a processor reset (warm boot) - try to restore previous data - */ - LC_OperData.TableResults |= LC_WRT_CDS_CREATED; - - Result = CFE_ES_RestoreFromCDS(LC_OperData.WRTPtr, LC_OperData.WRTDataCDSHandle); + CFE_Status_t Status; - if (Result == CFE_SUCCESS) - { - LC_OperData.TableResults |= LC_WRT_CDS_RESTORED; - } - } - else - { - CFE_EVS_SendEvent(LC_WRT_CDS_REGISTER_ERR_EID, - CFE_EVS_EventType_ERROR, - "Error registering WRT CDS Area, RC=0x%08X", - (unsigned int)Result); - return Result; - } + /* Default to active CDS */ + LC_OperData.HaveActiveCDS = true; /* - ** Create CDS and try to restore Actionpoint Results Table (ART) data + ** Create CDS and try to restore data */ - DataSize = LC_MAX_ACTIONPOINTS * sizeof(LC_ARTEntry_t); - Result = CFE_ES_RegisterCDS(&LC_OperData.ARTDataCDSHandle, DataSize, LC_ART_CDSNAME); + Status = CFE_ES_RegisterCDS(&LC_OperData.CDS_Handle, sizeof(LC_CDS_Data_t), LC_CDS_NAME); - if (Result == CFE_SUCCESS) + if (Status == CFE_SUCCESS) { - /* - ** Normal result after a power on reset (cold boot) - continue with next CDS area - */ - LC_OperData.TableResults |= LC_ART_CDS_CREATED; + /* Initialize CDS data */ + memset(&LC_OperData.CDS_Data.HkPacket, 0, sizeof(LC_HkPacket_t)); + LC_OperData.CDS_Data.WDTPtr = NULL; + LC_OperData.CDS_Data.WRTPtr = NULL; + LC_OperData.CDS_Data.ADTPtr = NULL; + LC_OperData.CDS_Data.ARTPtr = NULL; } - else if (Result == CFE_ES_CDS_ALREADY_EXISTS) + else if (Status == CFE_ES_CDS_ALREADY_EXISTS) { /* - ** Normal result after a processor reset (warm boot) - try to restore previous data + ** Critical Data Store already existed, we need to get a + ** copy of its current contents to see if we can use it */ - LC_OperData.TableResults |= LC_ART_CDS_CREATED; + Status = CFE_ES_RestoreFromCDS(&LC_OperData.CDS_Data, LC_OperData.CDS_Handle); - Result = CFE_ES_RestoreFromCDS(LC_OperData.ARTPtr, LC_OperData.ARTDataCDSHandle); - - if (Result == CFE_SUCCESS) + if (Status == CFE_SUCCESS) { - LC_OperData.TableResults |= LC_ART_CDS_RESTORED; + /* Update values from CDS data */ + memcpy(&LC_OperData.HkPacket, &LC_OperData.CDS_Data.HkPacket, sizeof(LC_HkPacket_t)); + LC_OperData.WDTPtr = LC_OperData.CDS_Data.WDTPtr; + LC_OperData.WRTPtr = LC_OperData.CDS_Data.WRTPtr; + LC_OperData.ADTPtr = LC_OperData.CDS_Data.ADTPtr; + LC_OperData.ARTPtr = LC_OperData.CDS_Data.ARTPtr; + + CFE_EVS_SendEvent(LC_CDS_RESTORED_INF_EID, + CFE_EVS_EventType_INFORMATION, + "Previous state restored from Critical Data Store"); } } else { - CFE_EVS_SendEvent(LC_ART_CDS_REGISTER_ERR_EID, - CFE_EVS_EventType_ERROR, - "Error registering ART CDS Area, RC=0x%08X", - (unsigned int)Result); - return Result; - } - - /* - ** Create CDS and try to restore Application (APP) data - */ - DataSize = sizeof(LC_AppData_t); - Result = CFE_ES_RegisterCDS(&LC_OperData.AppDataCDSHandle, DataSize, LC_APPDATA_CDSNAME); - - if (Result == CFE_SUCCESS) - { - /* - ** Normal result after a power on reset (cold boot) - continue with next CDS area - */ - LC_OperData.TableResults |= LC_APP_CDS_CREATED; - } - else if (Result == CFE_ES_CDS_ALREADY_EXISTS) - { - /* - ** Normal result after a processor reset (warm boot) - try to restore previous data - */ - LC_OperData.TableResults |= LC_APP_CDS_CREATED; - - Result = CFE_ES_RestoreFromCDS(&LC_AppData, LC_OperData.AppDataCDSHandle); - - if ((Result == CFE_SUCCESS) && (LC_AppData.CDSSavedOnExit == LC_CDS_SAVED)) - { - /* - ** Success - only if previous session saved CDS data at least once - */ - LC_OperData.TableResults |= LC_APP_CDS_RESTORED; - - /* - ** May need to override the restored application state - */ + /* Empty out the CDS handle so it can't be mistakenly used */ + LC_OperData.CDS_Handle = 0; + LC_OperData.HaveActiveCDS = false; -#if LC_STATE_WHEN_CDS_RESTORED != LC_STATE_FROM_CDS - LC_AppData.CurrentLCState = LC_STATE_WHEN_CDS_RESTORED; -#endif - } - } - else - { - CFE_EVS_SendEvent(LC_APP_CDS_REGISTER_ERR_EID, + CFE_EVS_SendEvent(LC_CDS_REGISTER_ERR_EID, CFE_EVS_EventType_ERROR, - "Error registering application data CDS Area, RC=0x%08X", - (unsigned int)Result); - return Result; + "Error registering CDS Area, RC=0x%08X", + (unsigned int)Status); } - return CFE_SUCCESS; + return Status; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ From eaa13c30ca121a0fbd0c6f93c50b0b66ae21f49f Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 15:46:29 -0500 Subject: [PATCH 04/13] Issue #159, Rename LC_CreateTaskCDS to LC_GetCDS_Data --- fsw/src/lc_app.c | 4 +-- fsw/src/lc_app.h | 2 +- unit-test/lc_app_tests.c | 66 +++++++++++++++++----------------- unit-test/stubs/lc_app_stubs.c | 10 +++--- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index 81c7719..81bf085 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -409,7 +409,7 @@ CFE_Status_t LC_TableInit(void) { if (LC_OperData.HaveActiveCDS) { - Result = LC_CreateTaskCDS(); + Result = LC_GetCDS_Data(); if (Result != CFE_SUCCESS) { LC_OperData.HaveActiveCDS = false; @@ -774,7 +774,7 @@ CFE_Status_t LC_CreateDefinitionTables(void) /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -CFE_Status_t LC_CreateTaskCDS(void) +CFE_Status_t LC_GetCDS_Data(void) { CFE_Status_t Status; diff --git a/fsw/src/lc_app.h b/fsw/src/lc_app.h index 76bc41f..e771540 100644 --- a/fsw/src/lc_app.h +++ b/fsw/src/lc_app.h @@ -341,7 +341,7 @@ CFE_Status_t LC_CreateDefinitionTables(void); * * \sa #LC_TableInit */ -CFE_Status_t LC_CreateTaskCDS(void); +CFE_Status_t LC_GetCDS_Data(void); /** * \brief Load Default Table Values diff --git a/unit-test/lc_app_tests.c b/unit-test/lc_app_tests.c index abc366f..ef4f08b 100644 --- a/unit-test/lc_app_tests.c +++ b/unit-test/lc_app_tests.c @@ -555,7 +555,7 @@ void LC_TableInit_Test_LoadDefaultTables(void) /* Only recover WDT */ UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 3, CFE_TBL_INFO_RECOVERED_TBL); - /* Setup LC_CreateTaskCDS to succeed */ + /* Setup LC_GetCDS_Data to succeed */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RegisterCDS), CFE_ES_CDS_ALREADY_EXISTS); UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RestoreFromCDS), CFE_SUCCESS); LC_AppData.CDSSavedOnExit = LC_CDS_SAVED; @@ -667,7 +667,7 @@ void LC_TableInit_Test_GetWDTAddressError(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_SUCCESS); UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_SUCCESS); - /* Setup LC_CreateTaskCDS to succeed */ + /* Setup LC_GetCDS_Data to succeed */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RegisterCDS), CFE_ES_CDS_ALREADY_EXISTS); UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RestoreFromCDS), CFE_SUCCESS); LC_AppData.CDSSavedOnExit = LC_CDS_SAVED; @@ -698,7 +698,7 @@ void LC_TableInit_Test_GetWDTAddressUpdated(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_SUCCESS); UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_SUCCESS); - /* Setup LC_CreateTaskCDS to succeed */ + /* Setup LC_GetCDS_Data to succeed */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RegisterCDS), CFE_ES_CDS_ALREADY_EXISTS); UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RestoreFromCDS), CFE_SUCCESS); LC_AppData.CDSSavedOnExit = LC_CDS_SAVED; @@ -727,7 +727,7 @@ void LC_TableInit_Test_GetADTAddressError(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_SUCCESS); UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_SUCCESS); - /* Setup LC_CreateTaskCDS to succeed */ + /* Setup LC_GetCDS_Data to succeed */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RegisterCDS), CFE_ES_CDS_ALREADY_EXISTS); UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RestoreFromCDS), CFE_SUCCESS); LC_AppData.CDSSavedOnExit = LC_CDS_SAVED; @@ -758,7 +758,7 @@ void LC_TableInit_Test_GetADTAddressUpdated(void) UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_SUCCESS); UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_SUCCESS); - /* Setup LC_CreateTaskCDS to succeed */ + /* Setup LC_GetCDS_Data to succeed */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RegisterCDS), CFE_ES_CDS_ALREADY_EXISTS); UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RestoreFromCDS), CFE_SUCCESS); LC_AppData.CDSSavedOnExit = LC_CDS_SAVED; @@ -783,7 +783,7 @@ void LC_TableInit_Test_CreateTaskCDSError(void) CFE_Status_t Result; LC_OperData.HaveActiveCDS = true; - /* force LC_CreateTaskCDS to fail */ + /* force LC_GetCDS_Data to fail */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RegisterCDS), -1); Result = LC_TableInit(); @@ -798,7 +798,7 @@ void LC_TableInit_Test_Nominal(void) LC_OperData.HaveActiveCDS = true; - /* Setup LC_CreateTaskCDS to succeed */ + /* Setup LC_GetCDS_Data to succeed */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RegisterCDS), CFE_ES_CDS_ALREADY_EXISTS); UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RestoreFromCDS), CFE_SUCCESS); LC_AppData.CDSSavedOnExit = LC_CDS_SAVED; @@ -1330,13 +1330,13 @@ void LC_LoadDefaultTables_Test_InfoUpdated(void) UtAssert_INT32_EQ(call_count_CFE_EVS_SendEvent, 0); } -void LC_CreateTaskCDS_Test_Nominal(void) +void LC_GetCDS_Data_Test_Nominal(void) { CFE_Status_t Result; UT_SetDefaultReturnValue(UT_KEY(CFE_ES_RegisterCDS), CFE_SUCCESS); - Result = LC_CreateTaskCDS(); + Result = LC_GetCDS_Data(); UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -1350,7 +1350,7 @@ void LC_CreateTaskCDS_Test_Nominal(void) "LC_OperData.TableResult & LC_APP_CDS_CREATED == LC_APP_CDS_CREATED"); } -void LC_CreateTaskCDS_Test_WRTRegisterCDSError(void) +void LC_GetCDS_Data_Test_WRTRegisterCDSError(void) { CFE_Status_t Result; int32 strCmpResult; @@ -1360,7 +1360,7 @@ void LC_CreateTaskCDS_Test_WRTRegisterCDSError(void) snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Error registering WRT CDS Area, RC=0x%%08X"); - Result = LC_CreateTaskCDS(); + Result = LC_GetCDS_Data(); UtAssert_True(Result == -1, "Result == -1"); @@ -1373,7 +1373,7 @@ void LC_CreateTaskCDS_Test_WRTRegisterCDSError(void) UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); } -void LC_CreateTaskCDS_Test_ARTRegisterCDSError(void) +void LC_GetCDS_Data_Test_ARTRegisterCDSError(void) { CFE_Status_t Result; int32 strCmpResult; @@ -1383,7 +1383,7 @@ void LC_CreateTaskCDS_Test_ARTRegisterCDSError(void) snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Error registering ART CDS Area, RC=0x%%08X"); - Result = LC_CreateTaskCDS(); + Result = LC_GetCDS_Data(); UtAssert_True(Result == -1, "Result == -1"); @@ -1396,7 +1396,7 @@ void LC_CreateTaskCDS_Test_ARTRegisterCDSError(void) UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); } -void LC_CreateTaskCDS_Test_AppDataRegisterCDSError(void) +void LC_GetCDS_Data_Test_AppDataRegisterCDSError(void) { CFE_Status_t Result; int32 strCmpResult; @@ -1408,7 +1408,7 @@ void LC_CreateTaskCDS_Test_AppDataRegisterCDSError(void) CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Error registering application data CDS Area, RC=0x%%08X"); - Result = LC_CreateTaskCDS(); + Result = LC_GetCDS_Data(); UtAssert_True(Result == -1, "Result == -1"); @@ -1421,7 +1421,7 @@ void LC_CreateTaskCDS_Test_AppDataRegisterCDSError(void) UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); } -void LC_CreateTaskCDS_Test_RestoreSuccess(void) +void LC_GetCDS_Data_Test_RestoreSuccess(void) { CFE_Status_t Result; @@ -1430,7 +1430,7 @@ void LC_CreateTaskCDS_Test_RestoreSuccess(void) LC_AppData.CDSSavedOnExit = LC_CDS_SAVED; - Result = LC_CreateTaskCDS(); + Result = LC_GetCDS_Data(); UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -1450,7 +1450,7 @@ void LC_CreateTaskCDS_Test_RestoreSuccess(void) "LC_OperData.TableResult & LC_APP_CDS_RESTORED == LC_APP_CDS_RESTORED"); } -void LC_CreateTaskCDS_Test_RestoreSuccessCDSNotSaved(void) +void LC_GetCDS_Data_Test_RestoreSuccessCDSNotSaved(void) { CFE_Status_t Result; @@ -1459,7 +1459,7 @@ void LC_CreateTaskCDS_Test_RestoreSuccessCDSNotSaved(void) LC_AppData.CDSSavedOnExit = !LC_CDS_SAVED; - Result = LC_CreateTaskCDS(); + Result = LC_GetCDS_Data(); UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -1479,7 +1479,7 @@ void LC_CreateTaskCDS_Test_RestoreSuccessCDSNotSaved(void) "LC_OperData.TableResult & LC_APP_CDS_RESTORED == 0"); } -void LC_CreateTaskCDS_Test_RestoreFail(void) +void LC_GetCDS_Data_Test_RestoreFail(void) { CFE_Status_t Result; @@ -1488,7 +1488,7 @@ void LC_CreateTaskCDS_Test_RestoreFail(void) LC_AppData.CDSSavedOnExit = LC_CDS_SAVED; - Result = LC_CreateTaskCDS(); + Result = LC_GetCDS_Data(); UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -1669,26 +1669,26 @@ void UtTest_Setup(void) LC_Test_TearDown, "LC_LoadDefaultTables_Test_InfoUpdated"); - UtTest_Add(LC_CreateTaskCDS_Test_Nominal, LC_Test_Setup, LC_Test_TearDown, "LC_CreateTaskCDS_Test_Nominal"); - UtTest_Add(LC_CreateTaskCDS_Test_WRTRegisterCDSError, + UtTest_Add(LC_GetCDS_Data_Test_Nominal, LC_Test_Setup, LC_Test_TearDown, "LC_GetCDS_Data_Test_Nominal"); + UtTest_Add(LC_GetCDS_Data_Test_WRTRegisterCDSError, LC_Test_Setup, LC_Test_TearDown, - "LC_CreateTaskCDS_Test_WRTRegisterCDSError"); - UtTest_Add(LC_CreateTaskCDS_Test_ARTRegisterCDSError, + "LC_GetCDS_Data_Test_WRTRegisterCDSError"); + UtTest_Add(LC_GetCDS_Data_Test_ARTRegisterCDSError, LC_Test_Setup, LC_Test_TearDown, - "LC_CreateTaskCDS_Test_ARTRegisterCDSError"); - UtTest_Add(LC_CreateTaskCDS_Test_AppDataRegisterCDSError, + "LC_GetCDS_Data_Test_ARTRegisterCDSError"); + UtTest_Add(LC_GetCDS_Data_Test_AppDataRegisterCDSError, LC_Test_Setup, LC_Test_TearDown, - "LC_CreateTaskCDS_Test_AppDataRegisterCDSError"); - UtTest_Add(LC_CreateTaskCDS_Test_RestoreSuccess, + "LC_GetCDS_Data_Test_AppDataRegisterCDSError"); + UtTest_Add(LC_GetCDS_Data_Test_RestoreSuccess, LC_Test_Setup, LC_Test_TearDown, - "LC_CreateTaskCDS_Test_RestoreSuccess"); - UtTest_Add(LC_CreateTaskCDS_Test_RestoreSuccessCDSNotSaved, + "LC_GetCDS_Data_Test_RestoreSuccess"); + UtTest_Add(LC_GetCDS_Data_Test_RestoreSuccessCDSNotSaved, LC_Test_Setup, LC_Test_TearDown, - "LC_CreateTaskCDS_Test_RestoreSuccessCDSNotSaved"); - UtTest_Add(LC_CreateTaskCDS_Test_RestoreFail, LC_Test_Setup, LC_Test_TearDown, "LC_CreateTaskCDS_Test_RestoreFail"); + "LC_GetCDS_Data_Test_RestoreSuccessCDSNotSaved"); + UtTest_Add(LC_GetCDS_Data_Test_RestoreFail, LC_Test_Setup, LC_Test_TearDown, "LC_GetCDS_Data_Test_RestoreFail"); } diff --git a/unit-test/stubs/lc_app_stubs.c b/unit-test/stubs/lc_app_stubs.c index b5c5530..4112010 100644 --- a/unit-test/stubs/lc_app_stubs.c +++ b/unit-test/stubs/lc_app_stubs.c @@ -79,16 +79,16 @@ CFE_Status_t LC_CreateResultTables(void) /* * ---------------------------------------------------- - * Generated stub function for LC_CreateTaskCDS() + * Generated stub function for LC_GetCDS_Data() * ---------------------------------------------------- */ -CFE_Status_t LC_CreateTaskCDS(void) +CFE_Status_t LC_GetCDS_Data(void) { - UT_GenStub_SetupReturnBuffer(LC_CreateTaskCDS, CFE_Status_t); + UT_GenStub_SetupReturnBuffer(LC_GetCDS_Data, CFE_Status_t); - UT_GenStub_Execute(LC_CreateTaskCDS, Basic, NULL); + UT_GenStub_Execute(LC_GetCDS_Data, Basic, NULL); - return UT_GenStub_GetReturnValue(LC_CreateTaskCDS, CFE_Status_t); + return UT_GenStub_GetReturnValue(LC_GetCDS_Data, CFE_Status_t); } /* From 16af86808c659a3a6d67103523bc5f0b80178d20 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 15:48:05 -0500 Subject: [PATCH 05/13] Issue #159, Simplify CDS data updates --- fsw/src/lc_utils.c | 67 ++++++++++++++++------------------------------ 1 file changed, 23 insertions(+), 44 deletions(-) diff --git a/fsw/src/lc_utils.c b/fsw/src/lc_utils.c index 3c98047..f883795 100644 --- a/fsw/src/lc_utils.c +++ b/fsw/src/lc_utils.c @@ -115,56 +115,35 @@ CFE_Status_t LC_ManageTables(void) CFE_Status_t LC_UpdateTaskCDS(void) { - CFE_Status_t Result; + CFE_Status_t Status; - /* - ** Copy the watchpoint results table (WRT) data to CDS - */ - Result = CFE_ES_CopyToCDS(LC_OperData.WRTDataCDSHandle, LC_OperData.WRTPtr); + Status = CFE_SUCCESS; - if (Result != CFE_SUCCESS) + if (LC_OperData.CDS_Handle != 0) { - CFE_EVS_SendEvent(LC_WRT_NO_SAVE_ERR_EID, - CFE_EVS_EventType_ERROR, - "Unable to update watchpoint results in CDS, RC=0x%08X", - (unsigned int)Result); - return Result; - } - - /* - ** Copy the actionpoint results table (ART) data to CDS - */ - Result = CFE_ES_CopyToCDS(LC_OperData.ARTDataCDSHandle, LC_OperData.ARTPtr); - - if (Result != CFE_SUCCESS) - { - CFE_EVS_SendEvent(LC_ART_NO_SAVE_ERR_EID, - CFE_EVS_EventType_ERROR, - "Unable to update actionpoint results in CDS, RC=0x%08X", - (unsigned int)Result); - return Result; - } - - /* - ** Set the "data has been saved" indicator - */ - LC_AppData.CDSSavedOnExit = LC_CDS_SAVED; - - /* - ** Copy the global application data structure to CDS - */ - Result = CFE_ES_CopyToCDS(LC_OperData.AppDataCDSHandle, &LC_AppData); + /* Update CDS data */ + memcpy(&(LC_OperData.CDS_Data.HkPacket), &(LC_OperData.HkPacket), sizeof(LC_HkPacket_t)); + LC_OperData.CDS_Data.WDTPtr = LC_OperData.WDTPtr; + LC_OperData.CDS_Data.WRTPtr = LC_OperData.WRTPtr; + LC_OperData.CDS_Data.ADTPtr = LC_OperData.ADTPtr; + LC_OperData.CDS_Data.ARTPtr = LC_OperData.ARTPtr; + + /* Copy the CDS data to CDS */ + Status = CFE_ES_CopyToCDS(LC_OperData.CDS_Handle, &(LC_OperData.CDS_Data)); + if (Status != CFE_SUCCESS) + { + LC_OperData.CDS_Handle = 0; + CFE_EVS_SendEvent(LC_CDS_NO_SAVE_ERR_EID, + CFE_EVS_EventType_ERROR, + "Unable to update CDS data results in CDS, RC=0x%08X", + (unsigned int)Status); + } - if (Result != CFE_SUCCESS) - { - CFE_EVS_SendEvent(LC_APP_NO_SAVE_START_ERR_EID, - CFE_EVS_EventType_ERROR, - "Unable to update application data in CDS, RC=0x%08X", - (unsigned int)Result); - return Result; + /* Set the "data has been saved" indicator */ + LC_AppData.CDSSavedOnExit = LC_CDS_SAVED; } - return CFE_SUCCESS; + return Status; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ From 6278588035f8ba3e0e90e7f5d90301dfebbeddbe Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 15:48:37 -0500 Subject: [PATCH 06/13] Issue #159, Rename LC_UpdateTaskCDS to LC_SetCDS_Data --- fsw/src/lc_app.c | 4 ++-- fsw/src/lc_utils.c | 9 ++++++--- fsw/src/lc_utils.h | 2 +- unit-test/lc_app_tests.c | 12 ++++++------ unit-test/lc_utils_tests.c | 32 ++++++++++++++++---------------- unit-test/stubs/lc_utils_stubs.c | 10 +++++----- 6 files changed, 36 insertions(+), 33 deletions(-) diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index 81bf085..b77828b 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -169,7 +169,7 @@ void LC_AppMain(void) */ if ((Initialized == true) && (LC_OperData.HaveActiveCDS) && (LC_AppData.CDSSavedOnExit == LC_CDS_SAVED)) { - LC_UpdateTaskCDS(); + LC_SetCDS_Data(); } /* @@ -947,7 +947,7 @@ CFE_Status_t LC_LoadDefaultTables(void) */ if (LC_OperData.HaveActiveCDS) { - if (LC_UpdateTaskCDS() == CFE_SUCCESS) + if (LC_SetCDS_Data() == CFE_SUCCESS) { LC_OperData.TableResults |= LC_CDS_UPDATED; } diff --git a/fsw/src/lc_utils.c b/fsw/src/lc_utils.c index f883795..159d7ca 100644 --- a/fsw/src/lc_utils.c +++ b/fsw/src/lc_utils.c @@ -113,12 +113,13 @@ CFE_Status_t LC_ManageTables(void) /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -CFE_Status_t LC_UpdateTaskCDS(void) +CFE_Status_t LC_SetCDS_Data(void) { CFE_Status_t Status; Status = CFE_SUCCESS; + /* Check whether previous CDS operations were successful */ if (LC_OperData.CDS_Handle != 0) { /* Update CDS data */ @@ -132,7 +133,9 @@ CFE_Status_t LC_UpdateTaskCDS(void) Status = CFE_ES_CopyToCDS(LC_OperData.CDS_Handle, &(LC_OperData.CDS_Data)); if (Status != CFE_SUCCESS) { - LC_OperData.CDS_Handle = 0; + /* Clear out the CDS handle to prevent future use */ + LC_OperData.CDS_Handle = 0; + LC_OperData.HaveActiveCDS = false; CFE_EVS_SendEvent(LC_CDS_NO_SAVE_ERR_EID, CFE_EVS_EventType_ERROR, "Unable to update CDS data results in CDS, RC=0x%08X", @@ -170,7 +173,7 @@ CFE_Status_t LC_PerformMaintenance(void) ** If CDS is enabled - update the 3 CDS areas managed by LC ** (continue, but disable CDS if unable to update all 3) */ - if (LC_UpdateTaskCDS() != CFE_SUCCESS) + if (LC_SetCDS_Data() != CFE_SUCCESS) { LC_OperData.HaveActiveCDS = false; } diff --git a/fsw/src/lc_utils.h b/fsw/src/lc_utils.h index 504cd26..ac2ae96 100644 --- a/fsw/src/lc_utils.h +++ b/fsw/src/lc_utils.h @@ -59,7 +59,7 @@ CFE_Status_t LC_ManageTables(void); * \return Execution status, see \ref CFEReturnCodes * \retval #CFE_SUCCESS \copybrief CFE_SUCCESS */ -CFE_Status_t LC_UpdateTaskCDS(void); +CFE_Status_t LC_SetCDS_Data(void); /** * \brief Perform Routine Maintenance diff --git a/unit-test/lc_app_tests.c b/unit-test/lc_app_tests.c index ef4f08b..c8df510 100644 --- a/unit-test/lc_app_tests.c +++ b/unit-test/lc_app_tests.c @@ -165,16 +165,16 @@ void LC_AppMain_Test_NominalCDSSave(void) /* Cycle through all conditions forced by handler */ LC_AppMain(); - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(LC_UpdateTaskCDS)), 0); + UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(LC_SetCDS_Data)), 0); /* Reset SendEvent to avoid filling buffer */ UT_ResetState(UT_KEY(CFE_EVS_SendEvent)); LC_AppMain(); - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(LC_UpdateTaskCDS)), 0); + UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(LC_SetCDS_Data)), 0); UT_ResetState(UT_KEY(CFE_EVS_SendEvent)); LC_AppMain(); - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(LC_UpdateTaskCDS)), 1); + UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(LC_SetCDS_Data)), 1); } void LC_AppMain_Test_NominalCDSNoSave(void) @@ -199,7 +199,7 @@ void LC_AppMain_Test_NominalCDSNoSave(void) UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(LC_AppPipe)), 1); - UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(LC_UpdateTaskCDS)), 0); + UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(LC_SetCDS_Data)), 0); } void LC_AppMain_Test_AppInitFail(void) @@ -1166,9 +1166,9 @@ void LC_LoadDefaultTables_Test_ActiveCDSNotSuccess(void) /* Set to satisfy all instances of condition "Result == CFE_SUCCESS" after calls to CFE_TBL_GetAddress */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); - /* Set to make subfunction LC_UpdateTaskCDS return -1, in order to satisfy condition "LC_UpdateTaskCDS() == + /* Set to make subfunction LC_SetCDS_Data return -1, in order to satisfy condition "LC_SetCDS_Data() == * CFE_SUCCESS" */ - UT_SetDefaultReturnValue(UT_KEY(LC_UpdateTaskCDS), -1); + UT_SetDefaultReturnValue(UT_KEY(LC_SetCDS_Data), -1); /* Execute the function being tested */ Result = LC_LoadDefaultTables(); diff --git a/unit-test/lc_utils_tests.c b/unit-test/lc_utils_tests.c index 9904a36..a5d0f7e 100644 --- a/unit-test/lc_utils_tests.c +++ b/unit-test/lc_utils_tests.c @@ -151,7 +151,7 @@ void LC_ManageTables_Test_ADTGetAddressError(void) UtAssert_INT32_EQ(call_count_LC_ResetResultsAP, 0); } -void LC_UpdateTaskCDS_Test_UpdateWatchpointError(void) +void LC_SetCDS_Data_Test_UpdateWatchpointError(void) { CFE_Status_t Result; int32 strCmpResult; @@ -165,7 +165,7 @@ void LC_UpdateTaskCDS_Test_UpdateWatchpointError(void) UT_SetDefaultReturnValue(UT_KEY(CFE_ES_CopyToCDS), -1); /* Execute the function being tested */ - Result = LC_UpdateTaskCDS(); + Result = LC_SetCDS_Data(); /* Verify results */ UtAssert_True(Result == -1, "Result == -1"); @@ -179,7 +179,7 @@ void LC_UpdateTaskCDS_Test_UpdateWatchpointError(void) UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); } -void LC_UpdateTaskCDS_Test_UpdateActionpointError(void) +void LC_SetCDS_Data_Test_UpdateActionpointError(void) { CFE_Status_t Result; int32 strCmpResult; @@ -193,7 +193,7 @@ void LC_UpdateTaskCDS_Test_UpdateActionpointError(void) UT_SetDeferredRetcode(UT_KEY(CFE_ES_CopyToCDS), 2, -1); /* Execute the function being tested */ - Result = LC_UpdateTaskCDS(); + Result = LC_SetCDS_Data(); /* Verify results */ UtAssert_True(Result == -1, "Result == -1"); @@ -206,7 +206,7 @@ void LC_UpdateTaskCDS_Test_UpdateActionpointError(void) UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); } -void LC_UpdateTaskCDS_Test_UpdateAppDataError(void) +void LC_SetCDS_Data_Test_UpdateAppDataError(void) { CFE_Status_t Result; int32 strCmpResult; @@ -220,7 +220,7 @@ void LC_UpdateTaskCDS_Test_UpdateAppDataError(void) UT_SetDeferredRetcode(UT_KEY(CFE_ES_CopyToCDS), 3, -1); /* Execute the function being tested */ - Result = LC_UpdateTaskCDS(); + Result = LC_SetCDS_Data(); /* Verify results */ UtAssert_True(Result == -1, "Result == -1"); @@ -235,12 +235,12 @@ void LC_UpdateTaskCDS_Test_UpdateAppDataError(void) UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec); } -void LC_UpdateTaskCDS_Test_Nominal(void) +void LC_SetCDS_Data_Test_Nominal(void) { CFE_Status_t Result; /* Execute the function being tested */ - Result = LC_UpdateTaskCDS(); + Result = LC_SetCDS_Data(); /* Verify results */ UtAssert_True(Result == CFE_SUCCESS, "Result == CFE_SUCCESS"); @@ -293,7 +293,7 @@ void LC_PerformMaintenance_Test_UpdateCDSFail(void) /* force LC_ManageTables to succeed */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); - /* force LC_UpdateTaskCDS to fail */ + /* force LC_SetCDS_Data to fail */ UT_SetDefaultReturnValue(UT_KEY(CFE_ES_CopyToCDS), -1); /* Execute the function being tested */ @@ -332,19 +332,19 @@ void UtTest_Setup(void) LC_Test_TearDown, "LC_ManageTables_Test_ADTGetAddressError"); - UtTest_Add(LC_UpdateTaskCDS_Test_UpdateWatchpointError, + UtTest_Add(LC_SetCDS_Data_Test_UpdateWatchpointError, LC_Test_Setup, LC_Test_TearDown, - "LC_UpdateTaskCDS_Test_UpdateWatchpointError"); - UtTest_Add(LC_UpdateTaskCDS_Test_UpdateActionpointError, + "LC_SetCDS_Data_Test_UpdateWatchpointError"); + UtTest_Add(LC_SetCDS_Data_Test_UpdateActionpointError, LC_Test_Setup, LC_Test_TearDown, - "LC_UpdateTaskCDS_Test_UpdateActionpointError"); - UtTest_Add(LC_UpdateTaskCDS_Test_UpdateAppDataError, + "LC_SetCDS_Data_Test_UpdateActionpointError"); + UtTest_Add(LC_SetCDS_Data_Test_UpdateAppDataError, LC_Test_Setup, LC_Test_TearDown, - "LC_UpdateTaskCDS_Test_UpdateAppDataError"); - UtTest_Add(LC_UpdateTaskCDS_Test_Nominal, LC_Test_Setup, LC_Test_TearDown, "LC_UpdateTaskCDS_Test_Nominal"); + "LC_SetCDS_Data_Test_UpdateAppDataError"); + UtTest_Add(LC_SetCDS_Data_Test_Nominal, LC_Test_Setup, LC_Test_TearDown, "LC_SetCDS_Data_Test_Nominal"); UtTest_Add(LC_PerformMaintenance_Test_NominalNoCDS, LC_Test_Setup, diff --git a/unit-test/stubs/lc_utils_stubs.c b/unit-test/stubs/lc_utils_stubs.c index b633691..aad7d48 100644 --- a/unit-test/stubs/lc_utils_stubs.c +++ b/unit-test/stubs/lc_utils_stubs.c @@ -55,14 +55,14 @@ CFE_Status_t LC_PerformMaintenance(void) /* * ---------------------------------------------------- - * Generated stub function for LC_UpdateTaskCDS() + * Generated stub function for LC_SetCDS_Data() * ---------------------------------------------------- */ -CFE_Status_t LC_UpdateTaskCDS(void) +CFE_Status_t LC_SetCDS_Data(void) { - UT_GenStub_SetupReturnBuffer(LC_UpdateTaskCDS, CFE_Status_t); + UT_GenStub_SetupReturnBuffer(LC_SetCDS_Data, CFE_Status_t); - UT_GenStub_Execute(LC_UpdateTaskCDS, Basic, NULL); + UT_GenStub_Execute(LC_SetCDS_Data, Basic, NULL); - return UT_GenStub_GetReturnValue(LC_UpdateTaskCDS, CFE_Status_t); + return UT_GenStub_GetReturnValue(LC_SetCDS_Data, CFE_Status_t); } From c45bdc71d9bb16b4e02b73b89e4b836a0d0b0c24 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 15:46:52 -0500 Subject: [PATCH 07/13] Issue #159, Remove unused events --- fsw/inc/lc_eventids.h | 170 +++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 110 deletions(-) diff --git a/fsw/inc/lc_eventids.h b/fsw/inc/lc_eventids.h index 02b62c5..0fd5aa3 100644 --- a/fsw/inc/lc_eventids.h +++ b/fsw/inc/lc_eventids.h @@ -171,40 +171,16 @@ #define LC_ART_REGISTER_ERR_EID 11 /** - * \brief LC Watchpoint Result Table CDS Registration Failed Event ID + * \brief LC CDS Registration Failed Event ID * * \par Type: ERROR * * \par Cause: * - * This event message is issued when the CDS area for the - * watchpoint results table (WRT) data could not be registered. + * This event message is issued when the CDS area data + * could not be registered. */ -#define LC_WRT_CDS_REGISTER_ERR_EID 12 - -/** - * \brief LC Actionpoint Result Table CDS Registration Failed Event ID - * - * \par Type: ERROR - * - * \par Cause: - * - * This event message is issued when the CDS area for the - * actionpont results table (ART) data could not be registered. - */ -#define LC_ART_CDS_REGISTER_ERR_EID 13 - -/** - * \brief LC Application Data CDS Registration Failed Event ID - * - * \par Type: ERROR - * - * \par Cause: - * - * This event message is issued when the CDS area for the - * LC application data could not be registered. - */ -#define LC_APP_CDS_REGISTER_ERR_EID 14 +#define LC_CDS_REGISTER_ERR_EID 12 /** * \brief LC Watchpoint Definition Table Load From File Failed Event ID @@ -217,7 +193,7 @@ * loading the watchpoint definition table (WDT) from the default * file image */ -#define LC_WDT_LOAD_ERR_EID 15 +#define LC_WDT_LOAD_ERR_EID 13 /** * \brief LC Actionpoint Definition Table Load From File Failed Event ID @@ -230,7 +206,7 @@ * loading the actionpoint definition table (ADT) from the default * file image */ -#define LC_ADT_LOAD_ERR_EID 16 +#define LC_ADT_LOAD_ERR_EID 14 /** * \brief LC Watchpoint Result Table Get Address Failed Event ID @@ -242,7 +218,7 @@ * This event message is issued when the address can't be obtained * from table services for the watchpoint results table (WRT). */ -#define LC_WRT_GETADDR_ERR_EID 17 +#define LC_WRT_GETADDR_ERR_EID 15 /** * \brief LC Actionpoint Result Table Get Address Failed Event ID @@ -254,7 +230,7 @@ * This event message is issued when the address can't be obtained * from table services for the actionpoint results table (ART). */ -#define LC_ART_GETADDR_ERR_EID 18 +#define LC_ART_GETADDR_ERR_EID 16 /** * \brief LC Watchpoint Definition Table Get Address Failed Event ID @@ -266,7 +242,7 @@ * This event message is issued when the address can't be obtained * from table services for the watchpoint definition table (WDT). */ -#define LC_WDT_GETADDR_ERR_EID 19 +#define LC_WDT_GETADDR_ERR_EID 17 /** * \brief LC Actionpoint Definition Table Get Address Failed Event ID @@ -278,7 +254,7 @@ * This event message is issued when the address can't be obtained * from table services for the actionpoint definition table (ADT). */ -#define LC_ADT_GETADDR_ERR_EID 20 +#define LC_ADT_GETADDR_ERR_EID 18 /** * \brief LC State Restored From CDS Event ID @@ -300,7 +276,7 @@ * * \sa LC_SAVE_TO_CDS, #LC_CDS_UPDATED_INF_EID, #LC_CDS_DISABLED_INF_EID */ -#define LC_CDS_RESTORED_INF_EID 21 +#define LC_CDS_RESTORED_INF_EID 19 /** * \brief LC Default State Initialized and Stored to CDS Event ID @@ -328,7 +304,7 @@ * * \sa LC_SAVE_TO_CDS, #LC_CDS_RESTORED_INF_EID, #LC_CDS_DISABLED_INF_EID */ -#define LC_CDS_UPDATED_INF_EID 22 +#define LC_CDS_UPDATED_INF_EID 20 /** * \brief LC Use Of CDS Disabled Event ID @@ -353,7 +329,7 @@ * * \sa LC_SAVE_TO_CDS, #LC_CDS_RESTORED_INF_EID, #LC_CDS_UPDATED_INF_EID */ -#define LC_CDS_DISABLED_INF_EID 23 +#define LC_CDS_DISABLED_INF_EID 21 /** * \brief LC Command Code Invalid Event ID @@ -365,7 +341,7 @@ * This event message is issued when a software bus message is received * with an invalid command code. */ -#define LC_CC_ERR_EID 24 +#define LC_CC_ERR_EID 22 /** * \brief LC Sample Actionpoint Message Start Or End Number Invalid Event ID @@ -377,7 +353,7 @@ * This event message is issued when the #LC_SAMPLE_AP_MID message * has been received with an invalid actionpoint start or end number specified */ -#define LC_APSAMPLE_APNUM_ERR_EID 25 +#define LC_APSAMPLE_APNUM_ERR_EID 23 /** * \brief LC No-op Command Event ID @@ -388,7 +364,7 @@ * * This event message is issued when a NOOP command has been received. */ -#define LC_NOOP_INF_EID 26 +#define LC_NOOP_INF_EID 24 /** * \brief LC Reset Counters Command Event ID @@ -400,7 +376,7 @@ * This event message is issued when a reset counters command has * been received. */ -#define LC_RESET_INF_EID 27 +#define LC_RESET_INF_EID 25 /** * \brief LC Set Limit Checker State Command Event ID @@ -412,7 +388,7 @@ * This event message is issued when the #LC_SET_LC_STATE_CC command * has been successfully executed */ -#define LC_LCSTATE_INF_EID 28 +#define LC_LCSTATE_INF_EID 26 /** * \brief LC Set Limit Checker State, State Invalid Event ID @@ -424,7 +400,7 @@ * This event message is issued when the #LC_SET_LC_STATE_CC command * has been received with an invalid state argument specified */ -#define LC_LCSTATE_ERR_EID 29 +#define LC_LCSTATE_ERR_EID 27 /** * \brief LC Set Actionpoint State New State Invalid Event ID @@ -436,7 +412,7 @@ * This event message is issued when the #LC_SET_AP_STATE_CC command * has been received with an invalid state argument specified */ -#define LC_APSTATE_NEW_ERR_EID 30 +#define LC_APSTATE_NEW_ERR_EID 28 /** * \brief LC Set Actionpoint State Current State Invalid Event ID @@ -450,7 +426,7 @@ * #LC_APSTATE_NOT_USED or #LC_APSTATE_PERMOFF which can only be changed * with a table load. */ -#define LC_APSTATE_CURR_ERR_EID 31 +#define LC_APSTATE_CURR_ERR_EID 29 /** * \brief LC Set Actionpoint State Actionpoint Number Invalid Event ID @@ -462,7 +438,7 @@ * This event message is issued when the #LC_SET_AP_STATE_CC command * has been received with an invalid actionpoint number specified */ -#define LC_APSTATE_APNUM_ERR_EID 32 +#define LC_APSTATE_APNUM_ERR_EID 30 /** * \brief LC Set Actionpoint State Command Event ID @@ -474,7 +450,7 @@ * This event message is issued when the #LC_SET_AP_STATE_CC command * has been successfully executed */ -#define LC_APSTATE_INF_EID 33 +#define LC_APSTATE_INF_EID 31 /** * \brief LC Set Actionpoint Permanently Off Actionpoint Number Invalid Event ID @@ -486,7 +462,7 @@ * This event message is issued when the #LC_SET_AP_PERM_OFF_CC command * has been received with an invalid actionpoint number specified */ -#define LC_APOFF_APNUM_ERR_EID 34 +#define LC_APOFF_APNUM_ERR_EID 32 /** * \brief LC Set Actionpoint Permanently Off Actionpoint Not Disabled Event ID @@ -499,7 +475,7 @@ * has been received and the current actionpoint state is not * #LC_APSTATE_DISABLED */ -#define LC_APOFF_CURR_ERR_EID 35 +#define LC_APOFF_CURR_ERR_EID 33 /** * \brief LC Set Actionpoint Permanently Off Command Event ID @@ -511,7 +487,7 @@ * This event message is issued when the #LC_SET_AP_PERM_OFF_CC command * has been successfully executed */ -#define LC_APOFF_INF_EID 36 +#define LC_APOFF_INF_EID 34 /** * \brief LC Reset Actionpoint Stats Actionpoint Number Invalid Event ID @@ -523,7 +499,7 @@ * This event message is issued when the #LC_RESET_AP_STATS_CC command * has been received with an invalid actionpoint number specified */ -#define LC_APSTATS_APNUM_ERR_EID 37 +#define LC_APSTATS_APNUM_ERR_EID 35 /** * \brief LC Reset Actionpoint Stats Command Event ID @@ -535,7 +511,7 @@ * This event message is issued when the #LC_RESET_AP_STATS_CC command * has been successfully executed */ -#define LC_APSTATS_INF_EID 38 +#define LC_APSTATS_INF_EID 36 /** * \brief LC Reset Watchpoint Stats Watchpoint Number Invalid Event ID @@ -547,7 +523,7 @@ * This event message is issued when the #LC_RESET_WP_STATS_CC command * has been received with an invalid watchpoint number specified */ -#define LC_WPSTATS_WPNUM_ERR_EID 39 +#define LC_WPSTATS_WPNUM_ERR_EID 37 /** * \brief LC Reset Watchpoint Stats Command Event ID @@ -559,7 +535,7 @@ * This event message is issued when the #LC_RESET_WP_STATS_CC command * has been successfully executed */ -#define LC_WPSTATS_INF_EID 40 +#define LC_WPSTATS_INF_EID 38 /** * \brief LC Housekeeping Request Message Length Invalid Event ID @@ -571,7 +547,7 @@ * This event message is issued when a housekeeping request is received * with a message length that doesn't match the expected value. */ -#define LC_HKREQ_LEN_ERR_EID 41 +#define LC_HKREQ_LEN_ERR_EID 39 /** * \brief LC Actionpoint Sample Message Length Invalid Event ID @@ -583,7 +559,7 @@ * This event message is issued when an actionpoint sample request is received * with a message length that doesn't match the expected value. */ -#define LC_APSAMPLE_LEN_ERR_EID 42 +#define LC_APSAMPLE_LEN_ERR_EID 40 /** * \brief LC Command Message Length Invalid Event ID @@ -595,7 +571,7 @@ * This event message is issued when a ground command message is received * with a message length that doesn't match the expected value. */ -#define LC_CMD_LEN_ERR_EID 43 +#define LC_CMD_LEN_ERR_EID 41 /** * \brief LC Watchpoint Message Unsubscribe Failed Event ID @@ -607,7 +583,7 @@ * This event message is issued when an error is encountered * unsubscribing to a watchpoint message ID */ -#define LC_UNSUB_WP_ERR_EID 44 +#define LC_UNSUB_WP_ERR_EID 42 /** * \brief LC Watchpoint Message Subscribe Failed Event ID @@ -619,45 +595,19 @@ * This event message is issued when an error is encountered * when subscribing to a watchpoint message iD */ -#define LC_SUB_WP_ERR_EID 45 - -/** - * \brief LC Watchpoint Results Table Not Saved To CDS On Exit Event ID - * - * \par Type: ERROR - * - * \par Cause: - * - * This event message is issued when the watchpoint results - * table (WRT) data could not be saved to the CDS on application - * exit. - */ -#define LC_WRT_NO_SAVE_ERR_EID 46 - -/** - * \brief LC Actionpoint Results Table Not Saved To CDS On Exit Event ID - * - * \par Type: ERROR - * - * \par Cause: - * - * This event message is issued when the actionpoint results - * table (ART) data could not be saved to the CDS on application - * exit. - */ -#define LC_ART_NO_SAVE_ERR_EID 47 +#define LC_SUB_WP_ERR_EID 43 /** - * \brief LC Application Data Not Saved To CDS On Startup Event ID + * \brief LC CDS Data Not Saved To CDS On Exit Event ID * * \par Type: ERROR * * \par Cause: * - * This event message is issued when the LC application data - * could not be saved to the CDS on application startup. + * This event message is issued when the CDS data + * could not be saved to the CDS on application exit. */ -#define LC_APP_NO_SAVE_START_ERR_EID 48 +#define LC_CDS_NO_SAVE_ERR_EID 44 /** * \brief LC Unreferenced Message ID Received Event ID @@ -670,7 +620,7 @@ * been received that isn't a recognized LC message and has no * defined watchpoints referencing it's message ID */ -#define LC_MID_INF_EID 49 +#define LC_MID_INF_EID 45 /** * \brief LC Watchpoint Data Type Undefined Event ID @@ -682,7 +632,7 @@ * This event message is issued whenever an undefined watchpoint data type * identifier is detected */ -#define LC_WP_DATATYPE_ERR_EID 50 +#define LC_WP_DATATYPE_ERR_EID 46 /** * \brief LC Watchpoint Operator ID Invalid Event ID @@ -694,7 +644,7 @@ * This event message is issued whenever an undefined watchpoint * operator identifier is detected */ -#define LC_WP_OPERID_ERR_EID 51 +#define LC_WP_OPERID_ERR_EID 47 /** * \brief LC Watchpoint Data Value Is Float NAN Event ID @@ -707,7 +657,7 @@ * type, but the extracted value would equate to a floating point * NAN (not-a-number) value */ -#define LC_WP_NAN_ERR_EID 52 +#define LC_WP_NAN_ERR_EID 48 /** * \brief LC Watchpoint Offset Value Invalid Event ID @@ -720,7 +670,7 @@ * the end of the message as reported by the #CFE_MSG_GetSize * function */ -#define LC_WP_OFFSET_ERR_EID 53 +#define LC_WP_OFFSET_ERR_EID 49 /** * \brief LC Watchpoint Definition Table Validation Floating Point Check Failed Event ID @@ -735,7 +685,7 @@ * for a wachpoint definition is floating point and the comparison value * equates to a floating point NAN (not-a-number) or infinite value. */ -#define LC_WDTVAL_FPERR_EID 54 +#define LC_WDTVAL_FPERR_EID 50 /** * \brief LC Watchpoint Definition Table Validation Failed (Not Floating Point Check) Event ID @@ -748,7 +698,7 @@ * fails for a watchpoint definition table (WDT) load and the error is * NOT a failed floating point check. */ -#define LC_WDTVAL_ERR_EID 55 +#define LC_WDTVAL_ERR_EID 51 /** * \brief LC Watchpoint Definition Table Validation Results Event ID @@ -760,7 +710,7 @@ * This event message is issued when a table validation has been * completed for a watchpoint definition table (WDT) load */ -#define LC_WDTVAL_INF_EID 56 +#define LC_WDTVAL_INF_EID 52 /** * \brief LC Sample Actionpoint Current Actionpoint State Invalid Event ID @@ -773,7 +723,7 @@ * has been received and the current state for the specified * actionpoint state is either #LC_APSTATE_NOT_USED or #LC_APSTATE_PERMOFF. */ -#define LC_APSAMPLE_CURR_ERR_EID 57 +#define LC_APSAMPLE_CURR_ERR_EID 53 /** * \brief LC Actionpoint State Change From PASS To FAIL Event ID @@ -785,7 +735,7 @@ * This event message is issued when an actionpoint evaluation transitions * from #LC_ACTION_PASS to #LC_ACTION_FAIL */ -#define LC_AP_PASSTOFAIL_INF_EID 58 +#define LC_AP_PASSTOFAIL_INF_EID 54 /** * \brief LC Actionpoint Failed While Limit Checker State Passive Event ID @@ -797,7 +747,7 @@ * This event message is issued when an actionpoint fails evaluation while * the LC task operating state is #LC_STATE_PASSIVE */ -#define LC_PASSIVE_FAIL_DBG_EID 59 +#define LC_PASSIVE_FAIL_DBG_EID 55 /** * \brief LC Actionpoint Failed While Actionpoint State Passive Event ID @@ -809,7 +759,7 @@ * This event message is issued when an actionpoint fails evaluation while * the actionpoint state is #LC_APSTATE_PASSIVE */ -#define LC_AP_PASSIVE_FAIL_INF_EID 60 +#define LC_AP_PASSIVE_FAIL_INF_EID 56 /** * \brief LC Actionpoint State Change From FAIL To PASS Event ID @@ -821,7 +771,7 @@ * This event message is issued when an actionpoint evaluation transitions * from #LC_ACTION_FAIL to #LC_ACTION_PASS */ -#define LC_AP_FAILTOPASS_INF_EID 61 +#define LC_AP_FAILTOPASS_INF_EID 57 /** * \brief LC Actionpoint Evaluated To Error Event ID @@ -833,7 +783,7 @@ * This event message is issued when an actionpoint evaluation * results in #LC_ACTION_ERROR */ -#define LC_ACTION_ERROR_ERR_EID 62 +#define LC_ACTION_ERROR_ERR_EID 58 /** * \brief LC Actionpoint RPN Expression Illegal Event ID @@ -845,7 +795,7 @@ * This event message is issued when an illegal Reverse Polish Notation * (RPN) expression is detected during an actionpoint evaluation */ -#define LC_INVALID_RPN_ERR_EID 63 +#define LC_INVALID_RPN_ERR_EID 59 /** * \brief LC Actionpoint Definition Table Validation RPN Equation Check Failed Event ID @@ -858,7 +808,7 @@ * fails for an actionpoint definition table (ADT) load and the error is * a failed RPN equation check. */ -#define LC_ADTVAL_RPNERR_EID 64 +#define LC_ADTVAL_RPNERR_EID 60 /** * \brief LC Actionpoint Definition Table Validation Failed (Not RPN Equation Check) Event ID @@ -871,7 +821,7 @@ * fails for an actioinpoint definition table (ADT) load and the error is * NOT a failed RPN equation check. */ -#define LC_ADTVAL_ERR_EID 65 +#define LC_ADTVAL_ERR_EID 61 /** * \brief LC Actionpoint Definition Table Validation Result Event ID @@ -883,7 +833,7 @@ * This event message is issued when a table validation has been * completed for an actionpoint definition table (ADT) load */ -#define LC_ADTVAL_INF_EID 66 +#define LC_ADTVAL_INF_EID 62 /** * \brief LC LC_CustomFunction Called With Unexpected Watchpoint ID Event ID @@ -896,7 +846,7 @@ * function #LC_CustomFunction is called with an unexpected * watchpoint ID */ -#define LC_CFCALL_ERR_EID 67 +#define LC_CFCALL_ERR_EID 63 /** * \brief LC Watchdog Definition Table Critical Table Registration Failed Event ID @@ -908,7 +858,7 @@ * This event message is issued when the watchpoint definition * table (WDT) could not be registered as a critical table. */ -#define LC_WDT_REGISTER_CRIT_ERR_EID 68 +#define LC_WDT_REGISTER_CRIT_ERR_EID 64 /** * \brief LC Actionpoint Definition Table Critical Table Registration Failed Event ID @@ -920,7 +870,7 @@ * This event message is issued when the actionpoint definition * table (ADT) could not be registered as a critical table. */ -#define LC_ADT_REGISTER_CRIT_ERR_EID 69 +#define LC_ADT_REGISTER_CRIT_ERR_EID 65 /** * \brief LC Actionpoint Definition Table Base ID From cfbfe38c284f8fad469cd97488845b503f74a103 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 15:50:23 -0500 Subject: [PATCH 08/13] Issue #159, Keep (most) HaveActiveCDS manipulation in CDS accessor and mutator --- fsw/src/lc_app.c | 8 -------- fsw/src/lc_utils.c | 15 ++------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index b77828b..f5dc0df 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -410,10 +410,6 @@ CFE_Status_t LC_TableInit(void) if (LC_OperData.HaveActiveCDS) { Result = LC_GetCDS_Data(); - if (Result != CFE_SUCCESS) - { - LC_OperData.HaveActiveCDS = false; - } } /* ** Create wp/ap definition tables - critical if CDS enabled @@ -951,10 +947,6 @@ CFE_Status_t LC_LoadDefaultTables(void) { LC_OperData.TableResults |= LC_CDS_UPDATED; } - else - { - LC_OperData.HaveActiveCDS = false; - } } } diff --git a/fsw/src/lc_utils.c b/fsw/src/lc_utils.c index 159d7ca..750cfe2 100644 --- a/fsw/src/lc_utils.c +++ b/fsw/src/lc_utils.c @@ -164,20 +164,9 @@ CFE_Status_t LC_PerformMaintenance(void) ** (an error here is fatal - LC must be able to access its tables) */ Result = LC_ManageTables(); - - if (Result == CFE_SUCCESS) + if (Result == CFE_SUCCESS && LC_OperData.HaveActiveCDS) { - if (LC_OperData.HaveActiveCDS) - { - /* - ** If CDS is enabled - update the 3 CDS areas managed by LC - ** (continue, but disable CDS if unable to update all 3) - */ - if (LC_SetCDS_Data() != CFE_SUCCESS) - { - LC_OperData.HaveActiveCDS = false; - } - } + LC_SetCDS_Data(); } return Result; From 03767e212fd5178256fd072b4fef9cc27d11f3da Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 16:37:46 -0500 Subject: [PATCH 09/13] Issue #159, Remove LC_OperData.TableResults from LC_TableInit() --- fsw/src/lc_app.c | 186 ++++++++++------------------------------------- 1 file changed, 39 insertions(+), 147 deletions(-) diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index f5dc0df..9500cc7 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -349,172 +349,64 @@ CFE_Status_t LC_SbInit(void) CFE_Status_t LC_TableInit(void) { - CFE_Status_t Result; - -/* -** LC task use of Critical Data Store (CDS) -** -** Global application data (LC_AppData) -** Watchpoint results dump only table data -** Actionpoint results dump only table data -** -** cFE Table Services use of CDS for LC task -** -** Watchpoint definition loadable table data -** Actionpoint definition loadable table data -** -** LC table initialization logic re CDS -** -** If LC cannot create all the CDS storage at startup, then LC -** will disable LC use of CDS and continue. -** -** If LC cannot register definition tables as critical, then LC -** will disable LC use of CDS and re-register tables as non-critical. -** -** If LC cannot register definition and results tables at startup, -** then LC will terminate - table use is a required function. -** -** If LC can create all the CDS storage and register definition -** tables as critical, then LC will write to CDS regardless of -** whether LC was able to read from CDS at startup. -** -** If LC cannot restore everything from CDS at startup, then LC -** will initialize everything - load default definition tables, -** init results table contents, init global application data. -*/ + /* + ** LC task use of Critical Data Store (CDS) + ** + ** Global application data (LC_AppData) + ** Watchpoint results dump only table data + ** Actionpoint results dump only table data + ** + ** cFE Table Services use of CDS for LC task + ** + ** Watchpoint definition loadable table data + ** Actionpoint definition loadable table data + ** + ** LC table initialization logic re CDS + ** + ** If LC cannot create all the CDS storage at startup, then LC + ** will disable LC use of CDS and continue. + ** + ** If LC cannot register definition tables as critical, then LC + ** will disable LC use of CDS and re-register tables as non-critical. + ** + ** If LC cannot register definition and results tables at startup, + ** then LC will terminate - table use is a required function. + ** + ** If LC can create all the CDS storage and register definition + ** tables as critical, then LC will write to CDS regardless of + ** whether LC was able to read from CDS at startup. + ** + ** If LC cannot restore everything from CDS at startup, then LC + ** will initialize everything - load default definition tables, + ** init results table contents, init global application data. + */ /* lc_platform_cfg.h */ #ifdef LC_SAVE_TO_CDS LC_OperData.HaveActiveCDS = true; #endif - /* - ** Maintain a detailed record of table initialization results - */ - if (LC_OperData.HaveActiveCDS) - { - LC_OperData.TableResults |= LC_CDS_ENABLED; - } + CFE_Status_t Status; - /* - ** Create watchpoint and actionpoint result tables - */ - Result = LC_CreateResultTables(); + /* Create watchpoint and actionpoint result tables */ + Status = LC_CreateResultTables(); /* ** If CDS is enabled - create the 3 CDS areas managed by the LC task ** (continue with init, but disable CDS if unable to create all 3) */ - if (Result == CFE_SUCCESS) + if (Status == CFE_SUCCESS) { if (LC_OperData.HaveActiveCDS) { - Result = LC_GetCDS_Data(); + (void)LC_GetCDS_Data(); } - /* - ** Create wp/ap definition tables - critical if CDS enabled - */ - Result = LC_CreateDefinitionTables(); - } - /* - ** CDS still active only if we created 3 CDS areas and 2 critical tables - */ - if ((Result == CFE_SUCCESS) && (LC_OperData.HaveActiveCDS)) - { - LC_OperData.TableResults |= LC_CDS_CREATED; + /* Create wp/ap definition tables - critical if CDS enabled */ + Status = LC_CreateDefinitionTables(); } - /* - ** If any CDS area or critical table is not restored - initialize everything. - ** (might be due to reset type, CDS disabled or corrupt, table restore error) - */ - if (Result == CFE_SUCCESS) - { - if (((LC_OperData.TableResults & LC_WRT_CDS_RESTORED) == LC_WRT_CDS_RESTORED) - && ((LC_OperData.TableResults & LC_ART_CDS_RESTORED) == LC_ART_CDS_RESTORED) - && ((LC_OperData.TableResults & LC_APP_CDS_RESTORED) == LC_APP_CDS_RESTORED) - && ((LC_OperData.TableResults & LC_WDT_TBL_RESTORED) == LC_WDT_TBL_RESTORED) - && ((LC_OperData.TableResults & LC_ADT_TBL_RESTORED) == LC_ADT_TBL_RESTORED)) - { - LC_OperData.TableResults |= LC_CDS_RESTORED; - - /* - ** Get a pointer to the watchpoint definition table data... - */ - Result = CFE_TBL_GetAddress((void *)&LC_OperData.WDTPtr, LC_OperData.WDTHandle); - - if ((Result != CFE_SUCCESS) && (Result != CFE_TBL_INFO_UPDATED)) - { - CFE_EVS_SendEvent(LC_WDT_GETADDR_ERR_EID, - CFE_EVS_EventType_ERROR, - "Error getting WDT address, RC=0x%08X", - (unsigned int)Result); - } - - /* - ** Get a pointer to the actionpoint definition table data - */ - if ((Result == CFE_SUCCESS) || (Result == CFE_TBL_INFO_UPDATED)) - { - Result = CFE_TBL_GetAddress((void *)&LC_OperData.ADTPtr, LC_OperData.ADTHandle); - - if ((Result != CFE_SUCCESS) && (Result != CFE_TBL_INFO_UPDATED)) - { - CFE_EVS_SendEvent(LC_ADT_GETADDR_ERR_EID, - CFE_EVS_EventType_ERROR, - "Error getting ADT address, RC=0x%08X", - (unsigned int)Result); - } - } - } - else - { - Result = LC_LoadDefaultTables(); - } - - if (Result == CFE_TBL_INFO_UPDATED) - { - Result = CFE_SUCCESS; - } - } - - /* - ** Create watchpoint hash tables -- also subscribes to watchpoint packets - */ - if (Result == CFE_SUCCESS) - { - LC_CreateHashTable(); - - /* - ** Display results of CDS initialization (if enabled at startup) - */ - if ((LC_OperData.TableResults & LC_CDS_ENABLED) == LC_CDS_ENABLED) - { - if ((LC_OperData.TableResults & LC_CDS_RESTORED) == LC_CDS_RESTORED) - { - CFE_EVS_SendEvent(LC_CDS_RESTORED_INF_EID, - CFE_EVS_EventType_INFORMATION, - "Previous state restored from Critical Data Store"); - } - else if ((LC_OperData.TableResults & LC_CDS_UPDATED) == LC_CDS_UPDATED) - { - CFE_EVS_SendEvent(LC_CDS_UPDATED_INF_EID, - CFE_EVS_EventType_INFORMATION, - "Default state loaded and written to CDS, activity mask = 0x%08X", - (unsigned int)LC_OperData.TableResults); - } - } - else - { - CFE_EVS_SendEvent(LC_CDS_DISABLED_INF_EID, - CFE_EVS_EventType_INFORMATION, - "LC use of Critical Data Store disabled, activity mask = 0x%08X", - (unsigned int)LC_OperData.TableResults); - } - } - - return Result; + return Status; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ From 08683d07a7a5220c944ce89831435663e7ab9ab6 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 16:38:26 -0500 Subject: [PATCH 10/13] Issue #159, CDS data will always need to be restored so move operations to CDS accessor --- fsw/src/lc_app.c | 41 +++++++++++++++++++++++++++++++++-------- fsw/src/lc_utils.c | 2 +- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index 9500cc7..5dbc76d 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -669,19 +669,17 @@ CFE_Status_t LC_GetCDS_Data(void) /* Default to active CDS */ LC_OperData.HaveActiveCDS = true; - /* - ** Create CDS and try to restore data - */ + /* Create CDS and try to restore data */ Status = CFE_ES_RegisterCDS(&LC_OperData.CDS_Handle, sizeof(LC_CDS_Data_t), LC_CDS_NAME); if (Status == CFE_SUCCESS) { - /* Initialize CDS data */ + /* + ** If any CDS area or critical table is not restored - initialize everything. + ** (might be due to reset type, CDS disabled or corrupt, table restore error) + */ memset(&LC_OperData.CDS_Data.HkPacket, 0, sizeof(LC_HkPacket_t)); - LC_OperData.CDS_Data.WDTPtr = NULL; - LC_OperData.CDS_Data.WRTPtr = NULL; - LC_OperData.CDS_Data.ADTPtr = NULL; - LC_OperData.CDS_Data.ARTPtr = NULL; + Status = LC_LoadDefaultTables(); } else if (Status == CFE_ES_CDS_ALREADY_EXISTS) { @@ -700,6 +698,33 @@ CFE_Status_t LC_GetCDS_Data(void) LC_OperData.ADTPtr = LC_OperData.CDS_Data.ADTPtr; LC_OperData.ARTPtr = LC_OperData.CDS_Data.ARTPtr; + Status = CFE_TBL_GetAddress((void *)&LC_OperData.WDTPtr, LC_OperData.WDTHandle); + if ((Status != CFE_SUCCESS) && (Status != CFE_TBL_INFO_UPDATED)) + { + CFE_EVS_SendEvent(LC_WDT_GETADDR_ERR_EID, + CFE_EVS_EventType_ERROR, + "Error getting WDT address, RC=0x%08X", + (unsigned int)Status); + } + } + + if ((Status == CFE_SUCCESS) || (Status == CFE_TBL_INFO_UPDATED)) + { + /* Update values in table */ + LC_CreateHashTable(); + + Status = CFE_TBL_GetAddress((void *)&LC_OperData.ADTPtr, LC_OperData.ADTHandle); + if ((Status != CFE_SUCCESS) && (Status != CFE_TBL_INFO_UPDATED)) + { + CFE_EVS_SendEvent(LC_ADT_GETADDR_ERR_EID, + CFE_EVS_EventType_ERROR, + "Error getting ADT address, RC=0x%08X", + (unsigned int)Status); + } + } + + if ((Status == CFE_SUCCESS) || (Status == CFE_TBL_INFO_UPDATED)) + { CFE_EVS_SendEvent(LC_CDS_RESTORED_INF_EID, CFE_EVS_EventType_INFORMATION, "Previous state restored from Critical Data Store"); diff --git a/fsw/src/lc_utils.c b/fsw/src/lc_utils.c index 750cfe2..306b986 100644 --- a/fsw/src/lc_utils.c +++ b/fsw/src/lc_utils.c @@ -120,7 +120,7 @@ CFE_Status_t LC_SetCDS_Data(void) Status = CFE_SUCCESS; /* Check whether previous CDS operations were successful */ - if (LC_OperData.CDS_Handle != 0) + if (LC_OperData.CDS_Handle != 0 && LC_OperData.HaveActiveCDS) { /* Update CDS data */ memcpy(&(LC_OperData.CDS_Data.HkPacket), &(LC_OperData.HkPacket), sizeof(LC_HkPacket_t)); From 1c24aba7b6d26442eab29246eaeaccbfcc51d404 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 16:36:23 -0500 Subject: [PATCH 11/13] Issue #159, Remove LC_OperData.TableResults from LC_CreateResultTables() --- fsw/src/lc_app.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index 5dbc76d..5082a32 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -454,8 +454,6 @@ CFE_Status_t LC_CreateResultTables(void) if (Result == CFE_SUCCESS) { - LC_OperData.TableResults |= LC_WRT_TBL_CREATED; - /* ** Register the Actionpoint Results Table (ART) - "dump only" tables ** cannot be critical with CDS use managed by CFE Table Services. @@ -484,11 +482,6 @@ CFE_Status_t LC_CreateResultTables(void) } } - if (Result == CFE_SUCCESS) - { - LC_OperData.TableResults |= LC_ART_TBL_CREATED; - } - return Result; } From 18ed02e759cc22d919e2a64a72aa0b0eff9f87b9 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 16:36:46 -0500 Subject: [PATCH 12/13] Issue #159, Remove LC_OperData.TableResults from LC_CreateDefinitionTables() --- fsw/src/lc_app.c | 180 +++++++++++++++++------------------------------ 1 file changed, 63 insertions(+), 117 deletions(-) diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index 5082a32..257678c 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -493,160 +493,106 @@ CFE_Status_t LC_CreateResultTables(void) CFE_Status_t LC_CreateDefinitionTables(void) { - CFE_Status_t Result; + CFE_Status_t Status; uint32 DataSize; - uint32 OptionFlags = CFE_TBL_OPT_DEFAULT; + + DataSize = LC_MAX_WATCHPOINTS * sizeof(LC_WDTEntry_t); /* - ** If CDS is still enabled, try to register the 2 definition tables as critical + ** If CDS is still enabled, try to register the Watchpoint Definition Table (WDT) as critical ** (if error, continue with init - but disable CDS and re-register as non-critical) */ if (LC_OperData.HaveActiveCDS) { - OptionFlags = CFE_TBL_OPT_DEFAULT | CFE_TBL_OPT_CRITICAL; - } + Status = CFE_TBL_Register(&LC_OperData.WDTHandle, + LC_WDT_TABLENAME, + DataSize, + CFE_TBL_OPT_DEFAULT | CFE_TBL_OPT_CRITICAL, + LC_ValidateWDT); - /* - ** Register the Watchpoint Definition Table (WDT) - */ - DataSize = LC_MAX_WATCHPOINTS * sizeof(LC_WDTEntry_t); - Result = CFE_TBL_Register(&LC_OperData.WDTHandle, LC_WDT_TABLENAME, DataSize, OptionFlags, LC_ValidateWDT); - - if ((LC_OperData.HaveActiveCDS) && ((Result != CFE_TBL_INFO_RECOVERED_TBL) && (Result != CFE_SUCCESS))) - { - LC_OperData.HaveActiveCDS = false; - OptionFlags = CFE_TBL_OPT_DEFAULT; - - CFE_EVS_SendEvent(LC_WDT_REGISTER_CRIT_ERR_EID, - CFE_EVS_EventType_ERROR, - "Error registering WDT as critical table, retrying with default options, RC=0x%08X", - (unsigned int)Result); - - /* - ** Re-register the Watchpoint Definition Table (WDT) non-critical - */ - Result = CFE_TBL_Register(&LC_OperData.WDTHandle, LC_WDT_TABLENAME, DataSize, OptionFlags, LC_ValidateWDT); + if ((Status != CFE_TBL_INFO_RECOVERED_TBL) && (Status != CFE_SUCCESS)) + { + LC_OperData.HaveActiveCDS = false; + CFE_EVS_SendEvent(LC_WDT_REGISTER_CRIT_ERR_EID, + CFE_EVS_EventType_ERROR, + "Error registering WDT as critical table, retrying with default options, RC=0x%08X", + (unsigned int)Status); + } } - if (Result == CFE_TBL_INFO_RECOVERED_TBL) - { - LC_OperData.TableResults |= LC_WDT_CRITICAL_TBL; - LC_OperData.TableResults |= LC_WDT_TBL_RESTORED; - Result = CFE_SUCCESS; - } - else if (Result == CFE_SUCCESS) + /* If CDS isn't active (re-)register the Watchpoint Definition Table (WDT) as non-critical */ + if (LC_OperData.HaveActiveCDS == false) { - if (LC_OperData.HaveActiveCDS) + Status = + CFE_TBL_Register(&LC_OperData.WDTHandle, LC_WDT_TABLENAME, DataSize, CFE_TBL_OPT_DEFAULT, LC_ValidateWDT); + + if ((Status != CFE_TBL_INFO_RECOVERED_TBL) && (Status != CFE_SUCCESS)) { - LC_OperData.TableResults |= LC_WDT_CRITICAL_TBL; + /* Task initialization fails without this table */ + CFE_EVS_SendEvent(LC_WDT_REGISTER_ERR_EID, + CFE_EVS_EventType_ERROR, + "Error registering WDT, RC=0x%08X", + (unsigned int)Status); } else { - LC_OperData.TableResults |= LC_WDT_NOT_CRITICAL; + /* Simplify successful outcomes */ + Status = CFE_SUCCESS; } } - else - { - /* - ** Task initialization fails without this table - ** - */ - CFE_EVS_SendEvent(LC_WDT_REGISTER_ERR_EID, - CFE_EVS_EventType_ERROR, - "Error registering WDT, RC=0x%08X", - (unsigned int)Result); - } - if (Result == CFE_SUCCESS) + if (Status == CFE_SUCCESS) { - /* - ** Register the Actionpoint Definition Table (ADT) - */ DataSize = LC_MAX_ACTIONPOINTS * sizeof(LC_ADTEntry_t); - Result = CFE_TBL_Register(&LC_OperData.ADTHandle, LC_ADT_TABLENAME, DataSize, OptionFlags, LC_ValidateADT); - if ((LC_OperData.HaveActiveCDS) && ((Result != CFE_TBL_INFO_RECOVERED_TBL) && (Result != CFE_SUCCESS))) + /* + ** If CDS is still enabled, try to register the Actionpoint Definition Table (ADT) as critical + ** (if error, continue with init - but disable CDS and re-register as non-critical) + */ + if (LC_OperData.HaveActiveCDS) { - LC_OperData.HaveActiveCDS = false; - OptionFlags = CFE_TBL_OPT_DEFAULT; - - CFE_EVS_SendEvent(LC_ADT_REGISTER_CRIT_ERR_EID, - CFE_EVS_EventType_ERROR, - "Error registering ADT as critical table, retrying with default options, RC=0x%08X", - (unsigned int)Result); - - /* - ** Re-register the Actionpoint Definition Table (ADT) non-critical - */ - Result = CFE_TBL_Register(&LC_OperData.ADTHandle, LC_ADT_TABLENAME, DataSize, OptionFlags, LC_ValidateADT); - } + Status = CFE_TBL_Register(&LC_OperData.ADTHandle, + LC_ADT_TABLENAME, + DataSize, + CFE_TBL_OPT_DEFAULT | CFE_TBL_OPT_CRITICAL, + LC_ValidateADT); - if (Result == CFE_TBL_INFO_RECOVERED_TBL) - { - LC_OperData.TableResults |= LC_ADT_CRITICAL_TBL; - LC_OperData.TableResults |= LC_ADT_TBL_RESTORED; - Result = CFE_SUCCESS; - } - else if (Result == CFE_SUCCESS) - { - if (LC_OperData.HaveActiveCDS) - { - LC_OperData.TableResults |= LC_ADT_CRITICAL_TBL; - } - else + if ((Status != CFE_TBL_INFO_RECOVERED_TBL) && (Status != CFE_SUCCESS)) { - LC_OperData.TableResults |= LC_ADT_NOT_CRITICAL; + LC_OperData.HaveActiveCDS = false; + CFE_EVS_SendEvent(LC_ADT_REGISTER_CRIT_ERR_EID, + CFE_EVS_EventType_ERROR, + "Error registering ADT as critical table, retrying with default options, RC=0x%08X", + (unsigned int)Status); } } - else - { - /* - ** Task initialization fails without this table - */ - CFE_EVS_SendEvent(LC_ADT_REGISTER_ERR_EID, - CFE_EVS_EventType_ERROR, - "Error registering ADT, RC=0x%08X", - (unsigned int)Result); - } - } - if (Result == CFE_SUCCESS) - { - /* - ** In case we created a critical WDT and then created a non-critical ADT - */ - if (((LC_OperData.TableResults & LC_WDT_CRITICAL_TBL) == LC_WDT_CRITICAL_TBL) - && ((LC_OperData.TableResults & LC_ADT_NOT_CRITICAL) == LC_ADT_NOT_CRITICAL)) + /* If CDS isn't active (re-)register the Actionpoint Definition Table (ADT) as non-critical */ + if (LC_OperData.HaveActiveCDS == false) { - /* - ** Un-register the critical watchpoint Definition Table (WDT) - */ - CFE_TBL_Unregister(LC_OperData.WDTHandle); + Status = CFE_TBL_Register(&LC_OperData.ADTHandle, + LC_ADT_TABLENAME, + DataSize, + CFE_TBL_OPT_DEFAULT, + LC_ValidateADT); - /* - ** Re-register the Watchpoint Definition Table (WDT) non-critical - */ - DataSize = LC_MAX_WATCHPOINTS * sizeof(LC_WDTEntry_t); - OptionFlags = CFE_TBL_OPT_DEFAULT; - Result = CFE_TBL_Register(&LC_OperData.WDTHandle, LC_WDT_TABLENAME, DataSize, OptionFlags, LC_ValidateWDT); - if (Result == CFE_SUCCESS) + if ((Status != CFE_TBL_INFO_RECOVERED_TBL) && (Status != CFE_SUCCESS)) { - LC_OperData.TableResults |= LC_WDT_NOT_CRITICAL; + /* Task initialization fails without this table */ + CFE_EVS_SendEvent(LC_ADT_REGISTER_ERR_EID, + CFE_EVS_EventType_ERROR, + "Error registering ADT, RC=0x%08X", + (unsigned int)Status); } else { - /* - ** Task initialization fails without this table - */ - CFE_EVS_SendEvent(LC_WDT_REREGISTER_ERR_EID, - CFE_EVS_EventType_ERROR, - "Error re-registering WDT, RC=0x%08X", - (unsigned int)Result); + /* Simplify successful outcomes */ + Status = CFE_SUCCESS; } } } - return Result; + return Status; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ From dc99a3b7250b11871a6fec6dfac18d5a9741ca05 Mon Sep 17 00:00:00 2001 From: Cameron Sykes Date: Fri, 13 Nov 2026 16:55:00 -0500 Subject: [PATCH 13/13] Issue #159, Removed all LC_AppData.TableResults in source files by removing from LC_LoadDefaultTables() --- fsw/src/lc_app.c | 85 +++++++++++++++--------------------------------- fsw/src/lc_app.h | 2 -- 2 files changed, 26 insertions(+), 61 deletions(-) diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index 257678c..b7d4145 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -694,20 +694,11 @@ CFE_Status_t LC_LoadDefaultTables(void) { CFE_Status_t Result; - /* - ** Load default watchpoint definition table (WDT) - */ + /* Load default watchpoint definition table (WDT) */ Result = CFE_TBL_Load(LC_OperData.WDTHandle, CFE_TBL_SRC_FILE, LC_WDT_FILENAME); - - if (Result == CFE_SUCCESS) - { - LC_OperData.TableResults |= LC_WDT_DEFAULT_TBL; - } - else + if (Result != CFE_SUCCESS) { - /* - ** Task initialization fails without this table - */ + /* Task initialization fails without this table */ CFE_EVS_SendEvent(LC_WDT_LOAD_ERR_EID, CFE_EVS_EventType_ERROR, "Error (RC=0x%08X) Loading WDT with '%s'", @@ -717,11 +708,8 @@ CFE_Status_t LC_LoadDefaultTables(void) if (Result == CFE_SUCCESS) { - /* - ** Get a pointer to the watchpoint definition table data... - */ + /* Get a pointer to the watchpoint definition table data */ Result = CFE_TBL_GetAddress((void *)&LC_OperData.WDTPtr, LC_OperData.WDTHandle); - if ((Result != CFE_SUCCESS) && (Result != CFE_TBL_INFO_UPDATED)) { CFE_EVS_SendEvent(LC_WDT_GETADDR_ERR_EID, @@ -729,24 +717,20 @@ CFE_Status_t LC_LoadDefaultTables(void) "Error getting WDT address, RC=0x%08X", (unsigned int)Result); } + else + { + /* Simplify successful outcomes */ + Result = CFE_SUCCESS; + } } - if ((Result == CFE_SUCCESS) || (Result == CFE_TBL_INFO_UPDATED)) + if (Result == CFE_SUCCESS) { - /* - ** Load default actionpoint definition table (ADT) - */ + /* Load default actionpoint definition table (ADT) */ Result = CFE_TBL_Load(LC_OperData.ADTHandle, CFE_TBL_SRC_FILE, LC_ADT_FILENAME); - - if (Result == CFE_SUCCESS) - { - LC_OperData.TableResults |= LC_ADT_DEFAULT_TBL; - } - else + if (Result != CFE_SUCCESS) { - /* - ** Task initialization fails without this table - */ + /* Task initialization fails without this table */ CFE_EVS_SendEvent(LC_ADT_LOAD_ERR_EID, CFE_EVS_EventType_ERROR, "Error (RC=0x%08X) Loading ADT with '%s'", @@ -757,11 +741,8 @@ CFE_Status_t LC_LoadDefaultTables(void) if (Result == CFE_SUCCESS) { - /* - ** Get a pointer to the actionpoint definition table data - */ + /* Get a pointer to the actionpoint definition table data */ Result = CFE_TBL_GetAddress((void *)&LC_OperData.ADTPtr, LC_OperData.ADTHandle); - if ((Result != CFE_SUCCESS) && (Result != CFE_TBL_INFO_UPDATED)) { CFE_EVS_SendEvent(LC_ADT_GETADDR_ERR_EID, @@ -769,41 +750,27 @@ CFE_Status_t LC_LoadDefaultTables(void) "Error getting ADT address, RC=0x%08X", (unsigned int)Result); } + else + { + /* Simplify successful outcomes */ + Result = CFE_SUCCESS; + } } - if ((Result == CFE_SUCCESS) || (Result == CFE_TBL_INFO_UPDATED)) + if (Result == CFE_SUCCESS) { - /* - ** Initialize the watchpoint and actionpoint result table data - */ + /* Initialize the watchpoint and actionpoint result table data */ LC_ResetResultsWP(0, LC_MAX_WATCHPOINTS - 1, false); - LC_OperData.TableResults |= LC_WRT_DEFAULT_DATA; - LC_ResetResultsAP(0, LC_MAX_ACTIONPOINTS - 1, false); - LC_OperData.TableResults |= LC_ART_DEFAULT_DATA; - /* - ** Reset application data counters reported in housekeeping - */ + /* Reset application data counters reported in housekeeping */ LC_ResetCounters(); - /* - ** Set LC operational state to configured startup value - */ - LC_AppData.CurrentLCState = LC_STATE_POWER_ON_RESET; - LC_OperData.TableResults |= LC_APP_DEFAULT_DATA; + /* Set LC operational state to configured startup value */ + LC_AppData.CurrentLCState = LC_STATE_POWER_ON_RESET; - /* - ** If CDS is enabled - try to update the 3 CDS areas managed by the LC task - ** (continue, but disable CDS if unable to update all 3) - */ - if (LC_OperData.HaveActiveCDS) - { - if (LC_SetCDS_Data() == CFE_SUCCESS) - { - LC_OperData.TableResults |= LC_CDS_UPDATED; - } - } + /* Try to update CDS data managed by the LC task */ + Result = LC_SetCDS_Data(); } return Result; diff --git a/fsw/src/lc_app.h b/fsw/src/lc_app.h index e771540..be2d576 100644 --- a/fsw/src/lc_app.h +++ b/fsw/src/lc_app.h @@ -165,8 +165,6 @@ typedef struct LC_HkPacket_t HkPacket; /**< \brief Housekeeping telemetry packet */ - uint32 TableResults; /**< \brief Table and CDS initialization results */ - LC_MessageList_t *HashTable[LC_HASH_TABLE_ENTRIES]; /**< \brief Each entry in the hash table is a linked list of all the MessageID's