From a71b471ef5c85466d845ff6c4ce6b8708bce86ea Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Fri, 1 Dec 2023 20:03:13 +1000 Subject: [PATCH 1/3] Fix #215, Convert syslog writes during initialization to events --- fsw/inc/sample_app_eventids.h | 22 +++++++++++-------- fsw/src/sample_app.c | 13 ++++++----- .../coveragetest/coveragetest_sample_app.c | 17 +++++++------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/fsw/inc/sample_app_eventids.h b/fsw/inc/sample_app_eventids.h index 06406d8..7a7d178 100644 --- a/fsw/inc/sample_app_eventids.h +++ b/fsw/inc/sample_app_eventids.h @@ -25,14 +25,18 @@ #ifndef SAMPLE_APP_EVENTS_H #define SAMPLE_APP_EVENTS_H -#define SAMPLE_APP_RESERVED_EID 0 -#define SAMPLE_APP_INIT_INF_EID 1 -#define SAMPLE_APP_CC_ERR_EID 2 -#define SAMPLE_APP_NOOP_INF_EID 3 -#define SAMPLE_APP_RESET_INF_EID 4 -#define SAMPLE_APP_MID_ERR_EID 5 -#define SAMPLE_APP_CMD_LEN_ERR_EID 6 -#define SAMPLE_APP_PIPE_ERR_EID 7 -#define SAMPLE_APP_VALUE_INF_EID 8 +#define SAMPLE_APP_RESERVED_EID 0 +#define SAMPLE_APP_INIT_INF_EID 1 +#define SAMPLE_APP_CC_ERR_EID 2 +#define SAMPLE_APP_NOOP_INF_EID 3 +#define SAMPLE_APP_RESET_INF_EID 4 +#define SAMPLE_APP_MID_ERR_EID 5 +#define SAMPLE_APP_CMD_LEN_ERR_EID 6 +#define SAMPLE_APP_PIPE_ERR_EID 7 +#define SAMPLE_APP_VALUE_INF_EID 8 +#define SAMPLE_APP_CR_PIPE_ERR_EID 9 +#define SAMPLE_APP_SUB_HK_ERR_EID 10 +#define SAMPLE_APP_SUB_CMD_ERR_EID 11 +#define SAMPLE_APP_TABLE_REG_ERR_EID 12 #endif /* SAMPLE_APP_EVENTS_H */ diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index b3b7e8a..7337d80 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -146,7 +146,8 @@ int32 SAMPLE_APP_Init(void) status = CFE_SB_CreatePipe(&SAMPLE_APP_Data.CommandPipe, SAMPLE_APP_Data.PipeDepth, SAMPLE_APP_Data.PipeName); if (status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("Sample App: Error creating pipe, RC = 0x%08lX\n", (unsigned long)status); + CFE_EVS_SendEvent(SAMPLE_APP_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR, + "Sample App: Error creating SB Command Pipe, RC = 0x%08lX", (unsigned long)status); } } @@ -158,7 +159,8 @@ int32 SAMPLE_APP_Init(void) status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(SAMPLE_APP_SEND_HK_MID), SAMPLE_APP_Data.CommandPipe); if (status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("Sample App: Error Subscribing to HK request, RC = 0x%08lX\n", (unsigned long)status); + CFE_EVS_SendEvent(SAMPLE_APP_SUB_HK_ERR_EID, CFE_EVS_EventType_ERROR, + "Sample App: Error Subscribing to HK request, RC = 0x%08lX", (unsigned long)status); } } @@ -170,9 +172,9 @@ int32 SAMPLE_APP_Init(void) status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(SAMPLE_APP_CMD_MID), SAMPLE_APP_Data.CommandPipe); if (status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("Sample App: Error Subscribing to Command, RC = 0x%08lX\n", (unsigned long)status); + CFE_EVS_SendEvent(SAMPLE_APP_SUB_CMD_ERR_EID, CFE_EVS_EventType_ERROR, + "Sample App: Error Subscribing to Commands, RC = 0x%08lX", (unsigned long)status); } - } if (status == CFE_SUCCESS) @@ -184,7 +186,8 @@ int32 SAMPLE_APP_Init(void) CFE_TBL_OPT_DEFAULT, SAMPLE_APP_TblValidationFunc); if (status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("Sample App: Error Registering Example Table, RC = 0x%08lX\n", (unsigned long)status); + CFE_EVS_SendEvent(SAMPLE_APP_TABLE_REG_ERR_EID, CFE_EVS_EventType_ERROR, + "Sample App: Error Registering Example Table, RC = 0x%08lX", (unsigned long)status); } else { diff --git a/unit-test/coveragetest/coveragetest_sample_app.c b/unit-test/coveragetest/coveragetest_sample_app.c index 294cf71..8eba846 100644 --- a/unit-test/coveragetest/coveragetest_sample_app.c +++ b/unit-test/coveragetest/coveragetest_sample_app.c @@ -149,29 +149,30 @@ void Test_SAMPLE_APP_Init(void) /* nominal case should return CFE_SUCCESS */ UtAssert_INT32_EQ(SAMPLE_APP_Init(), CFE_SUCCESS); - /* trigger a failure for each of the sub-calls, - * and confirm a write to syslog for each. - * Note that this count accumulates, because the status - * is _not_ reset between these test cases. */ + /* + * Trigger a failure for each of the sub-calls, and confirm a write to syslog for + * failure to register with EVS, and that an event is generated for subsequent error paths. + * Note that the stub counts accumulate, because the status is _not_ reset between test cases. + */ UT_SetDeferredRetcode(UT_KEY(CFE_EVS_Register), 1, CFE_EVS_INVALID_PARAMETER); UtAssert_INT32_EQ(SAMPLE_APP_Init(), CFE_EVS_INVALID_PARAMETER); UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 1); UT_SetDeferredRetcode(UT_KEY(CFE_SB_CreatePipe), 1, CFE_SB_BAD_ARGUMENT); UtAssert_INT32_EQ(SAMPLE_APP_Init(), CFE_SB_BAD_ARGUMENT); - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 2); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); /* 1 from previous nominal case, 1 from this error path */ UT_SetDeferredRetcode(UT_KEY(CFE_SB_Subscribe), 1, CFE_SB_BAD_ARGUMENT); UtAssert_INT32_EQ(SAMPLE_APP_Init(), CFE_SB_BAD_ARGUMENT); - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 3); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 3); /* 1 additional event sent from this error path */ UT_SetDeferredRetcode(UT_KEY(CFE_SB_Subscribe), 2, CFE_SB_BAD_ARGUMENT); UtAssert_INT32_EQ(SAMPLE_APP_Init(), CFE_SB_BAD_ARGUMENT); - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 4); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 4); /* 1 additional event sent from this error path */ UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_TBL_ERR_INVALID_OPTIONS); UtAssert_INT32_EQ(SAMPLE_APP_Init(), CFE_TBL_ERR_INVALID_OPTIONS); - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 5); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 6); /* 1 from table registration error, 1 from successful init event */ } /* From 1e903fb7df483202810b429e0ae4593c93a6da58 Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Sun, 3 Dec 2023 09:33:34 +1000 Subject: [PATCH 2/3] Fix #217, Convert remaining `int32` CFE status variables to `CFE_Status_t` --- fsw/src/sample_app.c | 13 ++++++------- fsw/src/sample_app.h | 4 ++-- fsw/src/sample_app_cmds.c | 2 +- fsw/src/sample_app_utils.c | 6 +++--- fsw/src/sample_app_utils.h | 4 ++-- unit-test/coveragetest/coveragetest_sample_app.c | 2 +- .../coveragetest/coveragetest_sample_app_utils.c | 2 +- unit-test/stubs/sample_app_stubs.c | 6 +++--- unit-test/stubs/sample_app_utils_stubs.c | 6 +++--- 9 files changed, 22 insertions(+), 23 deletions(-) diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index 6a96de4..5b4f36d 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -44,7 +44,7 @@ SAMPLE_APP_Data_t SAMPLE_APP_Data; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ void SAMPLE_APP_Main(void) { - int32 status; + CFE_Status_t status; CFE_SB_Buffer_t *SBBufPtr; /* @@ -107,10 +107,10 @@ void SAMPLE_APP_Main(void) /* Initialization */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -int32 SAMPLE_APP_Init(void) +CFE_Status_t SAMPLE_APP_Init(void) { - int32 status; - char VersionString[SAMPLE_APP_CFG_MAX_VERSION_STR_LEN]; + CFE_Status_t status; + char VersionString[SAMPLE_APP_CFG_MAX_VERSION_STR_LEN]; /* Zero out the global data structure */ memset(&SAMPLE_APP_Data, 0, sizeof(SAMPLE_APP_Data)); @@ -173,7 +173,6 @@ int32 SAMPLE_APP_Init(void) { CFE_ES_WriteToSysLog("Sample App: Error Subscribing to Command, RC = 0x%08lX\n", (unsigned long)status); } - } if (status == CFE_SUCCESS) @@ -192,8 +191,8 @@ int32 SAMPLE_APP_Init(void) status = CFE_TBL_Load(SAMPLE_APP_Data.TblHandles[0], CFE_TBL_SRC_FILE, SAMPLE_APP_TABLE_FILE); } - CFE_Config_GetVersionString(VersionString, SAMPLE_APP_CFG_MAX_VERSION_STR_LEN, "Sample App", - SAMPLE_APP_VERSION, SAMPLE_APP_BUILD_CODENAME, SAMPLE_APP_LAST_OFFICIAL); + CFE_Config_GetVersionString(VersionString, SAMPLE_APP_CFG_MAX_VERSION_STR_LEN, "Sample App", SAMPLE_APP_VERSION, + SAMPLE_APP_BUILD_CODENAME, SAMPLE_APP_LAST_OFFICIAL); CFE_EVS_SendEvent(SAMPLE_APP_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "Sample App Initialized.%s", VersionString); diff --git a/fsw/src/sample_app.h b/fsw/src/sample_app.h index c2cac81..1cd31ee 100644 --- a/fsw/src/sample_app.h +++ b/fsw/src/sample_app.h @@ -89,7 +89,7 @@ extern SAMPLE_APP_Data_t SAMPLE_APP_Data; ** Note: Except for the entry point (SAMPLE_APP_Main), these ** functions are not called from any other source module. */ -void SAMPLE_APP_Main(void); -int32 SAMPLE_APP_Init(void); +void SAMPLE_APP_Main(void); +CFE_Status_t SAMPLE_APP_Init(void); #endif /* SAMPLE_APP_H */ diff --git a/fsw/src/sample_app_cmds.c b/fsw/src/sample_app_cmds.c index e30fe32..b2eb155 100644 --- a/fsw/src/sample_app_cmds.c +++ b/fsw/src/sample_app_cmds.c @@ -111,7 +111,7 @@ CFE_Status_t SAMPLE_APP_ResetCountersCmd(const SAMPLE_APP_ResetCountersCmd_t *Ms /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ CFE_Status_t SAMPLE_APP_ProcessCmd(const SAMPLE_APP_ProcessCmd_t *Msg) { - int32 status; + CFE_Status_t status; void * TblAddr; SAMPLE_APP_ExampleTable_t *TblPtr; const char * TableName = "SAMPLE_APP.ExampleTable"; diff --git a/fsw/src/sample_app_utils.c b/fsw/src/sample_app_utils.c index 0de14ea..4bae292 100644 --- a/fsw/src/sample_app_utils.c +++ b/fsw/src/sample_app_utils.c @@ -34,9 +34,9 @@ /* Verify contents of First Example Table buffer contents */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 SAMPLE_APP_TblValidationFunc(void *TblData) +CFE_Status_t SAMPLE_APP_TblValidationFunc(void *TblData) { - int32 ReturnCode = CFE_SUCCESS; + CFE_Status_t ReturnCode = CFE_SUCCESS; SAMPLE_APP_ExampleTable_t *TblDataPtr = (SAMPLE_APP_ExampleTable_t *)TblData; /* @@ -58,7 +58,7 @@ int32 SAMPLE_APP_TblValidationFunc(void *TblData) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SAMPLE_APP_GetCrc(const char *TableName) { - int32 status; + CFE_Status_t status; uint32 Crc; CFE_TBL_Info_t TblInfoPtr; diff --git a/fsw/src/sample_app_utils.h b/fsw/src/sample_app_utils.h index 873962d..cc6f133 100644 --- a/fsw/src/sample_app_utils.h +++ b/fsw/src/sample_app_utils.h @@ -29,7 +29,7 @@ */ #include "sample_app.h" -int32 SAMPLE_APP_TblValidationFunc(void *TblData); -void SAMPLE_APP_GetCrc(const char *TableName); +CFE_Status_t SAMPLE_APP_TblValidationFunc(void *TblData); +void SAMPLE_APP_GetCrc(const char *TableName); #endif /* SAMPLE_APP_UTILS_H */ \ No newline at end of file diff --git a/unit-test/coveragetest/coveragetest_sample_app.c b/unit-test/coveragetest/coveragetest_sample_app.c index 294cf71..e724f06 100644 --- a/unit-test/coveragetest/coveragetest_sample_app.c +++ b/unit-test/coveragetest/coveragetest_sample_app.c @@ -143,7 +143,7 @@ void Test_SAMPLE_APP_Init(void) { /* * Test Case For: - * int32 SAMPLE_APP_Init( void ) + * CFE_Status_t SAMPLE_APP_Init( void ) */ /* nominal case should return CFE_SUCCESS */ diff --git a/unit-test/coveragetest/coveragetest_sample_app_utils.c b/unit-test/coveragetest/coveragetest_sample_app_utils.c index 72b32e2..6c81011 100644 --- a/unit-test/coveragetest/coveragetest_sample_app_utils.c +++ b/unit-test/coveragetest/coveragetest_sample_app_utils.c @@ -48,7 +48,7 @@ void Test_SAMPLE_APP_TblValidationFunc(void) { /* * Test Case For: - * int32 SAMPLE_APP_TblValidationFunc( void *TblData ) + * CFE_Status_t SAMPLE_APP_TblValidationFunc( void *TblData ) */ SAMPLE_APP_ExampleTable_t TestTblData; diff --git a/unit-test/stubs/sample_app_stubs.c b/unit-test/stubs/sample_app_stubs.c index 4001c1b..16977fd 100644 --- a/unit-test/stubs/sample_app_stubs.c +++ b/unit-test/stubs/sample_app_stubs.c @@ -30,13 +30,13 @@ * Generated stub function for SAMPLE_APP_Init() * ---------------------------------------------------- */ -int32 SAMPLE_APP_Init(void) +CFE_Status_t SAMPLE_APP_Init(void) { - UT_GenStub_SetupReturnBuffer(SAMPLE_APP_Init, int32); + UT_GenStub_SetupReturnBuffer(SAMPLE_APP_Init, CFE_Status_t); UT_GenStub_Execute(SAMPLE_APP_Init, Basic, NULL); - return UT_GenStub_GetReturnValue(SAMPLE_APP_Init, int32); + return UT_GenStub_GetReturnValue(SAMPLE_APP_Init, CFE_Status_t); } /* diff --git a/unit-test/stubs/sample_app_utils_stubs.c b/unit-test/stubs/sample_app_utils_stubs.c index 346a29a..88e52c1 100644 --- a/unit-test/stubs/sample_app_utils_stubs.c +++ b/unit-test/stubs/sample_app_utils_stubs.c @@ -42,13 +42,13 @@ void SAMPLE_APP_GetCrc(const char *TableName) * Generated stub function for SAMPLE_APP_TblValidationFunc() * ---------------------------------------------------- */ -int32 SAMPLE_APP_TblValidationFunc(void *TblData) +CFE_Status_t SAMPLE_APP_TblValidationFunc(void *TblData) { - UT_GenStub_SetupReturnBuffer(SAMPLE_APP_TblValidationFunc, int32); + UT_GenStub_SetupReturnBuffer(SAMPLE_APP_TblValidationFunc, CFE_Status_t); UT_GenStub_AddParam(SAMPLE_APP_TblValidationFunc, void *, TblData); UT_GenStub_Execute(SAMPLE_APP_TblValidationFunc, Basic, NULL); - return UT_GenStub_GetReturnValue(SAMPLE_APP_TblValidationFunc, int32); + return UT_GenStub_GetReturnValue(SAMPLE_APP_TblValidationFunc, CFE_Status_t); } From 2a8a39547de1b6bc7205587595a412cdddf351e1 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 21 Mar 2024 16:03:39 -0400 Subject: [PATCH 3/3] Updating documentation and version numbers for equuleus-rc1+dev46 --- CHANGELOG.md | 5 +++++ fsw/src/sample_app_version.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17bc40e..a444f6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Development Build: equuleus-rc1+dev46 +- Convert remaining int32 CFE status variables to CFE_Status_t +- Convert syslog writes during initialization to events +- See and + ## Development Build: equuleus-rc4+dev40 - apply name changes to EDS dispatcher - See diff --git a/fsw/src/sample_app_version.h b/fsw/src/sample_app_version.h index 1a4cfda..ea29947 100644 --- a/fsw/src/sample_app_version.h +++ b/fsw/src/sample_app_version.h @@ -27,7 +27,7 @@ /* Development Build Macro Definitions */ -#define SAMPLE_APP_BUILD_NUMBER 40 /*!< Development Build: Number of commits since baseline */ +#define SAMPLE_APP_BUILD_NUMBER 46 /*!< Development Build: Number of commits since baseline */ #define SAMPLE_APP_BUILD_BASELINE "equuleus-rc1" /*!< Development Build: git tag that is the base for the current development */ #define SAMPLE_APP_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */ #define SAMPLE_APP_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */