From 640d6d0289cc449a93ede752b7852c4601c35475 Mon Sep 17 00:00:00 2001 From: Avi Date: Wed, 19 Oct 2022 10:48:29 +1000 Subject: [PATCH 01/23] Fix #167, Rename CommandCode variable to FcnCode --- fsw/src/sample_app.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index 2961237..ce9966b 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -234,14 +234,14 @@ void SAMPLE_APP_ProcessCommandPacket(CFE_SB_Buffer_t *SBBufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) { - CFE_MSG_FcnCode_t CommandCode = 0; + CFE_MSG_FcnCode_t FcnCode = 0; - CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); + CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &FcnCode); /* ** Process "known" SAMPLE app ground commands */ - switch (CommandCode) + switch (FcnCode) { case SAMPLE_APP_NOOP_CC: if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_NoopCmd_t))) @@ -270,7 +270,7 @@ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) /* default case already found during FC vs length test */ default: CFE_EVS_SendEvent(SAMPLE_APP_COMMAND_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid ground command code: CC = %d", CommandCode); + "Invalid ground command code: CC = %d", FcnCode); break; } } From 30d640e5b03cdc6ac1ed708a47e5729bfcfd2d00 Mon Sep 17 00:00:00 2001 From: Avi Date: Fri, 21 Oct 2022 20:44:31 +1000 Subject: [PATCH 02/23] Fix #188, Apply consistent Event ID names to common events --- fsw/src/sample_app.c | 14 +++++++------- fsw/src/sample_app_events.h | 16 ++++++++-------- unit-test/coveragetest/coveragetest_sample_app.c | 14 +++++++------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index 2961237..dafb2e6 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -191,7 +191,7 @@ int32 SAMPLE_APP_Init(void) status = CFE_TBL_Load(SAMPLE_APP_Data.TblHandles[0], CFE_TBL_SRC_FILE, SAMPLE_APP_TABLE_FILE); } - CFE_EVS_SendEvent(SAMPLE_APP_STARTUP_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE App Initialized.%s", + CFE_EVS_SendEvent(SAMPLE_APP_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE App Initialized.%s", SAMPLE_APP_VERSION_STRING); return CFE_SUCCESS; @@ -221,7 +221,7 @@ void SAMPLE_APP_ProcessCommandPacket(CFE_SB_Buffer_t *SBBufPtr) break; default: - CFE_EVS_SendEvent(SAMPLE_APP_INVALID_MSGID_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_EVS_SendEvent(SAMPLE_APP_MID_ERR_EID, CFE_EVS_EventType_ERROR, "SAMPLE: invalid command packet,MID = 0x%x", (unsigned int)CFE_SB_MsgIdToValue(MsgId)); break; } @@ -269,8 +269,8 @@ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) /* default case already found during FC vs length test */ default: - CFE_EVS_SendEvent(SAMPLE_APP_COMMAND_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid ground command code: CC = %d", CommandCode); + CFE_EVS_SendEvent(SAMPLE_APP_CC_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid ground command code: CC = %d", + CommandCode); break; } } @@ -319,7 +319,7 @@ int32 SAMPLE_APP_Noop(const SAMPLE_APP_NoopCmd_t *Msg) { SAMPLE_APP_Data.CmdCounter++; - CFE_EVS_SendEvent(SAMPLE_APP_COMMANDNOP_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: NOOP command %s", + CFE_EVS_SendEvent(SAMPLE_APP_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: NOOP command %s", SAMPLE_APP_VERSION); return CFE_SUCCESS; @@ -337,7 +337,7 @@ int32 SAMPLE_APP_ResetCounters(const SAMPLE_APP_ResetCountersCmd_t *Msg) SAMPLE_APP_Data.CmdCounter = 0; SAMPLE_APP_Data.ErrCounter = 0; - CFE_EVS_SendEvent(SAMPLE_APP_COMMANDRST_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: RESET command"); + CFE_EVS_SendEvent(SAMPLE_APP_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: RESET command"); return CFE_SUCCESS; } @@ -403,7 +403,7 @@ bool SAMPLE_APP_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength CFE_MSG_GetMsgId(MsgPtr, &MsgId); CFE_MSG_GetFcnCode(MsgPtr, &FcnCode); - CFE_EVS_SendEvent(SAMPLE_APP_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_EVS_SendEvent(SAMPLE_APP_CMD_LEN_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u", (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, (unsigned int)ExpectedLength); diff --git a/fsw/src/sample_app_events.h b/fsw/src/sample_app_events.h index 46e7aaf..0d8a586 100644 --- a/fsw/src/sample_app_events.h +++ b/fsw/src/sample_app_events.h @@ -25,13 +25,13 @@ #ifndef SAMPLE_APP_EVENTS_H #define SAMPLE_APP_EVENTS_H -#define SAMPLE_APP_RESERVED_EID 0 -#define SAMPLE_APP_STARTUP_INF_EID 1 -#define SAMPLE_APP_COMMAND_ERR_EID 2 -#define SAMPLE_APP_COMMANDNOP_INF_EID 3 -#define SAMPLE_APP_COMMANDRST_INF_EID 4 -#define SAMPLE_APP_INVALID_MSGID_ERR_EID 5 -#define SAMPLE_APP_LEN_ERR_EID 6 -#define SAMPLE_APP_PIPE_ERR_EID 7 +#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 #endif /* SAMPLE_APP_EVENTS_H */ diff --git a/unit-test/coveragetest/coveragetest_sample_app.c b/unit-test/coveragetest/coveragetest_sample_app.c index a1ca631..cb7f2c1 100644 --- a/unit-test/coveragetest/coveragetest_sample_app.c +++ b/unit-test/coveragetest/coveragetest_sample_app.c @@ -291,7 +291,7 @@ void Test_SAMPLE_APP_ProcessCommandPacket(void) UT_CheckEvent_t EventTest; memset(&TestMsg, 0, sizeof(TestMsg)); - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_INVALID_MSGID_ERR_EID, "SAMPLE: invalid command packet,MID = 0x%x"); + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_MID_ERR_EID, "SAMPLE: invalid command packet,MID = 0x%x"); /* * The CFE_MSG_GetMsgId() stub uses a data buffer to hold the @@ -355,7 +355,7 @@ void Test_SAMPLE_APP_ProcessGroundCommand(void) Size = sizeof(TestMsg.Noop); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_COMMANDNOP_INF_EID, NULL); + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_NOOP_INF_EID, NULL); SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); @@ -366,7 +366,7 @@ void Test_SAMPLE_APP_ProcessGroundCommand(void) Size = sizeof(TestMsg.Reset); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_COMMANDRST_INF_EID, NULL); + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_RESET_INF_EID, NULL); SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); @@ -386,7 +386,7 @@ void Test_SAMPLE_APP_ProcessGroundCommand(void) /* test an invalid CC */ FcnCode = 1000; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_COMMAND_ERR_EID, "Invalid ground command code: CC = %d"); + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_CC_ERR_EID, "Invalid ground command code: CC = %d"); SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); /* @@ -443,7 +443,7 @@ void Test_SAMPLE_APP_NoopCmd(void) memset(&TestMsg, 0, sizeof(TestMsg)); /* test dispatch of NOOP */ - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_COMMANDNOP_INF_EID, NULL); + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_NOOP_INF_EID, NULL); UtAssert_INT32_EQ(SAMPLE_APP_Noop(&TestMsg), CFE_SUCCESS); @@ -464,7 +464,7 @@ void Test_SAMPLE_APP_ResetCounters(void) memset(&TestMsg, 0, sizeof(TestMsg)); - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_COMMANDRST_INF_EID, "SAMPLE: RESET command"); + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_RESET_INF_EID, "SAMPLE: RESET command"); UtAssert_INT32_EQ(SAMPLE_APP_ResetCounters(&TestMsg), CFE_SUCCESS); @@ -527,7 +527,7 @@ void Test_SAMPLE_APP_VerifyCmdLength(void) * test a match case */ UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &size, sizeof(size), false); - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_LEN_ERR_EID, + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_CMD_LEN_ERR_EID, "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u"); SAMPLE_APP_VerifyCmdLength(NULL, size); From 6edee0618d6282b740e5a556781a700b93b41c74 Mon Sep 17 00:00:00 2001 From: Avi Date: Mon, 24 Oct 2022 13:33:47 +1000 Subject: [PATCH 03/23] Fix #147, Add check for success of CFE_TBL_Load() during Initialization --- fsw/src/sample_app.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index 2961237..fdcb9a8 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -189,6 +189,12 @@ int32 SAMPLE_APP_Init(void) else { status = CFE_TBL_Load(SAMPLE_APP_Data.TblHandles[0], CFE_TBL_SRC_FILE, SAMPLE_APP_TABLE_FILE); + if (status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("Sample App: Error Loading Table, RC = 0x%08lX\n", (unsigned long)status); + + return status; + } } CFE_EVS_SendEvent(SAMPLE_APP_STARTUP_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE App Initialized.%s", From 5b49af7b234b5b306fd86877540c52528846dc8d Mon Sep 17 00:00:00 2001 From: Avi Date: Thu, 2 Feb 2023 11:56:31 +1000 Subject: [PATCH 04/23] Fix #194, Remove component-specific cFE header #includes --- fsw/src/sample_app.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fsw/src/sample_app.h b/fsw/src/sample_app.h index 5e9006d..0f13d85 100644 --- a/fsw/src/sample_app.h +++ b/fsw/src/sample_app.h @@ -29,10 +29,6 @@ ** Required header files. */ #include "cfe.h" -#include "cfe_error.h" -#include "cfe_evs.h" -#include "cfe_sb.h" -#include "cfe_es.h" #include "sample_app_perfids.h" #include "sample_app_msgids.h" From de9e945ef4210771411c07a876a3e7d36773ef58 Mon Sep 17 00:00:00 2001 From: Avi Date: Mon, 6 Mar 2023 13:43:53 +1000 Subject: [PATCH 05/23] Fix #197, Refactor SAMPLE_APP_Init/Process to remove multiple returns --- fsw/src/sample_app.c | 168 +++++++++--------- fsw/src/sample_app.h | 2 +- fsw/src/sample_app_events.h | 2 +- fsw/src/sample_app_msg.h | 6 +- .../coveragetest/coveragetest_sample_app.c | 4 +- 5 files changed, 93 insertions(+), 89 deletions(-) diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index 2961237..8a2f115 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -54,7 +54,7 @@ void SAMPLE_APP_Main(void) CFE_ES_PerfLogEntry(SAMPLE_APP_PERF_ID); /* - ** Perform application specific initialization + ** Perform application-specific initialization ** If the Initialization fails, set the RunStatus to ** CFE_ES_RunStatus_APP_ERROR and the App will not enter the RunLoop */ @@ -65,7 +65,7 @@ void SAMPLE_APP_Main(void) } /* - ** SAMPLE Runloop + ** Sample App Runloop */ while (CFE_ES_RunLoop(&SAMPLE_APP_Data.RunStatus) == true) { @@ -135,73 +135,77 @@ int32 SAMPLE_APP_Init(void) if (status != CFE_SUCCESS) { CFE_ES_WriteToSysLog("Sample App: Error Registering Events, RC = 0x%08lX\n", (unsigned long)status); - return status; } - - /* - ** Initialize housekeeping packet (clear user data area). - */ - CFE_MSG_Init(CFE_MSG_PTR(SAMPLE_APP_Data.HkTlm.TelemetryHeader), CFE_SB_ValueToMsgId(SAMPLE_APP_HK_TLM_MID), - sizeof(SAMPLE_APP_Data.HkTlm)); - - /* - ** Create Software Bus message pipe. - */ - status = CFE_SB_CreatePipe(&SAMPLE_APP_Data.CommandPipe, SAMPLE_APP_Data.PipeDepth, SAMPLE_APP_Data.PipeName); - if (status != CFE_SUCCESS) + else { - CFE_ES_WriteToSysLog("Sample App: Error creating pipe, RC = 0x%08lX\n", (unsigned long)status); - return status; + /* + ** Initialize housekeeping packet (clear user data area). + */ + CFE_MSG_Init(CFE_MSG_PTR(SAMPLE_APP_Data.HkTlm.TelemetryHeader), CFE_SB_ValueToMsgId(SAMPLE_APP_HK_TLM_MID), + sizeof(SAMPLE_APP_Data.HkTlm)); + + /* + ** Create Software Bus message pipe. + */ + 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); + } } - /* - ** Subscribe to Housekeeping request commands - */ - status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(SAMPLE_APP_SEND_HK_MID), SAMPLE_APP_Data.CommandPipe); - if (status != CFE_SUCCESS) + if (status == CFE_SUCCESS) { - CFE_ES_WriteToSysLog("Sample App: Error Subscribing to HK request, RC = 0x%08lX\n", (unsigned long)status); - return status; + /* + ** Subscribe to Housekeeping request commands + */ + 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); + } } - /* - ** Subscribe to ground command packets - */ - status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(SAMPLE_APP_CMD_MID), SAMPLE_APP_Data.CommandPipe); - if (status != CFE_SUCCESS) + if (status == CFE_SUCCESS) { - CFE_ES_WriteToSysLog("Sample App: Error Subscribing to Command, RC = 0x%08lX\n", (unsigned long)status); - - return status; + /* + ** Subscribe to ground command packets + */ + 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); + } } - /* - ** Register Table(s) - */ - status = CFE_TBL_Register(&SAMPLE_APP_Data.TblHandles[0], "SampleAppTable", sizeof(SAMPLE_APP_Table_t), - CFE_TBL_OPT_DEFAULT, SAMPLE_APP_TblValidationFunc); - if (status != CFE_SUCCESS) + if (status == CFE_SUCCESS) { - CFE_ES_WriteToSysLog("Sample App: Error Registering Table, RC = 0x%08lX\n", (unsigned long)status); + /* + ** Register Table(s) + */ + status = CFE_TBL_Register(&SAMPLE_APP_Data.TblHandles[0], "SampleAppTable", sizeof(SAMPLE_APP_Table_t), + CFE_TBL_OPT_DEFAULT, SAMPLE_APP_TblValidationFunc); + if (status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("Sample App: Error Registering Table, RC = 0x%08lX\n", (unsigned long)status); + } + else + { + status = CFE_TBL_Load(SAMPLE_APP_Data.TblHandles[0], CFE_TBL_SRC_FILE, SAMPLE_APP_TABLE_FILE); + } - return status; - } - else - { - status = CFE_TBL_Load(SAMPLE_APP_Data.TblHandles[0], CFE_TBL_SRC_FILE, SAMPLE_APP_TABLE_FILE); + CFE_EVS_SendEvent(SAMPLE_APP_STARTUP_INF_EID, CFE_EVS_EventType_INFORMATION, "Sample App Initialized.%s", + SAMPLE_APP_VERSION_STRING); } - CFE_EVS_SendEvent(SAMPLE_APP_STARTUP_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE App Initialized.%s", - SAMPLE_APP_VERSION_STRING); - - return CFE_SUCCESS; + return status; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ /* */ /* Purpose: */ -/* This routine will process any packet that is received on the SAMPLE */ -/* command pipe. */ +/* This routine will process any packet that is received on the Sample */ +/* App command pipe. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void SAMPLE_APP_ProcessCommandPacket(CFE_SB_Buffer_t *SBBufPtr) @@ -229,7 +233,7 @@ void SAMPLE_APP_ProcessCommandPacket(CFE_SB_Buffer_t *SBBufPtr) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ /* */ -/* SAMPLE ground commands */ +/* Process Ground Commands */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) @@ -239,7 +243,7 @@ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); /* - ** Process "known" SAMPLE app ground commands + ** Process "known" Sample App ground commands */ switch (CommandCode) { @@ -248,7 +252,6 @@ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) { SAMPLE_APP_Noop((SAMPLE_APP_NoopCmd_t *)SBBufPtr); } - break; case SAMPLE_APP_RESET_COUNTERS_CC: @@ -256,7 +259,6 @@ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) { SAMPLE_APP_ResetCounters((SAMPLE_APP_ResetCountersCmd_t *)SBBufPtr); } - break; case SAMPLE_APP_PROCESS_CC: @@ -264,7 +266,6 @@ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) { SAMPLE_APP_Process((SAMPLE_APP_ProcessCmd_t *)SBBufPtr); } - break; /* default case already found during FC vs length test */ @@ -279,9 +280,10 @@ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) /* */ /* Purpose: */ /* This function is triggered in response to a task telemetry request */ -/* from the housekeeping task. This function will gather the Apps */ +/* from the housekeeping task. This function will gather the App's */ /* telemetry, packetize it and send it to the housekeeping task via */ -/* the software bus */ +/* the software bus. */ +/* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int32 SAMPLE_APP_ReportHousekeeping(const CFE_MSG_CommandHeader_t *Msg) { @@ -312,7 +314,7 @@ int32 SAMPLE_APP_ReportHousekeeping(const CFE_MSG_CommandHeader_t *Msg) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ /* */ -/* SAMPLE NOOP commands */ +/* Sample App NOOP command */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ int32 SAMPLE_APP_Noop(const SAMPLE_APP_NoopCmd_t *Msg) @@ -345,7 +347,7 @@ int32 SAMPLE_APP_ResetCounters(const SAMPLE_APP_ResetCountersCmd_t *Msg) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ /* */ /* Purpose: */ -/* This function Process Ground Station Command */ +/* This function processes Ground Station Commands */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int32 SAMPLE_APP_Process(const SAMPLE_APP_ProcessCmd_t *Msg) @@ -361,24 +363,26 @@ int32 SAMPLE_APP_Process(const SAMPLE_APP_ProcessCmd_t *Msg) if (status < CFE_SUCCESS) { CFE_ES_WriteToSysLog("Sample App: Fail to get table address: 0x%08lx", (unsigned long)status); - return status; } + else + { + CFE_ES_WriteToSysLog("Sample App: Table Value 1: %d Value 2: %d", TblPtr->Int1, TblPtr->Int2); - CFE_ES_WriteToSysLog("Sample App: Table Value 1: %d Value 2: %d", TblPtr->Int1, TblPtr->Int2); - - SAMPLE_APP_GetCrc(TableName); + SAMPLE_APP_GetCrc(TableName); - status = CFE_TBL_ReleaseAddress(SAMPLE_APP_Data.TblHandles[0]); - if (status != CFE_SUCCESS) - { - CFE_ES_WriteToSysLog("Sample App: Fail to release table address: 0x%08lx", (unsigned long)status); - return status; + status = CFE_TBL_ReleaseAddress(SAMPLE_APP_Data.TblHandles[0]); + if (status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("Sample App: Fail to release table address: 0x%08lx", (unsigned long)status); + } + else + { + /* Invoke a function provided by SAMPLE_LIB */ + SAMPLE_LIB_Function(); + } } - /* Invoke a function provided by SAMPLE_APP_LIB */ - SAMPLE_LIB_Function(); - - return CFE_SUCCESS; + return status; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ @@ -416,11 +420,11 @@ bool SAMPLE_APP_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength return result; } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Verify contents of First Table buffer contents */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* Verify contents of First Table buffer contents */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ int32 SAMPLE_APP_TblValidationFunc(void *TblData) { int32 ReturnCode = CFE_SUCCESS; @@ -438,11 +442,11 @@ int32 SAMPLE_APP_TblValidationFunc(void *TblData) return ReturnCode; } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Output CRC */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* Output CRC */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ void SAMPLE_APP_GetCrc(const char *TableName) { int32 status; diff --git a/fsw/src/sample_app.h b/fsw/src/sample_app.h index 5e9006d..d73d063 100644 --- a/fsw/src/sample_app.h +++ b/fsw/src/sample_app.h @@ -19,7 +19,7 @@ /** * @file * - * Main header file for the SAMPLE application + * Main header file for the Sample application */ #ifndef SAMPLE_APP_H diff --git a/fsw/src/sample_app_events.h b/fsw/src/sample_app_events.h index 46e7aaf..b92b9e8 100644 --- a/fsw/src/sample_app_events.h +++ b/fsw/src/sample_app_events.h @@ -19,7 +19,7 @@ /** * @file * - * Define SAMPLE App Events IDs + * Define Sample App Events IDs */ #ifndef SAMPLE_APP_EVENTS_H diff --git a/fsw/src/sample_app_msg.h b/fsw/src/sample_app_msg.h index 537d1d7..c08b8c1 100644 --- a/fsw/src/sample_app_msg.h +++ b/fsw/src/sample_app_msg.h @@ -19,14 +19,14 @@ /** * @file * - * Define SAMPLE App Messages and info + * Define Sample App messages and info */ #ifndef SAMPLE_APP_MSG_H #define SAMPLE_APP_MSG_H /* -** SAMPLE App command codes +** Sample App command codes */ #define SAMPLE_APP_NOOP_CC 0 #define SAMPLE_APP_RESET_COUNTERS_CC 1 @@ -55,7 +55,7 @@ typedef SAMPLE_APP_NoArgsCmd_t SAMPLE_APP_ProcessCmd_t; /*************************************************************************/ /* -** Type definition (SAMPLE App housekeeping) +** Type definition (Sample App housekeeping) */ typedef struct diff --git a/unit-test/coveragetest/coveragetest_sample_app.c b/unit-test/coveragetest/coveragetest_sample_app.c index a1ca631..dbb391d 100644 --- a/unit-test/coveragetest/coveragetest_sample_app.c +++ b/unit-test/coveragetest/coveragetest_sample_app.c @@ -20,11 +20,11 @@ ** File: coveragetest_sample_app.c ** ** Purpose: -** Coverage Unit Test cases for the SAMPLE Application +** Coverage Unit Test cases for the Sample Application ** ** Notes: ** This implements various test cases to exercise all code -** paths through all functions defined in the SAMPLE application. +** paths through all functions defined in the Sample application. ** ** It is primarily focused at providing examples of the various ** stub configurations, hook functions, and wrapper calls that From d08ee4374fd0fe622ad2d70336cfcacbd8fd9ab4 Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Thu, 23 Mar 2023 08:20:14 +1000 Subject: [PATCH 06/23] Fix #141, Zero out global data structure during initialization --- fsw/src/sample_app.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index 2961237..6684f0b 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -112,13 +112,10 @@ int32 SAMPLE_APP_Init(void) { int32 status; - SAMPLE_APP_Data.RunStatus = CFE_ES_RunStatus_APP_RUN; + /* Zero out the global data structure */ + memset(&SAMPLE_APP_Data, 0, sizeof(SAMPLE_APP_Data)); - /* - ** Initialize app command execution counters - */ - SAMPLE_APP_Data.CmdCounter = 0; - SAMPLE_APP_Data.ErrCounter = 0; + SAMPLE_APP_Data.RunStatus = CFE_ES_RunStatus_APP_RUN; /* ** Initialize app configuration data From 2bef88cafa135e10cba299509b76d1a980429ef5 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 6 Apr 2023 12:15:41 -0400 Subject: [PATCH 07/23] Fix #202, update cmake recipe Prefer target-scope properties over directory scope where applicable --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd1d332..f83279b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,5 @@ project(CFE_SAMPLE_APP C) -include_directories(fsw/mission_inc) -include_directories(fsw/platform_inc) - # Create the app module add_cfe_app(sample_app fsw/src/sample_app.c) @@ -11,7 +8,12 @@ add_cfe_app(sample_app fsw/src/sample_app.c) add_cfe_app_dependency(sample_app sample_lib) # Add table -add_cfe_tables(sampleAppTable fsw/tables/sample_app_tbl.c) +add_cfe_tables(sample_app fsw/tables/sample_app_tbl.c) + +target_include_directories(sample_app PUBLIC + fsw/mission_inc + fsw/platform_inc +) # If UT is enabled, then add the tests from the subdirectory # Note that this is an app, and therefore does not provide From 07eddd6bc6be7c67968ef7b118fe016d7107dafd Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 10 Apr 2023 07:22:31 -0400 Subject: [PATCH 08/23] Bump to v1.3.0-rc4+dev39 --- CHANGELOG.md | 4 ++++ fsw/src/sample_app_version.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfbc057..116c3fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Development Build: v1.3.0-rc4+dev39 +- update cmake recipe +- See + ## Development Build: v1.3.0-rc4+dev35 - Remove redundant comments - Create CHANGELOG.md diff --git a/fsw/src/sample_app_version.h b/fsw/src/sample_app_version.h index 12d75bf..a2ea178 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 35 /*!< Development Build: Number of commits since baseline */ +#define SAMPLE_APP_BUILD_NUMBER 39 /*!< Development Build: Number of commits since baseline */ #define SAMPLE_APP_BUILD_BASELINE \ "v1.3.0-rc4" /*!< Development Build: git tag that is the base for the current development */ From 3aebb801992b99e22825798ccf82d01d16c7eb3d Mon Sep 17 00:00:00 2001 From: Avi Date: Tue, 7 Mar 2023 16:38:34 +1000 Subject: [PATCH 09/23] Fix #199, Add test for missing branch in SAMPLE_APP_Process() --- .../coveragetest/coveragetest_sample_app.c | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/unit-test/coveragetest/coveragetest_sample_app.c b/unit-test/coveragetest/coveragetest_sample_app.c index a1ca631..e550a94 100644 --- a/unit-test/coveragetest/coveragetest_sample_app.c +++ b/unit-test/coveragetest/coveragetest_sample_app.c @@ -493,6 +493,13 @@ void Test_SAMPLE_APP_ProcessCC(void) UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TblPtr, sizeof(TblPtr), false); UtAssert_INT32_EQ(SAMPLE_APP_Process(&TestMsg), CFE_SUCCESS); + /* + * Successful operation results in two calls to CFE_ES_WriteToSysLog() - one + * in this function reporting the table values, and one through + * SAMPLE_APP_GetCrc(). + */ + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 2); + /* * Confirm that the CFE_TBL_GetAddress() call was done */ @@ -505,11 +512,26 @@ void Test_SAMPLE_APP_ProcessCC(void) UtAssert_STUB_COUNT(SAMPLE_LIB_Function, 1); /* - * Configure the CFE_TBL_GetAddress function to return an error - * Exercise the error return path + * Configure the CFE_TBL_GetAddress function to return an error. + * Exercise the error return path. + * Error at this point should add only one additional call to + * CFE_ES_WriteToSysLog() through the CFE_TBL_GetAddress() error path. */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_UNREGISTERED); UtAssert_INT32_EQ(SAMPLE_APP_Process(&TestMsg), CFE_TBL_ERR_UNREGISTERED); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 3); + + /* + * Configure CFE_TBL_ReleaseAddress() to return an error, exercising the + * error return path. + * Confirm three additional calls to CFE_ES_WriteToSysLog() - one + * reporting the table values, one through SAMPLE_APP_GetCrc() and one + * through the CFE_TBL_ReleaseAddress() error path. + */ + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_ReleaseAddress), CFE_TBL_ERR_NO_ACCESS); + UtAssert_INT32_EQ(SAMPLE_APP_Process(&TestMsg), CFE_TBL_ERR_NO_ACCESS); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 6); } void Test_SAMPLE_APP_VerifyCmdLength(void) From 599bfca018c5f010ec2e40435c19637cc1a37a76 Mon Sep 17 00:00:00 2001 From: Avi Date: Wed, 22 Feb 2023 10:30:53 +1000 Subject: [PATCH 10/23] Fix #45, Move cmds and utils into separate files --- CMakeLists.txt | 4 +- fsw/src/sample_app.c | 161 +----------------- fsw/src/sample_app.h | 13 +- fsw/src/sample_app_cmds.c | 107 ++++++++++++ fsw/src/sample_app_cmds.h | 36 ++++ fsw/src/sample_app_utils.c | 110 ++++++++++++ fsw/src/sample_app_utils.h | 36 ++++ unit-test/CMakeLists.txt | 3 +- .../coveragetest/coveragetest_sample_app.c | 1 - .../sample_app_coveragetest_common.h | 4 +- unit-test/inc/ut_sample_app.h | 1 - 11 files changed, 307 insertions(+), 169 deletions(-) create mode 100644 fsw/src/sample_app_cmds.c create mode 100644 fsw/src/sample_app_cmds.h create mode 100644 fsw/src/sample_app_utils.c create mode 100644 fsw/src/sample_app_utils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f83279b..d499b8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,9 @@ project(CFE_SAMPLE_APP C) # Create the app module -add_cfe_app(sample_app fsw/src/sample_app.c) +add_cfe_app(sample_app fsw/src/sample_app.c + fsw/src/sample_app_cmds.c + fsw/src/sample_app_utils.c) # Include the public API from sample_lib to demonstrate how # to call library-provided functions diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index 2961237..012d863 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -24,15 +24,15 @@ /* ** Include Files: */ +#include + +#include "sample_app.h" +#include "sample_app_cmds.h" +#include "sample_app_utils.h" #include "sample_app_events.h" #include "sample_app_version.h" -#include "sample_app.h" #include "sample_app_table.h" -/* The sample_lib module provides the SAMPLE_LIB_Function() prototype */ -#include -#include "sample_lib.h" - /* ** global data */ @@ -309,154 +309,3 @@ int32 SAMPLE_APP_ReportHousekeeping(const CFE_MSG_CommandHeader_t *Msg) return CFE_SUCCESS; } - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* */ -/* SAMPLE NOOP commands */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -int32 SAMPLE_APP_Noop(const SAMPLE_APP_NoopCmd_t *Msg) -{ - SAMPLE_APP_Data.CmdCounter++; - - CFE_EVS_SendEvent(SAMPLE_APP_COMMANDNOP_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: NOOP command %s", - SAMPLE_APP_VERSION); - - return CFE_SUCCESS; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* */ -/* Purpose: */ -/* This function resets all the global counter variables that are */ -/* part of the task telemetry. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 SAMPLE_APP_ResetCounters(const SAMPLE_APP_ResetCountersCmd_t *Msg) -{ - SAMPLE_APP_Data.CmdCounter = 0; - SAMPLE_APP_Data.ErrCounter = 0; - - CFE_EVS_SendEvent(SAMPLE_APP_COMMANDRST_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: RESET command"); - - return CFE_SUCCESS; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* */ -/* Purpose: */ -/* This function Process Ground Station Command */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 SAMPLE_APP_Process(const SAMPLE_APP_ProcessCmd_t *Msg) -{ - int32 status; - SAMPLE_APP_Table_t *TblPtr; - const char * TableName = "SAMPLE_APP.SampleAppTable"; - - /* Sample Use of Table */ - - status = CFE_TBL_GetAddress((void *)&TblPtr, SAMPLE_APP_Data.TblHandles[0]); - - if (status < CFE_SUCCESS) - { - CFE_ES_WriteToSysLog("Sample App: Fail to get table address: 0x%08lx", (unsigned long)status); - return status; - } - - CFE_ES_WriteToSysLog("Sample App: Table Value 1: %d Value 2: %d", TblPtr->Int1, TblPtr->Int2); - - SAMPLE_APP_GetCrc(TableName); - - status = CFE_TBL_ReleaseAddress(SAMPLE_APP_Data.TblHandles[0]); - if (status != CFE_SUCCESS) - { - CFE_ES_WriteToSysLog("Sample App: Fail to release table address: 0x%08lx", (unsigned long)status); - return status; - } - - /* Invoke a function provided by SAMPLE_APP_LIB */ - SAMPLE_LIB_Function(); - - return CFE_SUCCESS; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* */ -/* Verify command packet length */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -bool SAMPLE_APP_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) -{ - bool result = true; - size_t ActualLength = 0; - CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; - CFE_MSG_FcnCode_t FcnCode = 0; - - CFE_MSG_GetSize(MsgPtr, &ActualLength); - - /* - ** Verify the command packet length. - */ - if (ExpectedLength != ActualLength) - { - CFE_MSG_GetMsgId(MsgPtr, &MsgId); - CFE_MSG_GetFcnCode(MsgPtr, &FcnCode); - - CFE_EVS_SendEvent(SAMPLE_APP_LEN_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u", - (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, - (unsigned int)ExpectedLength); - - result = false; - - SAMPLE_APP_Data.ErrCounter++; - } - - return result; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Verify contents of First Table buffer contents */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 SAMPLE_APP_TblValidationFunc(void *TblData) -{ - int32 ReturnCode = CFE_SUCCESS; - SAMPLE_APP_Table_t *TblDataPtr = (SAMPLE_APP_Table_t *)TblData; - - /* - ** Sample Table Validation - */ - if (TblDataPtr->Int1 > SAMPLE_APP_TBL_ELEMENT_1_MAX) - { - /* First element is out of range, return an appropriate error code */ - ReturnCode = SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE; - } - - return ReturnCode; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* */ -/* Output CRC */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void SAMPLE_APP_GetCrc(const char *TableName) -{ - int32 status; - uint32 Crc; - CFE_TBL_Info_t TblInfoPtr; - - status = CFE_TBL_GetInfo(&TblInfoPtr, TableName); - if (status != CFE_SUCCESS) - { - CFE_ES_WriteToSysLog("Sample App: Error Getting Table Info"); - } - else - { - Crc = TblInfoPtr.Crc; - CFE_ES_WriteToSysLog("Sample App: CRC: 0x%08lX\n\n", (unsigned long)Crc); - } -} diff --git a/fsw/src/sample_app.h b/fsw/src/sample_app.h index 5e9006d..0f9d448 100644 --- a/fsw/src/sample_app.h +++ b/fsw/src/sample_app.h @@ -88,6 +88,11 @@ typedef struct CFE_TBL_Handle_t TblHandles[SAMPLE_APP_NUMBER_OF_TABLES]; } SAMPLE_APP_Data_t; +/* +** Global data structure +*/ +extern SAMPLE_APP_Data_t SAMPLE_APP_Data; + /****************************************************************************/ /* ** Local function prototypes. @@ -100,13 +105,5 @@ int32 SAMPLE_APP_Init(void); void SAMPLE_APP_ProcessCommandPacket(CFE_SB_Buffer_t *SBBufPtr); void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr); int32 SAMPLE_APP_ReportHousekeeping(const CFE_MSG_CommandHeader_t *Msg); -int32 SAMPLE_APP_ResetCounters(const SAMPLE_APP_ResetCountersCmd_t *Msg); -int32 SAMPLE_APP_Process(const SAMPLE_APP_ProcessCmd_t *Msg); -int32 SAMPLE_APP_Noop(const SAMPLE_APP_NoopCmd_t *Msg); -void SAMPLE_APP_GetCrc(const char *TableName); - -int32 SAMPLE_APP_TblValidationFunc(void *TblData); - -bool SAMPLE_APP_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength); #endif /* SAMPLE_APP_H */ diff --git a/fsw/src/sample_app_cmds.c b/fsw/src/sample_app_cmds.c new file mode 100644 index 0000000..b8cf2ff --- /dev/null +++ b/fsw/src/sample_app_cmds.c @@ -0,0 +1,107 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * \file + * This file contains the source code for the Sample App Ground Command-handling functions + */ + +/* +** Include Files: +*/ +#include "sample_app.h" +#include "sample_app_cmds.h" +#include "sample_app_events.h" +#include "sample_app_version.h" +#include "sample_app_table.h" +#include "sample_app_utils.h" +#include "sample_app_msg.h" + +/* The sample_lib module provides the SAMPLE_Function() prototype */ +#include "sample_lib.h" + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* SAMPLE NOOP commands */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +int32 SAMPLE_APP_Noop(const SAMPLE_APP_NoopCmd_t *Msg) +{ + SAMPLE_APP_Data.CmdCounter++; + + CFE_EVS_SendEvent(SAMPLE_APP_COMMANDNOP_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: NOOP command %s", + SAMPLE_APP_VERSION); + + return CFE_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* Purpose: */ +/* This function resets all the global counter variables that are */ +/* part of the task telemetry. */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 SAMPLE_APP_ResetCounters(const SAMPLE_APP_ResetCountersCmd_t *Msg) +{ + SAMPLE_APP_Data.CmdCounter = 0; + SAMPLE_APP_Data.ErrCounter = 0; + + CFE_EVS_SendEvent(SAMPLE_APP_COMMANDRST_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: RESET command"); + + return CFE_SUCCESS; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* Purpose: */ +/* This function Process Ground Station Command */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 SAMPLE_APP_Process(const SAMPLE_APP_ProcessCmd_t *Msg) +{ + int32 status; + SAMPLE_APP_Table_t *TblPtr; + const char * TableName = "SAMPLE_APP.SampleAppTable"; + + /* Sample Use of Table */ + + status = CFE_TBL_GetAddress((void *)&TblPtr, SAMPLE_APP_Data.TblHandles[0]); + + if (status < CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("Sample App: Fail to get table address: 0x%08lx", (unsigned long)status); + return status; + } + + CFE_ES_WriteToSysLog("Sample App: Table Value 1: %d Value 2: %d", TblPtr->Int1, TblPtr->Int2); + + SAMPLE_APP_GetCrc(TableName); + + status = CFE_TBL_ReleaseAddress(SAMPLE_APP_Data.TblHandles[0]); + if (status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("Sample App: Fail to release table address: 0x%08lx", (unsigned long)status); + return status; + } + + /* Invoke a function provided by SAMPLE_APP_LIB */ + SAMPLE_LIB_Function(); + + return CFE_SUCCESS; +} \ No newline at end of file diff --git a/fsw/src/sample_app_cmds.h b/fsw/src/sample_app_cmds.h new file mode 100644 index 0000000..7b899e9 --- /dev/null +++ b/fsw/src/sample_app_cmds.h @@ -0,0 +1,36 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * This file contains the prototypes for the Sample App Ground Command-handling functions + */ + +#ifndef SAMPLE_APP_CMDS_H +#define SAMPLE_APP_CMDS_H + +/* +** Required header files. +*/ +#include "sample_app.h" + +int32 SAMPLE_APP_ResetCounters(const SAMPLE_APP_ResetCountersCmd_t *Msg); +int32 SAMPLE_APP_Process(const SAMPLE_APP_ProcessCmd_t *Msg); +int32 SAMPLE_APP_Noop(const SAMPLE_APP_NoopCmd_t *Msg); + +#endif /* SAMPLE_APP_CMDS_H */ \ No newline at end of file diff --git a/fsw/src/sample_app_utils.c b/fsw/src/sample_app_utils.c new file mode 100644 index 0000000..9489e6b --- /dev/null +++ b/fsw/src/sample_app_utils.c @@ -0,0 +1,110 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * \file + * This file contains the source code for the Sample App utility functions + */ + +/* +** Include Files: +*/ +#include "sample_app.h" +#include "sample_app_events.h" +#include "sample_app_table.h" +#include "sample_app_utils.h" + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* Verify command packet length */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +bool SAMPLE_APP_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) +{ + bool result = true; + size_t ActualLength = 0; + CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; + CFE_MSG_FcnCode_t FcnCode = 0; + + CFE_MSG_GetSize(MsgPtr, &ActualLength); + + /* + ** Verify the command packet length. + */ + if (ExpectedLength != ActualLength) + { + CFE_MSG_GetMsgId(MsgPtr, &MsgId); + CFE_MSG_GetFcnCode(MsgPtr, &FcnCode); + + CFE_EVS_SendEvent(SAMPLE_APP_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u", + (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, + (unsigned int)ExpectedLength); + + result = false; + + SAMPLE_APP_Data.ErrCounter++; + } + + return result; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Verify contents of First Table buffer contents */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +int32 SAMPLE_APP_TblValidationFunc(void *TblData) +{ + int32 ReturnCode = CFE_SUCCESS; + SAMPLE_APP_Table_t *TblDataPtr = (SAMPLE_APP_Table_t *)TblData; + + /* + ** Sample Table Validation + */ + if (TblDataPtr->Int1 > SAMPLE_APP_TBL_ELEMENT_1_MAX) + { + /* First element is out of range, return an appropriate error code */ + ReturnCode = SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE; + } + + return ReturnCode; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* */ +/* Output CRC */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void SAMPLE_APP_GetCrc(const char *TableName) +{ + int32 status; + uint32 Crc; + CFE_TBL_Info_t TblInfoPtr; + + status = CFE_TBL_GetInfo(&TblInfoPtr, TableName); + if (status != CFE_SUCCESS) + { + CFE_ES_WriteToSysLog("Sample App: Error Getting Table Info"); + } + else + { + Crc = TblInfoPtr.Crc; + CFE_ES_WriteToSysLog("Sample App: CRC: 0x%08lX\n\n", (unsigned long)Crc); + } +} diff --git a/fsw/src/sample_app_utils.h b/fsw/src/sample_app_utils.h new file mode 100644 index 0000000..369f050 --- /dev/null +++ b/fsw/src/sample_app_utils.h @@ -0,0 +1,36 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * This file contains the prototypes for the Sample App utility functions + */ + +#ifndef SAMPLE_APP_UTILS_H +#define SAMPLE_APP_UTILS_H + +/* +** Required header files. +*/ +#include "sample_app.h" + +bool SAMPLE_APP_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength); +int32 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/CMakeLists.txt b/unit-test/CMakeLists.txt index ed625c7..224c97d 100644 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -23,7 +23,6 @@ include_directories(${PROJECT_SOURCE_DIR}/fsw/src) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) - # Add a coverage test executable called "sample_app-ALL" that # covers all of the functions in sample_app. # @@ -34,6 +33,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) add_cfe_coverage_test(sample_app ALL "coveragetest/coveragetest_sample_app.c" "${CFE_SAMPLE_APP_SOURCE_DIR}/fsw/src/sample_app.c" + "${CFE_SAMPLE_APP_SOURCE_DIR}/fsw/src/sample_app_cmds.c" + "${CFE_SAMPLE_APP_SOURCE_DIR}/fsw/src/sample_app_utils.c" ) # The sample_app uses library functions provided by sample_lib so must be linked diff --git a/unit-test/coveragetest/coveragetest_sample_app.c b/unit-test/coveragetest/coveragetest_sample_app.c index a1ca631..e8bfd2f 100644 --- a/unit-test/coveragetest/coveragetest_sample_app.c +++ b/unit-test/coveragetest/coveragetest_sample_app.c @@ -35,7 +35,6 @@ /* * Includes */ - #include "sample_lib.h" /* For SAMPLE_LIB_Function */ #include "sample_app_coveragetest_common.h" #include "ut_sample_app.h" diff --git a/unit-test/coveragetest/sample_app_coveragetest_common.h b/unit-test/coveragetest/sample_app_coveragetest_common.h index 134e2ca..464a4a9 100644 --- a/unit-test/coveragetest/sample_app_coveragetest_common.h +++ b/unit-test/coveragetest/sample_app_coveragetest_common.h @@ -34,8 +34,10 @@ #include "utstubs.h" #include "cfe.h" -#include "sample_app_events.h" #include "sample_app.h" +#include "sample_app_cmds.h" +#include "sample_app_utils.h" +#include "sample_app_events.h" #include "sample_app_table.h" /* diff --git a/unit-test/inc/ut_sample_app.h b/unit-test/inc/ut_sample_app.h index ca8567e..88f222a 100644 --- a/unit-test/inc/ut_sample_app.h +++ b/unit-test/inc/ut_sample_app.h @@ -39,7 +39,6 @@ * Necessary to include these here to get the definition of the * "SAMPLE_APP_Data_t" typedef. */ -#include "sample_app_events.h" #include "sample_app.h" /* From 6d3d30e8c95f1ba47e6e848b4e613c7f61a59735 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 25 Oct 2023 16:12:30 -0400 Subject: [PATCH 11/23] Fix #207, organize source files according to current patterns Re-organize the source files to adhere to the recommended patterns. --- CMakeLists.txt | 8 +-- arch_build.cmake | 27 +++++++++ config/default_sample_app_fcncodes.h | 42 ++++++++++++++ config/default_sample_app_internal_cfg.h | 44 ++++++++++++++ config/default_sample_app_mission_cfg.h | 36 ++++++++++++ config/default_sample_app_msg.h | 38 +++++++++++++ config/default_sample_app_msgdefs.h | 44 ++++++++++++++ .../default_sample_app_msgids.h | 8 +-- .../default_sample_app_msgstruct.h | 57 ++++++++++--------- .../default_sample_app_perfids.h | 6 +- config/default_sample_app_platform_cfg.h | 41 +++++++++++++ .../default_sample_app_tbl.h | 23 ++++---- config/default_sample_app_tbldefs.h | 45 +++++++++++++++ config/default_sample_app_tblstruct.h | 45 +++++++++++++++ .../sample_app_eventids.h} | 2 +- fsw/src/sample_app.c | 6 +- fsw/src/sample_app.h | 14 +---- fsw/tables/sample_app_tbl.c | 2 +- mission_build.cmake | 49 ++++++++++++++++ .../sample_app_coveragetest_common.h | 4 +- unit-test/inc/ut_sample_app.h | 2 +- 21 files changed, 470 insertions(+), 73 deletions(-) create mode 100644 arch_build.cmake create mode 100644 config/default_sample_app_fcncodes.h create mode 100644 config/default_sample_app_internal_cfg.h create mode 100644 config/default_sample_app_mission_cfg.h create mode 100644 config/default_sample_app_msg.h create mode 100644 config/default_sample_app_msgdefs.h rename fsw/platform_inc/sample_app_msgids.h => config/default_sample_app_msgids.h (87%) rename fsw/src/sample_app_msg.h => config/default_sample_app_msgstruct.h (60%) rename fsw/mission_inc/sample_app_perfids.h => config/default_sample_app_perfids.h (93%) create mode 100644 config/default_sample_app_platform_cfg.h rename fsw/platform_inc/sample_app_table.h => config/default_sample_app_tbl.h (70%) create mode 100644 config/default_sample_app_tbldefs.h create mode 100644 config/default_sample_app_tblstruct.h rename fsw/{src/sample_app_events.h => inc/sample_app_eventids.h} (97%) create mode 100644 mission_build.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f83279b..70e099f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ project(CFE_SAMPLE_APP C) # Create the app module add_cfe_app(sample_app fsw/src/sample_app.c) +target_include_directories(sample_app PUBLIC fsw/inc) # Include the public API from sample_lib to demonstrate how # to call library-provided functions add_cfe_app_dependency(sample_app sample_lib) @@ -10,14 +11,9 @@ add_cfe_app_dependency(sample_app sample_lib) # Add table add_cfe_tables(sample_app fsw/tables/sample_app_tbl.c) -target_include_directories(sample_app PUBLIC - fsw/mission_inc - fsw/platform_inc -) - # If UT is enabled, then add the tests from the subdirectory # Note that this is an app, and therefore does not provide -# stub functions, as other entities would not typically make +# stub functions, as other entities would not typically make # direct function calls into this application. if (ENABLE_UNIT_TESTS) add_subdirectory(unit-test) diff --git a/arch_build.cmake b/arch_build.cmake new file mode 100644 index 0000000..d2d95e2 --- /dev/null +++ b/arch_build.cmake @@ -0,0 +1,27 @@ +########################################################### +# +# SAMPLE_APP platform build setup +# +# This file is evaluated as part of the "prepare" stage +# and can be used to set up prerequisites for the build, +# such as generating header files +# +########################################################### + +# The list of header files that control the SAMPLE_APP configuration +set(SAMPLE_APP_PLATFORM_CONFIG_FILE_LIST + sample_app_internal_cfg.h + sample_app_platform_cfg.h + sample_app_perfids.h + sample_app_msgids.h +) + +# Create wrappers around the all the config header files +# This makes them individually overridable by the missions, without modifying +# the distribution default copies +foreach(SAMPLE_APP_CFGFILE ${SAMPLE_APP_PLATFORM_CONFIG_FILE_LIST}) + generate_config_includefile( + FILE_NAME "${SAMPLE_APP_CFGFILE}" + FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${SAMPLE_APP_CFGFILE}" + ) +endforeach() diff --git a/config/default_sample_app_fcncodes.h b/config/default_sample_app_fcncodes.h new file mode 100644 index 0000000..aec457f --- /dev/null +++ b/config/default_sample_app_fcncodes.h @@ -0,0 +1,42 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the SAMPLE_APP command function codes + * + * @note + * This file should be strictly limited to the command/function code (CC) + * macro definitions. Other definitions such as enums, typedefs, or other + * macros should be placed in the msgdefs.h or msg.h files. + */ +#ifndef SAMPLE_APP_FCNCODES_H +#define SAMPLE_APP_FCNCODES_H + +/************************************************************************ + * Macro Definitions + ************************************************************************/ + +/* +** Sample App command codes +*/ +#define SAMPLE_APP_NOOP_CC 0 +#define SAMPLE_APP_RESET_COUNTERS_CC 1 +#define SAMPLE_APP_PROCESS_CC 2 + +#endif diff --git a/config/default_sample_app_internal_cfg.h b/config/default_sample_app_internal_cfg.h new file mode 100644 index 0000000..32862ae --- /dev/null +++ b/config/default_sample_app_internal_cfg.h @@ -0,0 +1,44 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * SAMPLE_APP Application Private Config Definitions + * + * This provides default values for configurable items that are internal + * to this module and do NOT affect the interface(s) of this module. Changes + * to items in this file only affect the local module and will be transparent + * to external entities that are using the public interface(s). + * + * @note This file may be overridden/superceded by mission-provided defintions + * either by overriding this header or by generating definitions from a command/data + * dictionary tool. + */ +#ifndef SAMPLE_APP_INTERNAL_CFG_H +#define SAMPLE_APP_INTERNAL_CFG_H + +/***********************************************************************/ +#define SAMPLE_APP_PIPE_DEPTH 32 /* Depth of the Command Pipe for Application */ + +#define SAMPLE_APP_NUMBER_OF_TABLES 1 /* Number of Table(s) */ + +#define SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE -1 + +#define SAMPLE_APP_TBL_ELEMENT_1_MAX 10 + +#endif diff --git a/config/default_sample_app_mission_cfg.h b/config/default_sample_app_mission_cfg.h new file mode 100644 index 0000000..93d3307 --- /dev/null +++ b/config/default_sample_app_mission_cfg.h @@ -0,0 +1,36 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * SAMPLE_APP Application Mission Configuration Header File + * + * This is a compatibility header for the "mission_cfg.h" file that has + * traditionally provided public config definitions for each CFS app. + * + * @note This file may be overridden/superceded by mission-provided defintions + * either by overriding this header or by generating definitions from a command/data + * dictionary tool. + */ +#ifndef SAMPLE_APP_MISSION_CFG_H +#define SAMPLE_APP_MISSION_CFG_H + +/* Placeholder - SAMPLE_APP currently has no mission-scope config options */ + +#endif diff --git a/config/default_sample_app_msg.h b/config/default_sample_app_msg.h new file mode 100644 index 0000000..1d94e43 --- /dev/null +++ b/config/default_sample_app_msg.h @@ -0,0 +1,38 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the SAMPLE_APP command and telemetry + * message data types. + * + * This is a compatibility header for the "sample_app_msg.h" file that has + * traditionally provided the message definitions for cFS apps. + * + * @note This file may be overridden/superceded by mission-provided defintions + * either by overriding this header or by generating definitions from a command/data + * dictionary tool. + */ +#ifndef SAMPLE_APP_MSG_H +#define SAMPLE_APP_MSG_H + +#include "sample_app_mission_cfg.h" +#include "sample_app_msgdefs.h" +#include "sample_app_msgstruct.h" + +#endif diff --git a/config/default_sample_app_msgdefs.h b/config/default_sample_app_msgdefs.h new file mode 100644 index 0000000..7ea7b82 --- /dev/null +++ b/config/default_sample_app_msgdefs.h @@ -0,0 +1,44 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the SAMPLE_APP command and telemetry + * message constant definitions. + * + * For SAMPLE_APP this is only the function/command code definitions + */ +#ifndef SAMPLE_APP_MSGDEFS_H +#define SAMPLE_APP_MSGDEFS_H + +#include "common_types.h" +#include "sample_app_fcncodes.h" + +/*************************************************************************/ +/* +** Type definition (Sample App housekeeping) +*/ + +typedef struct +{ + uint8 CommandErrorCounter; + uint8 CommandCounter; + uint8 spare[2]; +} SAMPLE_APP_HkTlm_Payload_t; + +#endif diff --git a/fsw/platform_inc/sample_app_msgids.h b/config/default_sample_app_msgids.h similarity index 87% rename from fsw/platform_inc/sample_app_msgids.h rename to config/default_sample_app_msgids.h index 154569e..6b11e55 100644 --- a/fsw/platform_inc/sample_app_msgids.h +++ b/config/default_sample_app_msgids.h @@ -18,12 +18,8 @@ /** * @file - * - * Define Sample App Message IDs - * - * \note The Sample App assumes default configuration which uses V1 of message id implementation + * SAMPLE_APP Application Message IDs */ - #ifndef SAMPLE_APP_MSGIDS_H #define SAMPLE_APP_MSGIDS_H @@ -33,4 +29,4 @@ /* V1 Telemetry Message IDs must be 0x08xx */ #define SAMPLE_APP_HK_TLM_MID 0x0883 -#endif /* SAMPLE_APP_MSGIDS_H */ +#endif diff --git a/fsw/src/sample_app_msg.h b/config/default_sample_app_msgstruct.h similarity index 60% rename from fsw/src/sample_app_msg.h rename to config/default_sample_app_msgstruct.h index 537d1d7..90d1a47 100644 --- a/fsw/src/sample_app_msg.h +++ b/config/default_sample_app_msgstruct.h @@ -18,30 +18,26 @@ /** * @file + * Specification for the SAMPLE_APP command and telemetry + * message data types. * - * Define SAMPLE App Messages and info + * @note + * Constants and enumerated types related to these message structures + * are defined in sample_app_msgdefs.h. */ +#ifndef SAMPLE_APP_MSGSTRUCT_H +#define SAMPLE_APP_MSGSTRUCT_H -#ifndef SAMPLE_APP_MSG_H -#define SAMPLE_APP_MSG_H +/************************************************************************ + * Includes + ************************************************************************/ -/* -** SAMPLE App command codes -*/ -#define SAMPLE_APP_NOOP_CC 0 -#define SAMPLE_APP_RESET_COUNTERS_CC 1 -#define SAMPLE_APP_PROCESS_CC 2 +#include "sample_app_mission_cfg.h" +#include "sample_app_msgdefs.h" +#include "cfe_msg_hdr.h" /*************************************************************************/ -/* -** Type definition (generic "no arguments" command) -*/ -typedef struct -{ - CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command header */ -} SAMPLE_APP_NoArgsCmd_t; - /* ** The following commands all share the "NoArgs" format ** @@ -49,21 +45,30 @@ typedef struct ** allows them to change independently in the future without changing the prototype ** of the handler function */ -typedef SAMPLE_APP_NoArgsCmd_t SAMPLE_APP_NoopCmd_t; -typedef SAMPLE_APP_NoArgsCmd_t SAMPLE_APP_ResetCountersCmd_t; -typedef SAMPLE_APP_NoArgsCmd_t SAMPLE_APP_ProcessCmd_t; +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ +} SAMPLE_APP_NoopCmd_t; + +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ +} SAMPLE_APP_ResetCountersCmd_t; + +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ +} SAMPLE_APP_ProcessCmd_t; /*************************************************************************/ /* -** Type definition (SAMPLE App housekeeping) +** Type definition (Sample App housekeeping) */ typedef struct { - uint8 CommandErrorCounter; - uint8 CommandCounter; - uint8 spare[2]; -} SAMPLE_APP_HkTlm_Payload_t; + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ +} SAMPLE_APP_SendHkCmd_t; typedef struct { @@ -71,4 +76,4 @@ typedef struct SAMPLE_APP_HkTlm_Payload_t Payload; /**< \brief Telemetry payload */ } SAMPLE_APP_HkTlm_t; -#endif /* SAMPLE_APP_MSG_H */ +#endif /* SAMPLE_APP_MSGSTRUCT_H */ diff --git a/fsw/mission_inc/sample_app_perfids.h b/config/default_sample_app_perfids.h similarity index 93% rename from fsw/mission_inc/sample_app_perfids.h rename to config/default_sample_app_perfids.h index d87ea64..5c83334 100644 --- a/fsw/mission_inc/sample_app_perfids.h +++ b/config/default_sample_app_perfids.h @@ -18,13 +18,11 @@ /** * @file - * - * Define Sample App Performance IDs + * Define TO Lab Performance IDs */ - #ifndef SAMPLE_APP_PERFIDS_H #define SAMPLE_APP_PERFIDS_H #define SAMPLE_APP_PERF_ID 91 -#endif /* SAMPLE_APP_PERFIDS_H */ +#endif diff --git a/config/default_sample_app_platform_cfg.h b/config/default_sample_app_platform_cfg.h new file mode 100644 index 0000000..d62a136 --- /dev/null +++ b/config/default_sample_app_platform_cfg.h @@ -0,0 +1,41 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * SAMPLE_APP Application Platform Configuration Header File + * + * This is a compatibility header for the "platform_cfg.h" file that has + * traditionally provided both public and private config definitions + * for each CFS app. + * + * These definitions are now provided in two separate files, one for + * the public/mission scope and one for internal scope. + * + * @note This file may be overridden/superceded by mission-provided defintions + * either by overriding this header or by generating definitions from a command/data + * dictionary tool. + */ +#ifndef SAMPLE_APP_PLATFORM_CFG_H +#define SAMPLE_APP_PLATFORM_CFG_H + +#include "sample_app_mission_cfg.h" +#include "sample_app_internal_cfg.h" + +#endif diff --git a/fsw/platform_inc/sample_app_table.h b/config/default_sample_app_tbl.h similarity index 70% rename from fsw/platform_inc/sample_app_table.h rename to config/default_sample_app_tbl.h index ca688f0..f62b974 100644 --- a/fsw/platform_inc/sample_app_table.h +++ b/config/default_sample_app_tbl.h @@ -18,20 +18,19 @@ /** * @file + * Specification for the SAMPLE_APP table structures * - * Define sample app table + * @note + * Constants and enumerated types related to these table structures + * are defined in sample_app_tbldefs.h. */ +#ifndef SAMPLE_APP_TBL_H +#define SAMPLE_APP_TBL_H -#ifndef SAMPLE_APP_TABLE_H -#define SAMPLE_APP_TABLE_H +#include "sample_app_tbldefs.h" +#include "sample_app_tblstruct.h" -/* -** Table structure -*/ -typedef struct -{ - uint16 Int1; - uint16 Int2; -} SAMPLE_APP_Table_t; +/* Define filenames of default data images for tables */ +#define SAMPLE_APP_TABLE_FILE "/cf/sample_app_tbl.tbl" -#endif /* SAMPLE_APP_TABLE_H */ +#endif diff --git a/config/default_sample_app_tbldefs.h b/config/default_sample_app_tbldefs.h new file mode 100644 index 0000000..7338708 --- /dev/null +++ b/config/default_sample_app_tbldefs.h @@ -0,0 +1,45 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the SAMPLE_APP table related + * constant definitions. + * + * @note + * These Macro definitions have been put in this file (instead of + * sample_app_tbl.h). DO NOT PUT ANY TYPEDEFS OR + * STRUCTURE DEFINITIONS IN THIS FILE! + * ADD THEM TO sample_app_tbl.h IF NEEDED! + */ +#ifndef SAMPLE_APP_TBLDEFS_H +#define SAMPLE_APP_TBLDEFS_H + +#include "common_types.h" +#include "sample_app_mission_cfg.h" + +/* +** Example Table structure +*/ +typedef struct +{ + uint16 Int1; + uint16 Int2; +} SAMPLE_APP_Table_t; + +#endif diff --git a/config/default_sample_app_tblstruct.h b/config/default_sample_app_tblstruct.h new file mode 100644 index 0000000..3cd7882 --- /dev/null +++ b/config/default_sample_app_tblstruct.h @@ -0,0 +1,45 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * Specification for the SAMPLE_APP table structures + * + * Provides default definitions for SAMPLE_APP table structures + * + * @note This file may be overridden/superceded by mission-provided defintions + * either by overriding this header or by generating definitions from a command/data + * dictionary tool. + */ +#ifndef SAMPLE_APP_TBLSTRUCT_H +#define SAMPLE_APP_TBLSTRUCT_H + +/************************************************************************* + * Includes + *************************************************************************/ +#include "sample_app_tbldefs.h" + +/************************************************************************ + * Macro Definitions + ************************************************************************/ + +/************************************************************************* + * Type Definitions + *************************************************************************/ + +#endif diff --git a/fsw/src/sample_app_events.h b/fsw/inc/sample_app_eventids.h similarity index 97% rename from fsw/src/sample_app_events.h rename to fsw/inc/sample_app_eventids.h index 46e7aaf..b92b9e8 100644 --- a/fsw/src/sample_app_events.h +++ b/fsw/inc/sample_app_eventids.h @@ -19,7 +19,7 @@ /** * @file * - * Define SAMPLE App Events IDs + * Define Sample App Events IDs */ #ifndef SAMPLE_APP_EVENTS_H diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index 2961237..75fa897 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -24,10 +24,10 @@ /* ** Include Files: */ -#include "sample_app_events.h" +#include "sample_app_eventids.h" #include "sample_app_version.h" #include "sample_app.h" -#include "sample_app_table.h" +#include "sample_app_tbl.h" /* The sample_lib module provides the SAMPLE_LIB_Function() prototype */ #include @@ -239,7 +239,7 @@ void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); /* - ** Process "known" SAMPLE app ground commands + ** Process "known" Sample App ground commands */ switch (CommandCode) { diff --git a/fsw/src/sample_app.h b/fsw/src/sample_app.h index 5e9006d..922ddd4 100644 --- a/fsw/src/sample_app.h +++ b/fsw/src/sample_app.h @@ -34,21 +34,13 @@ #include "cfe_sb.h" #include "cfe_es.h" +#include "sample_app_mission_cfg.h" +#include "sample_app_platform_cfg.h" + #include "sample_app_perfids.h" #include "sample_app_msgids.h" #include "sample_app_msg.h" -/***********************************************************************/ -#define SAMPLE_APP_PIPE_DEPTH 32 /* Depth of the Command Pipe for Application */ - -#define SAMPLE_APP_NUMBER_OF_TABLES 1 /* Number of Table(s) */ - -/* Define filenames of default data images for tables */ -#define SAMPLE_APP_TABLE_FILE "/cf/sample_app_tbl.tbl" - -#define SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE -1 - -#define SAMPLE_APP_TBL_ELEMENT_1_MAX 10 /************************************************************************ ** Type Definitions *************************************************************************/ diff --git a/fsw/tables/sample_app_tbl.c b/fsw/tables/sample_app_tbl.c index 435409d..c380534 100644 --- a/fsw/tables/sample_app_tbl.c +++ b/fsw/tables/sample_app_tbl.c @@ -17,7 +17,7 @@ ************************************************************************/ #include "cfe_tbl_filedef.h" /* Required to obtain the CFE_TBL_FILEDEF macro definition */ -#include "sample_app_table.h" +#include "sample_app_tbl.h" /* ** The following is an example of the declaration statement that defines the desired diff --git a/mission_build.cmake b/mission_build.cmake new file mode 100644 index 0000000..9b7d460 --- /dev/null +++ b/mission_build.cmake @@ -0,0 +1,49 @@ +########################################################### +# +# SAMPLE_APP mission build setup +# +# This file is evaluated as part of the "prepare" stage +# and can be used to set up prerequisites for the build, +# such as generating header files +# +########################################################### + +# The list of header files that control the SAMPLE_APP configuration +set(SAMPLE_APP_MISSION_CONFIG_FILE_LIST + sample_app_fcncodes.h + sample_app_mission_cfg.h + sample_app_perfids.h + sample_app_msg.h + sample_app_msgdefs.h + sample_app_msgstruct.h + sample_app_tbl.h + sample_app_tbldefs.h + sample_app_tblstruct.h +) + +if (CFE_EDS_ENABLED_BUILD) + + # In an EDS-based build, these files come generated from the EDS tool + set(SAMPLE_APP_CFGFILE_SRC_sample_app_tbldefs "sample_app_eds_typedefs.h") + set(SAMPLE_APP_CFGFILE_SRC_sample_app_tblstruct "sample_app_eds_typedefs.h") + set(SAMPLE_APP_CFGFILE_SRC_sample_app_msgdefs "sample_app_eds_typedefs.h") + set(SAMPLE_APP_CFGFILE_SRC_sample_app_msgstruct "sample_app_eds_typedefs.h") + set(SAMPLE_APP_CFGFILE_SRC_sample_app_fcncodes "sample_app_eds_cc.h") + +endif(CFE_EDS_ENABLED_BUILD) + +# Create wrappers around the all the config header files +# This makes them individually overridable by the missions, without modifying +# the distribution default copies +foreach(SAMPLE_APP_CFGFILE ${SAMPLE_APP_MISSION_CONFIG_FILE_LIST}) + get_filename_component(CFGKEY "${SAMPLE_APP_CFGFILE}" NAME_WE) + if (DEFINED SAMPLE_APP_CFGFILE_SRC_${CFGKEY}) + set(DEFAULT_SOURCE GENERATED_FILE "${SAMPLE_APP_CFGFILE_SRC_${CFGKEY}}") + else() + set(DEFAULT_SOURCE FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${SAMPLE_APP_CFGFILE}") + endif() + generate_config_includefile( + FILE_NAME "${SAMPLE_APP_CFGFILE}" + ${DEFAULT_SOURCE} + ) +endforeach() diff --git a/unit-test/coveragetest/sample_app_coveragetest_common.h b/unit-test/coveragetest/sample_app_coveragetest_common.h index 134e2ca..3f48bf6 100644 --- a/unit-test/coveragetest/sample_app_coveragetest_common.h +++ b/unit-test/coveragetest/sample_app_coveragetest_common.h @@ -34,9 +34,9 @@ #include "utstubs.h" #include "cfe.h" -#include "sample_app_events.h" +#include "sample_app_eventids.h" #include "sample_app.h" -#include "sample_app_table.h" +#include "sample_app_tbl.h" /* * Macro to add a test case to the list of tests to execute diff --git a/unit-test/inc/ut_sample_app.h b/unit-test/inc/ut_sample_app.h index ca8567e..858ef29 100644 --- a/unit-test/inc/ut_sample_app.h +++ b/unit-test/inc/ut_sample_app.h @@ -39,7 +39,7 @@ * Necessary to include these here to get the definition of the * "SAMPLE_APP_Data_t" typedef. */ -#include "sample_app_events.h" +#include "sample_app_eventids.h" #include "sample_app.h" /* From b7c1b4a559ae4d2c6cef07f3af2fd24a98ce6dcc Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Mon, 30 Oct 2023 10:36:45 -0400 Subject: [PATCH 12/23] HotFix #209, correct merge issues related to event names --- fsw/src/sample_app.c | 2 +- fsw/src/sample_app_cmds.c | 4 ++-- fsw/src/sample_app_utils.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index 9b93285..d2abb76 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -191,7 +191,7 @@ int32 SAMPLE_APP_Init(void) status = CFE_TBL_Load(SAMPLE_APP_Data.TblHandles[0], CFE_TBL_SRC_FILE, SAMPLE_APP_TABLE_FILE); } - CFE_EVS_SendEvent(SAMPLE_APP_STARTUP_INF_EID, CFE_EVS_EventType_INFORMATION, "Sample App Initialized.%s", + CFE_EVS_SendEvent(SAMPLE_APP_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "Sample App Initialized.%s", SAMPLE_APP_VERSION_STRING); } diff --git a/fsw/src/sample_app_cmds.c b/fsw/src/sample_app_cmds.c index 5df7e96..fc635d5 100644 --- a/fsw/src/sample_app_cmds.c +++ b/fsw/src/sample_app_cmds.c @@ -44,7 +44,7 @@ int32 SAMPLE_APP_Noop(const SAMPLE_APP_NoopCmd_t *Msg) { SAMPLE_APP_Data.CmdCounter++; - CFE_EVS_SendEvent(SAMPLE_APP_COMMANDNOP_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: NOOP command %s", + CFE_EVS_SendEvent(SAMPLE_APP_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: NOOP command %s", SAMPLE_APP_VERSION); return CFE_SUCCESS; @@ -62,7 +62,7 @@ int32 SAMPLE_APP_ResetCounters(const SAMPLE_APP_ResetCountersCmd_t *Msg) SAMPLE_APP_Data.CmdCounter = 0; SAMPLE_APP_Data.ErrCounter = 0; - CFE_EVS_SendEvent(SAMPLE_APP_COMMANDRST_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: RESET command"); + CFE_EVS_SendEvent(SAMPLE_APP_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: RESET command"); return CFE_SUCCESS; } diff --git a/fsw/src/sample_app_utils.c b/fsw/src/sample_app_utils.c index 9c97201..a316dcf 100644 --- a/fsw/src/sample_app_utils.c +++ b/fsw/src/sample_app_utils.c @@ -51,7 +51,7 @@ bool SAMPLE_APP_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength CFE_MSG_GetMsgId(MsgPtr, &MsgId); CFE_MSG_GetFcnCode(MsgPtr, &FcnCode); - CFE_EVS_SendEvent(SAMPLE_APP_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + CFE_EVS_SendEvent(SAMPLE_APP_CMD_LEN_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u", (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, (unsigned int)ExpectedLength); From b309b83c766280c785a66c2b3e779fab7f95ff09 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 30 Oct 2023 12:48:06 -0400 Subject: [PATCH 13/23] v1.3.0-rc4+dev56 --- CHANGELOG.md | 10 ++++++++++ fsw/src/sample_app_version.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 116c3fc..d59533b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## Development Build: v1.3.0-rc4+dev56 +- Apply consistent Event ID names to common events +- Remove component-specific cFE header #includes +- Refactor SAMPLE_APP_Init/Process to remove multiple returns +- Add test for missing branch in SAMPLE_APP_Process() +- Zero out global data structure during initialization +- Move cmds and utils into separate files +- organize source files according to current patterns +- See , , , , , , and + ## Development Build: v1.3.0-rc4+dev39 - update cmake recipe - See diff --git a/fsw/src/sample_app_version.h b/fsw/src/sample_app_version.h index a2ea178..b29b42d 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 39 /*!< Development Build: Number of commits since baseline */ +#define SAMPLE_APP_BUILD_NUMBER 56 /*!< Development Build: Number of commits since baseline */ #define SAMPLE_APP_BUILD_BASELINE \ "v1.3.0-rc4" /*!< Development Build: git tag that is the base for the current development */ From d18673ea495c4fc7ab71e93d91f52782c0eea3c6 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 1 Nov 2023 09:52:33 -0400 Subject: [PATCH 14/23] Fix #210, symbol name updates and UT breakup Update internal symbol naming to better follow conventions. Notably, this renames the "SampleAppTable" to be "ExampleTable", among other things. This also adds a separate dispatch source file, splits the unit test into source file units as well. --- CMakeLists.txt | 11 +- config/default_sample_app_internal_cfg.h | 2 +- config/default_sample_app_tbldefs.h | 2 +- fsw/src/sample_app.c | 124 +---- fsw/src/sample_app.h | 3 - fsw/src/sample_app_cmds.c | 56 ++- fsw/src/sample_app_cmds.h | 12 +- fsw/src/sample_app_dispatch.c | 145 ++++++ fsw/src/sample_app_dispatch.h | 38 ++ fsw/src/sample_app_utils.c | 45 +- fsw/src/sample_app_utils.h | 1 - fsw/tables/sample_app_tbl.c | 6 +- unit-test/CMakeLists.txt | 63 ++- unit-test/common/eventcheck.c | 128 +++++ unit-test/common/eventcheck.h | 64 +++ unit-test/common/setup.c | 55 +++ unit-test/common/setup.h | 45 ++ .../coveragetest/coveragetest_sample_app.c | 463 ------------------ .../coveragetest_sample_app_cmds.c | 195 ++++++++ .../coveragetest_sample_app_dispatch.c | 257 ++++++++++ .../coveragetest_sample_app_utils.c | 97 ++++ .../sample_app_coveragetest_common.h | 16 +- unit-test/stubs/sample_app_cmds_stubs.c | 90 ++++ unit-test/stubs/sample_app_dispatch_stubs.c | 67 +++ unit-test/stubs/sample_app_global_stubs.c | 27 + .../sample_app_stubs.c} | 41 +- unit-test/stubs/sample_app_utils_stubs.c | 54 ++ 27 files changed, 1411 insertions(+), 696 deletions(-) create mode 100644 fsw/src/sample_app_dispatch.c create mode 100644 fsw/src/sample_app_dispatch.h create mode 100644 unit-test/common/eventcheck.c create mode 100644 unit-test/common/eventcheck.h create mode 100644 unit-test/common/setup.c create mode 100644 unit-test/common/setup.h create mode 100644 unit-test/coveragetest/coveragetest_sample_app_cmds.c create mode 100644 unit-test/coveragetest/coveragetest_sample_app_dispatch.c create mode 100644 unit-test/coveragetest/coveragetest_sample_app_utils.c create mode 100644 unit-test/stubs/sample_app_cmds_stubs.c create mode 100644 unit-test/stubs/sample_app_dispatch_stubs.c create mode 100644 unit-test/stubs/sample_app_global_stubs.c rename unit-test/{inc/ut_sample_app.h => stubs/sample_app_stubs.c} (58%) create mode 100644 unit-test/stubs/sample_app_utils_stubs.c diff --git a/CMakeLists.txt b/CMakeLists.txt index d84eea4..de47fce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,14 @@ project(CFE_SAMPLE_APP C) +set(APP_SRC_FILES + fsw/src/sample_app.c + fsw/src/sample_app_cmds.c + fsw/src/sample_app_dispatch.c + fsw/src/sample_app_utils.c +) + # Create the app module -add_cfe_app(sample_app fsw/src/sample_app.c - fsw/src/sample_app_cmds.c - fsw/src/sample_app_utils.c) +add_cfe_app(sample_app ${APP_SRC_FILES}) target_include_directories(sample_app PUBLIC fsw/inc) # Include the public API from sample_lib to demonstrate how diff --git a/config/default_sample_app_internal_cfg.h b/config/default_sample_app_internal_cfg.h index 32862ae..25d753f 100644 --- a/config/default_sample_app_internal_cfg.h +++ b/config/default_sample_app_internal_cfg.h @@ -35,7 +35,7 @@ /***********************************************************************/ #define SAMPLE_APP_PIPE_DEPTH 32 /* Depth of the Command Pipe for Application */ -#define SAMPLE_APP_NUMBER_OF_TABLES 1 /* Number of Table(s) */ +#define SAMPLE_APP_NUMBER_OF_TABLES 1 /* Number of Example Table(s) */ #define SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE -1 diff --git a/config/default_sample_app_tbldefs.h b/config/default_sample_app_tbldefs.h index 7338708..d478f00 100644 --- a/config/default_sample_app_tbldefs.h +++ b/config/default_sample_app_tbldefs.h @@ -40,6 +40,6 @@ typedef struct { uint16 Int1; uint16 Int2; -} SAMPLE_APP_Table_t; +} SAMPLE_APP_ExampleTable_t; #endif diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index d2abb76..674870d 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -24,14 +24,13 @@ /* ** Include Files: */ -#include - #include "sample_app.h" #include "sample_app_cmds.h" #include "sample_app_utils.h" #include "sample_app_eventids.h" -#include "sample_app_version.h" +#include "sample_app_dispatch.h" #include "sample_app_tbl.h" +#include "sample_app_version.h" /* ** global data @@ -84,7 +83,7 @@ void SAMPLE_APP_Main(void) if (status == CFE_SUCCESS) { - SAMPLE_APP_ProcessCommandPacket(SBBufPtr); + SAMPLE_APP_TaskPipe(SBBufPtr); } else { @@ -178,13 +177,13 @@ int32 SAMPLE_APP_Init(void) if (status == CFE_SUCCESS) { /* - ** Register Table(s) + ** Register Example Table(s) */ - status = CFE_TBL_Register(&SAMPLE_APP_Data.TblHandles[0], "SampleAppTable", sizeof(SAMPLE_APP_Table_t), + status = CFE_TBL_Register(&SAMPLE_APP_Data.TblHandles[0], "ExampleTable", sizeof(SAMPLE_APP_ExampleTable_t), CFE_TBL_OPT_DEFAULT, SAMPLE_APP_TblValidationFunc); if (status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("Sample App: Error Registering Table, RC = 0x%08lX\n", (unsigned long)status); + CFE_ES_WriteToSysLog("Sample App: Error Registering Example Table, RC = 0x%08lX\n", (unsigned long)status); } else { @@ -197,114 +196,3 @@ int32 SAMPLE_APP_Init(void) return status; } - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* */ -/* Purpose: */ -/* This routine will process any packet that is received on the Sample */ -/* App command pipe. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -void SAMPLE_APP_ProcessCommandPacket(CFE_SB_Buffer_t *SBBufPtr) -{ - CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; - - CFE_MSG_GetMsgId(&SBBufPtr->Msg, &MsgId); - - switch (CFE_SB_MsgIdToValue(MsgId)) - { - case SAMPLE_APP_CMD_MID: - SAMPLE_APP_ProcessGroundCommand(SBBufPtr); - break; - - case SAMPLE_APP_SEND_HK_MID: - SAMPLE_APP_ReportHousekeeping((CFE_MSG_CommandHeader_t *)SBBufPtr); - break; - - default: - CFE_EVS_SendEvent(SAMPLE_APP_MID_ERR_EID, CFE_EVS_EventType_ERROR, - "SAMPLE: invalid command packet,MID = 0x%x", (unsigned int)CFE_SB_MsgIdToValue(MsgId)); - break; - } -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* */ -/* Process Ground Commands */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr) -{ - CFE_MSG_FcnCode_t CommandCode = 0; - - CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); - - /* - ** Process "known" Sample App ground commands - */ - switch (CommandCode) - { - case SAMPLE_APP_NOOP_CC: - if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_NoopCmd_t))) - { - SAMPLE_APP_Noop((SAMPLE_APP_NoopCmd_t *)SBBufPtr); - } - break; - - case SAMPLE_APP_RESET_COUNTERS_CC: - if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_ResetCountersCmd_t))) - { - SAMPLE_APP_ResetCounters((SAMPLE_APP_ResetCountersCmd_t *)SBBufPtr); - } - break; - - case SAMPLE_APP_PROCESS_CC: - if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_ProcessCmd_t))) - { - SAMPLE_APP_Process((SAMPLE_APP_ProcessCmd_t *)SBBufPtr); - } - break; - - /* default case already found during FC vs length test */ - default: - CFE_EVS_SendEvent(SAMPLE_APP_CC_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid ground command code: CC = %d", - CommandCode); - break; - } -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* */ -/* Purpose: */ -/* This function is triggered in response to a task telemetry request */ -/* from the housekeeping task. This function will gather the App's */ -/* telemetry, packetize it and send it to the housekeeping task via */ -/* the software bus. */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 SAMPLE_APP_ReportHousekeeping(const CFE_MSG_CommandHeader_t *Msg) -{ - int i; - - /* - ** Get command execution counters... - */ - SAMPLE_APP_Data.HkTlm.Payload.CommandErrorCounter = SAMPLE_APP_Data.ErrCounter; - SAMPLE_APP_Data.HkTlm.Payload.CommandCounter = SAMPLE_APP_Data.CmdCounter; - - /* - ** Send housekeeping telemetry packet... - */ - CFE_SB_TimeStampMsg(CFE_MSG_PTR(SAMPLE_APP_Data.HkTlm.TelemetryHeader)); - CFE_SB_TransmitMsg(CFE_MSG_PTR(SAMPLE_APP_Data.HkTlm.TelemetryHeader), true); - - /* - ** Manage any pending table loads, validations, etc. - */ - for (i = 0; i < SAMPLE_APP_NUMBER_OF_TABLES; i++) - { - CFE_TBL_Manage(SAMPLE_APP_Data.TblHandles[i]); - } - - return CFE_SUCCESS; -} diff --git a/fsw/src/sample_app.h b/fsw/src/sample_app.h index d0d7e6a..321d1d8 100644 --- a/fsw/src/sample_app.h +++ b/fsw/src/sample_app.h @@ -90,8 +90,5 @@ extern SAMPLE_APP_Data_t SAMPLE_APP_Data; */ void SAMPLE_APP_Main(void); int32 SAMPLE_APP_Init(void); -void SAMPLE_APP_ProcessCommandPacket(CFE_SB_Buffer_t *SBBufPtr); -void SAMPLE_APP_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr); -int32 SAMPLE_APP_ReportHousekeeping(const CFE_MSG_CommandHeader_t *Msg); #endif /* SAMPLE_APP_H */ diff --git a/fsw/src/sample_app_cmds.c b/fsw/src/sample_app_cmds.c index fc635d5..6dfe79f 100644 --- a/fsw/src/sample_app_cmds.c +++ b/fsw/src/sample_app_cmds.c @@ -26,6 +26,7 @@ */ #include "sample_app.h" #include "sample_app_cmds.h" +#include "sample_app_msgids.h" #include "sample_app_eventids.h" #include "sample_app_version.h" #include "sample_app_tbl.h" @@ -35,12 +36,47 @@ /* The sample_lib module provides the SAMPLE_Function() prototype */ #include "sample_lib.h" +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* Purpose: */ +/* This function is triggered in response to a task telemetry request */ +/* from the housekeeping task. This function will gather the Apps */ +/* telemetry, packetize it and send it to the housekeeping task via */ +/* the software bus */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +CFE_Status_t SAMPLE_APP_SendHkCmd(const SAMPLE_APP_SendHkCmd_t *Msg) +{ + int i; + + /* + ** Get command execution counters... + */ + SAMPLE_APP_Data.HkTlm.Payload.CommandErrorCounter = SAMPLE_APP_Data.ErrCounter; + SAMPLE_APP_Data.HkTlm.Payload.CommandCounter = SAMPLE_APP_Data.CmdCounter; + + /* + ** Send housekeeping telemetry packet... + */ + CFE_SB_TimeStampMsg(CFE_MSG_PTR(SAMPLE_APP_Data.HkTlm.TelemetryHeader)); + CFE_SB_TransmitMsg(CFE_MSG_PTR(SAMPLE_APP_Data.HkTlm.TelemetryHeader), true); + + /* + ** Manage any pending table loads, validations, etc. + */ + for (i = 0; i < SAMPLE_APP_NUMBER_OF_TABLES; i++) + { + CFE_TBL_Manage(SAMPLE_APP_Data.TblHandles[i]); + } + + return CFE_SUCCESS; +} + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ /* */ /* SAMPLE NOOP commands */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -int32 SAMPLE_APP_Noop(const SAMPLE_APP_NoopCmd_t *Msg) +CFE_Status_t SAMPLE_APP_NoopCmd(const SAMPLE_APP_NoopCmd_t *Msg) { SAMPLE_APP_Data.CmdCounter++; @@ -57,7 +93,7 @@ int32 SAMPLE_APP_Noop(const SAMPLE_APP_NoopCmd_t *Msg) /* part of the task telemetry. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 SAMPLE_APP_ResetCounters(const SAMPLE_APP_ResetCountersCmd_t *Msg) +CFE_Status_t SAMPLE_APP_ResetCountersCmd(const SAMPLE_APP_ResetCountersCmd_t *Msg) { SAMPLE_APP_Data.CmdCounter = 0; SAMPLE_APP_Data.ErrCounter = 0; @@ -73,15 +109,16 @@ int32 SAMPLE_APP_ResetCounters(const SAMPLE_APP_ResetCountersCmd_t *Msg) /* This function Process Ground Station Command */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -int32 SAMPLE_APP_Process(const SAMPLE_APP_ProcessCmd_t *Msg) +CFE_Status_t SAMPLE_APP_ProcessCmd(const SAMPLE_APP_ProcessCmd_t *Msg) { - int32 status; - SAMPLE_APP_Table_t *TblPtr; - const char * TableName = "SAMPLE_APP.SampleAppTable"; + int32 status; + void * TblAddr; + SAMPLE_APP_ExampleTable_t *TblPtr; + const char * TableName = "SAMPLE_APP.ExampleTable"; - /* Sample Use of Table */ + /* Sample Use of Example Table */ - status = CFE_TBL_GetAddress((void *)&TblPtr, SAMPLE_APP_Data.TblHandles[0]); + status = CFE_TBL_GetAddress(&TblAddr, SAMPLE_APP_Data.TblHandles[0]); if (status < CFE_SUCCESS) { @@ -89,7 +126,8 @@ int32 SAMPLE_APP_Process(const SAMPLE_APP_ProcessCmd_t *Msg) return status; } - CFE_ES_WriteToSysLog("Sample App: Table Value 1: %d Value 2: %d", TblPtr->Int1, TblPtr->Int2); + TblPtr = TblAddr; + CFE_ES_WriteToSysLog("Sample App: Example Table Value 1: %d Value 2: %d", TblPtr->Int1, TblPtr->Int2); SAMPLE_APP_GetCrc(TableName); diff --git a/fsw/src/sample_app_cmds.h b/fsw/src/sample_app_cmds.h index 7b899e9..384ebe8 100644 --- a/fsw/src/sample_app_cmds.h +++ b/fsw/src/sample_app_cmds.h @@ -27,10 +27,12 @@ /* ** Required header files. */ -#include "sample_app.h" +#include "cfe_error.h" +#include "sample_app_msg.h" -int32 SAMPLE_APP_ResetCounters(const SAMPLE_APP_ResetCountersCmd_t *Msg); -int32 SAMPLE_APP_Process(const SAMPLE_APP_ProcessCmd_t *Msg); -int32 SAMPLE_APP_Noop(const SAMPLE_APP_NoopCmd_t *Msg); +CFE_Status_t SAMPLE_APP_SendHkCmd(const SAMPLE_APP_SendHkCmd_t *Msg); +CFE_Status_t SAMPLE_APP_ResetCountersCmd(const SAMPLE_APP_ResetCountersCmd_t *Msg); +CFE_Status_t SAMPLE_APP_ProcessCmd(const SAMPLE_APP_ProcessCmd_t *Msg); +CFE_Status_t SAMPLE_APP_NoopCmd(const SAMPLE_APP_NoopCmd_t *Msg); -#endif /* SAMPLE_APP_CMDS_H */ \ No newline at end of file +#endif /* SAMPLE_APP_CMDS_H */ diff --git a/fsw/src/sample_app_dispatch.c b/fsw/src/sample_app_dispatch.c new file mode 100644 index 0000000..7e2a256 --- /dev/null +++ b/fsw/src/sample_app_dispatch.c @@ -0,0 +1,145 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * \file + * This file contains the source code for the Sample App. + */ + +/* +** Include Files: +*/ +#include "sample_app.h" +#include "sample_app_dispatch.h" +#include "sample_app_cmds.h" +#include "sample_app_eventids.h" +#include "sample_app_msgids.h" +#include "sample_app_msg.h" + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* Verify command packet length */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +bool SAMPLE_APP_VerifyCmdLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) +{ + bool result = true; + size_t ActualLength = 0; + CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; + CFE_MSG_FcnCode_t FcnCode = 0; + + CFE_MSG_GetSize(MsgPtr, &ActualLength); + + /* + ** Verify the command packet length. + */ + if (ExpectedLength != ActualLength) + { + CFE_MSG_GetMsgId(MsgPtr, &MsgId); + CFE_MSG_GetFcnCode(MsgPtr, &FcnCode); + + CFE_EVS_SendEvent(SAMPLE_APP_CMD_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u", + (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, + (unsigned int)ExpectedLength); + + result = false; + + SAMPLE_APP_Data.ErrCounter++; + } + + return result; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* SAMPLE ground commands */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +void SAMPLE_APP_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr) +{ + CFE_MSG_FcnCode_t CommandCode = 0; + + CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); + + /* + ** Process "known" SAMPLE app ground commands + */ + switch (CommandCode) + { + case SAMPLE_APP_NOOP_CC: + if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_NoopCmd_t))) + { + SAMPLE_APP_NoopCmd((const SAMPLE_APP_NoopCmd_t *)SBBufPtr); + } + + break; + + case SAMPLE_APP_RESET_COUNTERS_CC: + if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_ResetCountersCmd_t))) + { + SAMPLE_APP_ResetCountersCmd((const SAMPLE_APP_ResetCountersCmd_t *)SBBufPtr); + } + + break; + + case SAMPLE_APP_PROCESS_CC: + if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_ProcessCmd_t))) + { + SAMPLE_APP_ProcessCmd((const SAMPLE_APP_ProcessCmd_t *)SBBufPtr); + } + + break; + + /* default case already found during FC vs length test */ + default: + CFE_EVS_SendEvent(SAMPLE_APP_CC_ERR_EID, CFE_EVS_EventType_ERROR, "Invalid ground command code: CC = %d", + CommandCode); + break; + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* Purpose: */ +/* This routine will process any packet that is received on the SAMPLE */ +/* command pipe. */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void SAMPLE_APP_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr) +{ + CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; + + CFE_MSG_GetMsgId(&SBBufPtr->Msg, &MsgId); + + switch (CFE_SB_MsgIdToValue(MsgId)) + { + case SAMPLE_APP_CMD_MID: + SAMPLE_APP_ProcessGroundCommand(SBBufPtr); + break; + + case SAMPLE_APP_SEND_HK_MID: + SAMPLE_APP_SendHkCmd((const SAMPLE_APP_SendHkCmd_t *)SBBufPtr); + break; + + default: + CFE_EVS_SendEvent(SAMPLE_APP_MID_ERR_EID, CFE_EVS_EventType_ERROR, + "SAMPLE: invalid command packet,MID = 0x%x", (unsigned int)CFE_SB_MsgIdToValue(MsgId)); + break; + } +} diff --git a/fsw/src/sample_app_dispatch.h b/fsw/src/sample_app_dispatch.h new file mode 100644 index 0000000..b3289e8 --- /dev/null +++ b/fsw/src/sample_app_dispatch.h @@ -0,0 +1,38 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * Main header file for the SAMPLE application + */ + +#ifndef SAMPLE_APP_DISPATCH_H +#define SAMPLE_APP_DISPATCH_H + +/* +** Required header files. +*/ +#include "cfe.h" +#include "sample_app_msg.h" + +void SAMPLE_APP_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr); +void SAMPLE_APP_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr); +bool SAMPLE_APP_VerifyCmdLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength); + +#endif /* SAMPLE_APP_DISPATCH_H */ diff --git a/fsw/src/sample_app_utils.c b/fsw/src/sample_app_utils.c index a316dcf..0de14ea 100644 --- a/fsw/src/sample_app_utils.c +++ b/fsw/src/sample_app_utils.c @@ -29,53 +29,18 @@ #include "sample_app_tbl.h" #include "sample_app_utils.h" -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -/* */ -/* Verify command packet length */ -/* */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ -bool SAMPLE_APP_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) -{ - bool result = true; - size_t ActualLength = 0; - CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; - CFE_MSG_FcnCode_t FcnCode = 0; - - CFE_MSG_GetSize(MsgPtr, &ActualLength); - - /* - ** Verify the command packet length. - */ - if (ExpectedLength != ActualLength) - { - CFE_MSG_GetMsgId(MsgPtr, &MsgId); - CFE_MSG_GetFcnCode(MsgPtr, &FcnCode); - - CFE_EVS_SendEvent(SAMPLE_APP_CMD_LEN_ERR_EID, CFE_EVS_EventType_ERROR, - "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u", - (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength, - (unsigned int)ExpectedLength); - - result = false; - - SAMPLE_APP_Data.ErrCounter++; - } - - return result; -} - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ -/* Verify contents of First Table buffer contents */ +/* Verify contents of First Example Table buffer contents */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ int32 SAMPLE_APP_TblValidationFunc(void *TblData) { - int32 ReturnCode = CFE_SUCCESS; - SAMPLE_APP_Table_t *TblDataPtr = (SAMPLE_APP_Table_t *)TblData; + int32 ReturnCode = CFE_SUCCESS; + SAMPLE_APP_ExampleTable_t *TblDataPtr = (SAMPLE_APP_ExampleTable_t *)TblData; /* - ** Sample Table Validation + ** Sample Example Table Validation */ if (TblDataPtr->Int1 > SAMPLE_APP_TBL_ELEMENT_1_MAX) { @@ -100,7 +65,7 @@ void SAMPLE_APP_GetCrc(const char *TableName) status = CFE_TBL_GetInfo(&TblInfoPtr, TableName); if (status != CFE_SUCCESS) { - CFE_ES_WriteToSysLog("Sample App: Error Getting Table Info"); + CFE_ES_WriteToSysLog("Sample App: Error Getting Example Table Info"); } else { diff --git a/fsw/src/sample_app_utils.h b/fsw/src/sample_app_utils.h index 369f050..873962d 100644 --- a/fsw/src/sample_app_utils.h +++ b/fsw/src/sample_app_utils.h @@ -29,7 +29,6 @@ */ #include "sample_app.h" -bool SAMPLE_APP_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength); int32 SAMPLE_APP_TblValidationFunc(void *TblData); void SAMPLE_APP_GetCrc(const char *TableName); diff --git a/fsw/tables/sample_app_tbl.c b/fsw/tables/sample_app_tbl.c index c380534..c36c412 100644 --- a/fsw/tables/sample_app_tbl.c +++ b/fsw/tables/sample_app_tbl.c @@ -23,13 +23,13 @@ ** The following is an example of the declaration statement that defines the desired ** contents of the table image. */ -SAMPLE_APP_Table_t SampleAppTable = {1, 2}; +SAMPLE_APP_ExampleTable_t ExampleTable = {1, 2}; /* ** The macro below identifies: ** 1) the data structure type to use as the table image format -** 2) the name of the table to be placed into the cFE Table File Header +** 2) the name of the table to be placed into the cFE Example Table File Header ** 3) a brief description of the contents of the file image ** 4) the desired name of the table image binary file that is cFE compatible */ -CFE_TBL_FILEDEF(SampleAppTable, SAMPLE_APP.SampleAppTable, Table Utility Test Table, sample_app_tbl.tbl) +CFE_TBL_FILEDEF(ExampleTable, SAMPLE_APP.ExampleTable, Table Utility Test Table, sample_app_tbl.tbl) diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt index 224c97d..28c052e 100644 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -7,38 +7,63 @@ # ################################################################## -# # # NOTE on the subdirectory structures here: # # - "inc" provides local header files shared between the coveragetest, # wrappers, and overrides source code units # - "coveragetest" contains source code for the actual unit test cases -# The primary objective is to get line/path coverage on the FSW +# The primary objective is to get line/path coverage on the FSW # code units. # - + # Use the UT assert public API, and allow direct # inclusion of source files that are normally private -include_directories(${PROJECT_SOURCE_DIR}/fsw/src) +include_directories(../fsw/src) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) -# Add a coverage test executable called "sample_app-ALL" that -# covers all of the functions in sample_app. -# -# Also note in a more complex app/lib the coverage test can also -# be broken down into smaller units (in which case one should use -# a unique suffix other than "ALL" for each unit). For example, -# OSAL implements a separate coverage test per source unit. -add_cfe_coverage_test(sample_app ALL - "coveragetest/coveragetest_sample_app.c" - "${CFE_SAMPLE_APP_SOURCE_DIR}/fsw/src/sample_app.c" - "${CFE_SAMPLE_APP_SOURCE_DIR}/fsw/src/sample_app_cmds.c" - "${CFE_SAMPLE_APP_SOURCE_DIR}/fsw/src/sample_app_utils.c" +add_cfe_coverage_stubs(sample_app + stubs/sample_app_global_stubs.c + stubs/sample_app_stubs.c + stubs/sample_app_cmds_stubs.c + stubs/sample_app_dispatch_stubs.c + stubs/sample_app_utils_stubs.c +) + +add_library(sample_app_ut_common STATIC + common/eventcheck.c + common/setup.c ) +target_include_directories(sample_app_ut_common PUBLIC common) +target_link_libraries(sample_app_ut_common core_api ut_assert) + + +# Generate a dedicated "testrunner" executable for each test file +# Accomplish this by cycling through all the app's source files, there must be +# a *_tests file for each +foreach(SRCFILE ${APP_SRC_FILES}) + + # Get the base sourcefile name as a module name without path or the + # extension, this will be used as the base name of the unit test file. + get_filename_component(UNIT_NAME "${SRCFILE}" NAME_WE) + + # Use the module name to make the test name by adding _tests to the end + set(TESTS_NAME "coveragetest_${UNIT_NAME}") + + # Make the test sourcefile name with unit test path and extension + set(TESTS_SOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/coveragetest/${TESTS_NAME}.c") + + # Create the coverage test executable + add_cfe_coverage_test(sample_app "${UNIT_NAME}" "${TESTS_SOURCE_FILE}" "../${SRCFILE}") + add_cfe_coverage_dependency(sample_app "${UNIT_NAME}" sample_app) + target_link_libraries(coverage-sample_app-${UNIT_NAME}-testrunner coverage-sample_app-stubs sample_app_ut_common) + +endforeach() + + + # The sample_app uses library functions provided by sample_lib so must be linked -# with the sample_lib stub library (this is mainly just an example of how this +# with the sample_lib stub library (this is mainly just an example of how this # can be done). -add_cfe_coverage_dependency(sample_app ALL sample_lib) - +add_cfe_coverage_dependency(sample_app sample_app_cmds sample_lib) diff --git a/unit-test/common/eventcheck.c b/unit-test/common/eventcheck.c new file mode 100644 index 0000000..5bb23ee --- /dev/null +++ b/unit-test/common/eventcheck.c @@ -0,0 +1,128 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* +** File: coveragetest_sample_app.c +** +** Purpose: +** Coverage Unit Test cases for the SAMPLE Application +** +** Notes: +** This implements various test cases to exercise all code +** paths through all functions defined in the SAMPLE application. +** +** It is primarily focused at providing examples of the various +** stub configurations, hook functions, and wrapper calls that +** are often needed when coercing certain code paths through +** complex functions. +*/ + +/* + * Includes + */ +#include "common_types.h" +#include "cfe_evs.h" + +#include "eventcheck.h" + +#include "utassert.h" +#include "uttest.h" +#include "utstubs.h" + +/* + * An example hook function to check for a specific event. + */ +static int32 UT_CheckEvent_Hook(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context, + va_list va) +{ + UT_CheckEvent_t *State = UserObj; + uint16 EventId; + const char * Spec; + + /* + * The CFE_EVS_SendEvent stub passes the EventID as the + * first context argument. + */ + if (Context->ArgCount > 0) + { + EventId = UT_Hook_GetArgValueByName(Context, "EventID", uint16); + if (EventId == State->ExpectedEvent) + { + if (State->ExpectedFormat != NULL) + { + Spec = UT_Hook_GetArgValueByName(Context, "Spec", const char *); + if (Spec != NULL) + { + /* + * Example of how to validate the full argument set. + * ------------------------------------------------ + * + * If really desired one can call something like: + * + * char TestText[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + * vsnprintf(TestText, sizeof(TestText), Spec, va); + * + * And then compare the output (TestText) to the expected fully-rendered string. + * + * NOTE: While this can be done, use with discretion - This isn't really + * verifying that the FSW code unit generated the correct event text, + * rather it is validating what the system snprintf() library function + * produces when passed the format string and args. + * + * This type of check has been demonstrated to make tests very fragile, + * because it is influenced by many factors outside the control of the + * test case. + * + * __This derived string is not an actual output of the unit under test__ + */ + if (strcmp(Spec, State->ExpectedFormat) == 0) + { + ++State->MatchCount; + } + } + } + else + { + ++State->MatchCount; + } + } + } + + return 0; +} + +/* + * Helper function to set up for event checking + * This attaches the hook function to CFE_EVS_SendEvent + */ +void UT_CheckEvent_Setup_Impl(UT_CheckEvent_t *Evt, uint16 ExpectedEvent, const char *EventName, + const char *ExpectedFormat) +{ + if (ExpectedFormat == NULL) + { + UtPrintf("CheckEvent will match: %s(%u)", EventName, ExpectedEvent); + } + else + { + UtPrintf("CheckEvent will match: %s(%u), \"%s\"", EventName, ExpectedEvent, ExpectedFormat); + } + memset(Evt, 0, sizeof(*Evt)); + Evt->ExpectedEvent = ExpectedEvent; + Evt->ExpectedFormat = ExpectedFormat; + UT_SetVaHookFunction(UT_KEY(CFE_EVS_SendEvent), UT_CheckEvent_Hook, Evt); +} diff --git a/unit-test/common/eventcheck.h b/unit-test/common/eventcheck.h new file mode 100644 index 0000000..07168aa --- /dev/null +++ b/unit-test/common/eventcheck.h @@ -0,0 +1,64 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* +** Purpose: +** Coverage Unit Test cases for the SAMPLE Application +** +** Notes: +** This implements various test cases to exercise all code +** paths through all functions defined in the SAMPLE application. +** +** It is primarily focused at providing examples of the various +** stub configurations, hook functions, and wrapper calls that +** are often needed when coercing certain code paths through +** complex functions. +*/ + +#ifndef EVENTCHECK_H +#define EVENTCHECK_H + +#include "common_types.h" +#include "cfe_evs.h" + +#include "utassert.h" +#include "uttest.h" +#include "utstubs.h" + +/* + * Unit test check event hook information + */ +typedef struct +{ + uint16 ExpectedEvent; + uint32 MatchCount; + const char *ExpectedFormat; +} UT_CheckEvent_t; + +/* Macro to get expected event name */ +#define UT_CHECKEVENT_SETUP(Evt, ExpectedEvent, ExpectedFormat) \ + UT_CheckEvent_Setup_Impl(Evt, ExpectedEvent, #ExpectedEvent, ExpectedFormat) + +/* + * Helper function to set up for event checking + * This attaches the hook function to CFE_EVS_SendEvent + */ +void UT_CheckEvent_Setup_Impl(UT_CheckEvent_t *Evt, uint16 ExpectedEvent, const char *EventName, + const char *ExpectedFormat); + +#endif diff --git a/unit-test/common/setup.c b/unit-test/common/setup.c new file mode 100644 index 0000000..9d6011e --- /dev/null +++ b/unit-test/common/setup.c @@ -0,0 +1,55 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* +** Purpose: +** Coverage Unit Test cases for the SAMPLE Application +** +** Notes: +** This implements various test cases to exercise all code +** paths through all functions defined in the SAMPLE application. +** +** It is primarily focused at providing examples of the various +** stub configurations, hook functions, and wrapper calls that +** are often needed when coercing certain code paths through +** complex functions. +*/ + +/* + * Includes + */ +#include "common_types.h" + +#include "setup.h" + +#include "utassert.h" +#include "uttest.h" +#include "utstubs.h" + +/* + * Setup function prior to every test + */ +void Sample_UT_Setup(void) +{ + UT_ResetState(0); +} + +/* + * Teardown function after every test + */ +void Sample_UT_TearDown(void) {} diff --git a/unit-test/common/setup.h b/unit-test/common/setup.h new file mode 100644 index 0000000..a1ed825 --- /dev/null +++ b/unit-test/common/setup.h @@ -0,0 +1,45 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* +** Purpose: +** Coverage Unit Test cases for the SAMPLE Application +** +** Notes: +** This implements various test cases to exercise all code +** paths through all functions defined in the SAMPLE application. +** +** It is primarily focused at providing examples of the various +** stub configurations, hook functions, and wrapper calls that +** are often needed when coercing certain code paths through +** complex functions. +*/ + +#ifndef SETUP_H +#define SETUP_H + +#include "common_types.h" + +#include "utassert.h" +#include "uttest.h" +#include "utstubs.h" + +void Sample_UT_Setup(void); +void Sample_UT_TearDown(void); + +#endif diff --git a/unit-test/coveragetest/coveragetest_sample_app.c b/unit-test/coveragetest/coveragetest_sample_app.c index 272476b..294cf71 100644 --- a/unit-test/coveragetest/coveragetest_sample_app.c +++ b/unit-test/coveragetest/coveragetest_sample_app.c @@ -37,104 +37,6 @@ */ #include "sample_lib.h" /* For SAMPLE_LIB_Function */ #include "sample_app_coveragetest_common.h" -#include "ut_sample_app.h" - -/* - * Unit test check event hook information - */ -typedef struct -{ - uint16 ExpectedEvent; - uint32 MatchCount; - const char *ExpectedFormat; -} UT_CheckEvent_t; - -/* - * An example hook function to check for a specific event. - */ -static int32 UT_CheckEvent_Hook(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context, - va_list va) -{ - UT_CheckEvent_t *State = UserObj; - uint16 EventId; - const char * Spec; - - /* - * The CFE_EVS_SendEvent stub passes the EventID as the - * first context argument. - */ - if (Context->ArgCount > 0) - { - EventId = UT_Hook_GetArgValueByName(Context, "EventID", uint16); - if (EventId == State->ExpectedEvent) - { - if (State->ExpectedFormat != NULL) - { - Spec = UT_Hook_GetArgValueByName(Context, "Spec", const char *); - if (Spec != NULL) - { - /* - * Example of how to validate the full argument set. - * ------------------------------------------------ - * - * If really desired one can call something like: - * - * char TestText[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; - * vsnprintf(TestText, sizeof(TestText), Spec, va); - * - * And then compare the output (TestText) to the expected fully-rendered string. - * - * NOTE: While this can be done, use with discretion - This isn't really - * verifying that the FSW code unit generated the correct event text, - * rather it is validating what the system snprintf() library function - * produces when passed the format string and args. - * - * This type of check has been demonstrated to make tests very fragile, - * because it is influenced by many factors outside the control of the - * test case. - * - * __This derived string is not an actual output of the unit under test__ - */ - if (strcmp(Spec, State->ExpectedFormat) == 0) - { - ++State->MatchCount; - } - } - } - else - { - ++State->MatchCount; - } - } - } - - return 0; -} - -/* Macro to get expected event name */ -#define UT_CHECKEVENT_SETUP(Evt, ExpectedEvent, ExpectedFormat) \ - UT_CheckEvent_Setup_Impl(Evt, ExpectedEvent, #ExpectedEvent, ExpectedFormat) - -/* - * Helper function to set up for event checking - * This attaches the hook function to CFE_EVS_SendEvent - */ -static void UT_CheckEvent_Setup_Impl(UT_CheckEvent_t *Evt, uint16 ExpectedEvent, const char *EventName, - const char *ExpectedFormat) -{ - if (ExpectedFormat == NULL) - { - UtPrintf("CheckEvent will match: %s(%u)", EventName, ExpectedEvent); - } - else - { - UtPrintf("CheckEvent will match: %s(%u), \"%s\"", EventName, ExpectedEvent, ExpectedFormat); - } - memset(Evt, 0, sizeof(*Evt)); - Evt->ExpectedEvent = ExpectedEvent; - Evt->ExpectedFormat = ExpectedFormat; - UT_SetVaHookFunction(UT_KEY(CFE_EVS_SendEvent), UT_CheckEvent_Hook, Evt); -} /* ********************************************************************************** @@ -272,362 +174,6 @@ void Test_SAMPLE_APP_Init(void) UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 5); } -void Test_SAMPLE_APP_ProcessCommandPacket(void) -{ - /* - * Test Case For: - * void SAMPLE_APP_ProcessCommandPacket - */ - /* a buffer large enough for any command message */ - union - { - CFE_SB_Buffer_t SBBuf; - SAMPLE_APP_NoopCmd_t Noop; - } TestMsg; - CFE_SB_MsgId_t TestMsgId; - CFE_MSG_FcnCode_t FcnCode; - size_t MsgSize; - UT_CheckEvent_t EventTest; - - memset(&TestMsg, 0, sizeof(TestMsg)); - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_MID_ERR_EID, "SAMPLE: invalid command packet,MID = 0x%x"); - - /* - * The CFE_MSG_GetMsgId() stub uses a data buffer to hold the - * message ID values to return. - */ - TestMsgId = CFE_SB_ValueToMsgId(SAMPLE_APP_CMD_MID); - FcnCode = SAMPLE_APP_NOOP_CC; - MsgSize = sizeof(TestMsg.Noop); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); - SAMPLE_APP_ProcessCommandPacket(&TestMsg.SBBuf); - - TestMsgId = CFE_SB_ValueToMsgId(SAMPLE_APP_SEND_HK_MID); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - SAMPLE_APP_ProcessCommandPacket(&TestMsg.SBBuf); - - /* invalid message id */ - TestMsgId = CFE_SB_INVALID_MSG_ID; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - SAMPLE_APP_ProcessCommandPacket(&TestMsg.SBBuf); - - /* - * Confirm that the event was generated only _once_ - */ - UtAssert_UINT32_EQ(EventTest.MatchCount, 1); -} - -void Test_SAMPLE_APP_ProcessGroundCommand(void) -{ - /* - * Test Case For: - * void SAMPLE_APP_ProcessGroundCommand - */ - CFE_MSG_FcnCode_t FcnCode; - size_t Size; - - /* a buffer large enough for any command message */ - union - { - CFE_SB_Buffer_t SBBuf; - SAMPLE_APP_NoopCmd_t Noop; - SAMPLE_APP_ResetCountersCmd_t Reset; - SAMPLE_APP_ProcessCmd_t Process; - } TestMsg; - UT_CheckEvent_t EventTest; - - memset(&TestMsg, 0, sizeof(TestMsg)); - - /* - * call with each of the supported command codes - * The CFE_MSG_GetFcnCode stub allows the code to be - * set to whatever is needed. There is no return - * value here and the actual implementation of these - * commands have separate test cases, so this just - * needs to exercise the "switch" statement. - */ - - /* test dispatch of NOOP */ - FcnCode = SAMPLE_APP_NOOP_CC; - Size = sizeof(TestMsg.Noop); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_NOOP_INF_EID, NULL); - - SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); - - UtAssert_UINT32_EQ(EventTest.MatchCount, 1); - - /* test dispatch of RESET */ - FcnCode = SAMPLE_APP_RESET_COUNTERS_CC; - Size = sizeof(TestMsg.Reset); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_RESET_INF_EID, NULL); - - SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); - - UtAssert_UINT32_EQ(EventTest.MatchCount, 1); - - /* test dispatch of PROCESS */ - /* note this will end up calling SAMPLE_APP_Process(), and as such it needs to - * avoid dereferencing a table which does not exist. */ - FcnCode = SAMPLE_APP_PROCESS_CC; - Size = sizeof(TestMsg.Process); - UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_UNREGISTERED); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); - - SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); - - /* test an invalid CC */ - FcnCode = 1000; - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_CC_ERR_EID, "Invalid ground command code: CC = %d"); - SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); - - /* - * Confirm that the event was generated only _once_ - */ - UtAssert_UINT32_EQ(EventTest.MatchCount, 1); -} - -void Test_SAMPLE_APP_ReportHousekeeping(void) -{ - /* - * Test Case For: - * void SAMPLE_APP_ReportHousekeeping( const CFE_SB_CmdHdr_t *Msg ) - */ - CFE_MSG_Message_t *MsgSend; - CFE_MSG_Message_t *MsgTimestamp; - CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(SAMPLE_APP_SEND_HK_MID); - - /* Set message id to return so SAMPLE_APP_Housekeeping will be called */ - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); - - /* Set up to capture send message address */ - UT_SetDataBuffer(UT_KEY(CFE_SB_TransmitMsg), &MsgSend, sizeof(MsgSend), false); - - /* Set up to capture timestamp message address */ - UT_SetDataBuffer(UT_KEY(CFE_SB_TimeStampMsg), &MsgTimestamp, sizeof(MsgTimestamp), false); - - /* Call unit under test, NULL pointer confirms command access is through APIs */ - SAMPLE_APP_ProcessCommandPacket((CFE_SB_Buffer_t *)NULL); - - /* Confirm message sent*/ - UtAssert_STUB_COUNT(CFE_SB_TransmitMsg, 1); - UtAssert_ADDRESS_EQ(MsgSend, &SAMPLE_APP_Data.HkTlm); - - /* Confirm timestamp msg address */ - UtAssert_STUB_COUNT(CFE_SB_TimeStampMsg, 1); - UtAssert_ADDRESS_EQ(MsgTimestamp, &SAMPLE_APP_Data.HkTlm); - - /* - * Confirm that the CFE_TBL_Manage() call was done - */ - UtAssert_STUB_COUNT(CFE_TBL_Manage, 1); -} - -void Test_SAMPLE_APP_NoopCmd(void) -{ - /* - * Test Case For: - * void SAMPLE_APP_NoopCmd( const SAMPLE_APP_Noop_t *Msg ) - */ - SAMPLE_APP_NoopCmd_t TestMsg; - UT_CheckEvent_t EventTest; - - memset(&TestMsg, 0, sizeof(TestMsg)); - - /* test dispatch of NOOP */ - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_NOOP_INF_EID, NULL); - - UtAssert_INT32_EQ(SAMPLE_APP_Noop(&TestMsg), CFE_SUCCESS); - - /* - * Confirm that the event was generated - */ - UtAssert_UINT32_EQ(EventTest.MatchCount, 1); -} - -void Test_SAMPLE_APP_ResetCounters(void) -{ - /* - * Test Case For: - * void SAMPLE_APP_ResetCounters( const SAMPLE_APP_ResetCounters_t *Msg ) - */ - SAMPLE_APP_ResetCountersCmd_t TestMsg; - UT_CheckEvent_t EventTest; - - memset(&TestMsg, 0, sizeof(TestMsg)); - - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_RESET_INF_EID, "SAMPLE: RESET command"); - - UtAssert_INT32_EQ(SAMPLE_APP_ResetCounters(&TestMsg), CFE_SUCCESS); - - /* - * Confirm that the event was generated - */ - UtAssert_UINT32_EQ(EventTest.MatchCount, 1); -} - -void Test_SAMPLE_APP_ProcessCC(void) -{ - /* - * Test Case For: - * void SAMPLE_APP_ProcessCC( const SAMPLE_APP_Process_t *Msg ) - */ - SAMPLE_APP_ProcessCmd_t TestMsg; - SAMPLE_APP_Table_t TestTblData; - void * TblPtr = &TestTblData; - - memset(&TestTblData, 0, sizeof(TestTblData)); - memset(&TestMsg, 0, sizeof(TestMsg)); - - /* Provide some table data for the SAMPLE_APP_Process() function to use */ - TestTblData.Int1 = 40; - TestTblData.Int2 = 50; - UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TblPtr, sizeof(TblPtr), false); - UtAssert_INT32_EQ(SAMPLE_APP_Process(&TestMsg), CFE_SUCCESS); - - /* - * Successful operation results in two calls to CFE_ES_WriteToSysLog() - one - * in this function reporting the table values, and one through - * SAMPLE_APP_GetCrc(). - */ - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 2); - - /* - * Confirm that the CFE_TBL_GetAddress() call was done - */ - UtAssert_STUB_COUNT(CFE_TBL_GetAddress, 1); - - /* - * Confirm that the SAMPLE_LIB_Function() call was done - * NOTE: This stub is provided by the sample_lib library - */ - UtAssert_STUB_COUNT(SAMPLE_LIB_Function, 1); - - /* - * Configure the CFE_TBL_GetAddress function to return an error. - * Exercise the error return path. - * Error at this point should add only one additional call to - * CFE_ES_WriteToSysLog() through the CFE_TBL_GetAddress() error path. - */ - UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_UNREGISTERED); - UtAssert_INT32_EQ(SAMPLE_APP_Process(&TestMsg), CFE_TBL_ERR_UNREGISTERED); - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 3); - - /* - * Configure CFE_TBL_ReleaseAddress() to return an error, exercising the - * error return path. - * Confirm three additional calls to CFE_ES_WriteToSysLog() - one - * reporting the table values, one through SAMPLE_APP_GetCrc() and one - * through the CFE_TBL_ReleaseAddress() error path. - */ - UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); - UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_ReleaseAddress), CFE_TBL_ERR_NO_ACCESS); - UtAssert_INT32_EQ(SAMPLE_APP_Process(&TestMsg), CFE_TBL_ERR_NO_ACCESS); - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 6); -} - -void Test_SAMPLE_APP_VerifyCmdLength(void) -{ - /* - * Test Case For: - * bool SAMPLE_APP_VerifyCmdLength - */ - UT_CheckEvent_t EventTest; - size_t size = 1; - CFE_MSG_FcnCode_t fcncode = 2; - CFE_SB_MsgId_t msgid = CFE_SB_ValueToMsgId(3); - - /* - * test a match case - */ - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &size, sizeof(size), false); - UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_CMD_LEN_ERR_EID, - "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u"); - - SAMPLE_APP_VerifyCmdLength(NULL, size); - - /* - * Confirm that the event was NOT generated - */ - UtAssert_UINT32_EQ(EventTest.MatchCount, 0); - - /* - * test a mismatch case - */ - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &size, sizeof(size), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &msgid, sizeof(msgid), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &fcncode, sizeof(fcncode), false); - SAMPLE_APP_VerifyCmdLength(NULL, size + 1); - - /* - * Confirm that the event WAS generated - */ - UtAssert_UINT32_EQ(EventTest.MatchCount, 1); -} - -void Test_SAMPLE_APP_TblValidationFunc(void) -{ - /* - * Test Case For: - * int32 SAMPLE_APP_TblValidationFunc( void *TblData ) - */ - SAMPLE_APP_Table_t TestTblData; - - memset(&TestTblData, 0, sizeof(TestTblData)); - - /* nominal case (0) should succeed */ - UtAssert_INT32_EQ(SAMPLE_APP_TblValidationFunc(&TestTblData), CFE_SUCCESS); - - /* error case should return SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE */ - TestTblData.Int1 = 1 + SAMPLE_APP_TBL_ELEMENT_1_MAX; - UtAssert_INT32_EQ(SAMPLE_APP_TblValidationFunc(&TestTblData), SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE); -} - -void Test_SAMPLE_APP_GetCrc(void) -{ - /* - * Test Case For: - * void SAMPLE_APP_GetCrc( const char *TableName ) - */ - - /* - * The only branch point here is CFE_TBL_GetInfo() - * - * Either way this function just does a write to syslog, - * and it is the same in both cases, just with - * a different message. This could actually verify - * the message using a hook function, if desired. - */ - - UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetInfo), CFE_TBL_ERR_INVALID_NAME); - SAMPLE_APP_GetCrc("UT"); - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 1); - - UT_ClearDefaultReturnValue(UT_KEY(CFE_TBL_GetInfo)); - SAMPLE_APP_GetCrc("UT"); - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 2); -} - -/* - * Setup function prior to every test - */ -void Sample_UT_Setup(void) -{ - UT_ResetState(0); -} - -/* - * Teardown function after every test - */ -void Sample_UT_TearDown(void) {} - /* * Register the test cases to execute with the unit test tool */ @@ -635,13 +181,4 @@ void UtTest_Setup(void) { ADD_TEST(SAMPLE_APP_Main); ADD_TEST(SAMPLE_APP_Init); - ADD_TEST(SAMPLE_APP_ProcessCommandPacket); - ADD_TEST(SAMPLE_APP_ProcessGroundCommand); - ADD_TEST(SAMPLE_APP_ReportHousekeeping); - ADD_TEST(SAMPLE_APP_NoopCmd); - ADD_TEST(SAMPLE_APP_ResetCounters); - ADD_TEST(SAMPLE_APP_ProcessCC); - ADD_TEST(SAMPLE_APP_VerifyCmdLength); - ADD_TEST(SAMPLE_APP_TblValidationFunc); - ADD_TEST(SAMPLE_APP_GetCrc); } diff --git a/unit-test/coveragetest/coveragetest_sample_app_cmds.c b/unit-test/coveragetest/coveragetest_sample_app_cmds.c new file mode 100644 index 0000000..218ea96 --- /dev/null +++ b/unit-test/coveragetest/coveragetest_sample_app_cmds.c @@ -0,0 +1,195 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* +** File: coveragetest_sample_app.c +** +** Purpose: +** Coverage Unit Test cases for the SAMPLE Application +** +** Notes: +** This implements various test cases to exercise all code +** paths through all functions defined in the SAMPLE application. +** +** It is primarily focused at providing examples of the various +** stub configurations, hook functions, and wrapper calls that +** are often needed when coercing certain code paths through +** complex functions. +*/ + +/* + * Includes + */ + +#include "sample_lib.h" /* For SAMPLE_LIB_Function */ +#include "sample_app_coveragetest_common.h" +#include "sample_app.h" +#include "sample_app_dispatch.h" +#include "sample_app_cmds.h" + +/* +********************************************************************************** +** TEST CASE FUNCTIONS +********************************************************************************** +*/ + +void Test_SAMPLE_APP_ReportHousekeeping(void) +{ + /* + * Test Case For: + * void SAMPLE_APP_ReportHousekeeping( const CFE_SB_CmdHdr_t *Msg ) + */ + CFE_MSG_Message_t *MsgSend; + CFE_MSG_Message_t *MsgTimestamp; + + /* Set up to capture send message address */ + UT_SetDataBuffer(UT_KEY(CFE_SB_TransmitMsg), &MsgSend, sizeof(MsgSend), false); + + /* Set up to capture timestamp message address */ + UT_SetDataBuffer(UT_KEY(CFE_SB_TimeStampMsg), &MsgTimestamp, sizeof(MsgTimestamp), false); + + /* Call unit under test, NULL pointer confirms command access is through APIs */ + SAMPLE_APP_SendHkCmd(NULL); + + /* Confirm message sent*/ + UtAssert_STUB_COUNT(CFE_SB_TransmitMsg, 1); + UtAssert_ADDRESS_EQ(MsgSend, &SAMPLE_APP_Data.HkTlm); + + /* Confirm timestamp msg address */ + UtAssert_STUB_COUNT(CFE_SB_TimeStampMsg, 1); + UtAssert_ADDRESS_EQ(MsgTimestamp, &SAMPLE_APP_Data.HkTlm); + + /* + * Confirm that the CFE_TBL_Manage() call was done + */ + UtAssert_STUB_COUNT(CFE_TBL_Manage, 1); +} + +void Test_SAMPLE_APP_NoopCmd(void) +{ + /* + * Test Case For: + * void SAMPLE_APP_NoopCmd( const SAMPLE_APP_Noop_t *Msg ) + */ + SAMPLE_APP_NoopCmd_t TestMsg; + UT_CheckEvent_t EventTest; + + memset(&TestMsg, 0, sizeof(TestMsg)); + + /* test dispatch of NOOP */ + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_NOOP_INF_EID, NULL); + + UtAssert_INT32_EQ(SAMPLE_APP_NoopCmd(&TestMsg), CFE_SUCCESS); + + /* + * Confirm that the event was generated + */ + UtAssert_UINT32_EQ(EventTest.MatchCount, 1); +} + +void Test_SAMPLE_APP_ResetCountersCmd(void) +{ + /* + * Test Case For: + * void SAMPLE_APP_ResetCounters( const SAMPLE_APP_ResetCounters_t *Msg ) + */ + SAMPLE_APP_ResetCountersCmd_t TestMsg; + UT_CheckEvent_t EventTest; + + memset(&TestMsg, 0, sizeof(TestMsg)); + + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_RESET_INF_EID, "SAMPLE: RESET command"); + + UtAssert_INT32_EQ(SAMPLE_APP_ResetCountersCmd(&TestMsg), CFE_SUCCESS); + + /* + * Confirm that the event was generated + */ + UtAssert_UINT32_EQ(EventTest.MatchCount, 1); +} + +void Test_SAMPLE_APP_ProcessCmd(void) +{ + /* + * Test Case For: + * void SAMPLE_APP_ProcessCmd( const SAMPLE_APP_ProcessCmd_t *Msg ) + */ + SAMPLE_APP_ProcessCmd_t TestMsg; + SAMPLE_APP_ExampleTable_t TestTblData; + void * TblPtr = &TestTblData; + + memset(&TestTblData, 0, sizeof(TestTblData)); + memset(&TestMsg, 0, sizeof(TestMsg)); + + /* Provide some table data for the SAMPLE_APP_Process() function to use */ + TestTblData.Int1 = 40; + TestTblData.Int2 = 50; + UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TblPtr, sizeof(TblPtr), false); + UtAssert_INT32_EQ(SAMPLE_APP_ProcessCmd(&TestMsg), CFE_SUCCESS); + + /* + * Successful operation results in two calls to CFE_ES_WriteToSysLog() - one + * in this function reporting the table values, and one through + * SAMPLE_APP_GetCrc(). + */ + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 2); + + /* + * Confirm that the CFE_TBL_GetAddress() call was done + */ + UtAssert_STUB_COUNT(CFE_TBL_GetAddress, 1); + + /* + * Confirm that the SAMPLE_LIB_Function() call was done + * NOTE: This stub is provided by the sample_lib library + */ + UtAssert_STUB_COUNT(SAMPLE_LIB_Function, 1); + + /* + * Configure the CFE_TBL_GetAddress function to return an error. + * Exercise the error return path. + * Error at this point should add only one additional call to + * CFE_ES_WriteToSysLog() through the CFE_TBL_GetAddress() error path. + */ + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_UNREGISTERED); + UtAssert_INT32_EQ(SAMPLE_APP_ProcessCmd(&TestMsg), CFE_TBL_ERR_UNREGISTERED); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 3); + + /* + * Configure CFE_TBL_ReleaseAddress() to return an error, exercising the + * error return path. + * Confirm three additional calls to CFE_ES_WriteToSysLog() - one + * reporting the table values, one through SAMPLE_APP_GetCrc() and one + * through the CFE_TBL_ReleaseAddress() error path. + */ + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_ReleaseAddress), CFE_TBL_ERR_NO_ACCESS); + UtAssert_INT32_EQ(SAMPLE_APP_ProcessCmd(&TestMsg), CFE_TBL_ERR_NO_ACCESS); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 6); +} + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(SAMPLE_APP_ReportHousekeeping); + ADD_TEST(SAMPLE_APP_NoopCmd); + ADD_TEST(SAMPLE_APP_ResetCountersCmd); + ADD_TEST(SAMPLE_APP_ProcessCmd); +} diff --git a/unit-test/coveragetest/coveragetest_sample_app_dispatch.c b/unit-test/coveragetest/coveragetest_sample_app_dispatch.c new file mode 100644 index 0000000..bf644f9 --- /dev/null +++ b/unit-test/coveragetest/coveragetest_sample_app_dispatch.c @@ -0,0 +1,257 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* +** Purpose: +** Coverage Unit Test cases for the SAMPLE Application +** +** Notes: +** This implements various test cases to exercise all code +** paths through all functions defined in the SAMPLE application. +** +** It is primarily focused at providing examples of the various +** stub configurations, hook functions, and wrapper calls that +** are often needed when coercing certain code paths through +** complex functions. +*/ + +/* + * Includes + */ + +#include "sample_app_coveragetest_common.h" +#include "sample_app.h" +#include "sample_app_dispatch.h" +#include "sample_app_cmds.h" + +/* +********************************************************************************** +** TEST CASE FUNCTIONS +********************************************************************************** +*/ + +void Test_SAMPLE_APP_TaskPipe(void) +{ + /* + * Test Case For: + * void SAMPLE_APP_TaskPipe + */ + /* a buffer large enough for any command message */ + union + { + CFE_SB_Buffer_t SBBuf; + SAMPLE_APP_NoopCmd_t Noop; + } TestMsg; + CFE_SB_MsgId_t TestMsgId; + CFE_MSG_FcnCode_t FcnCode; + size_t MsgSize; + UT_CheckEvent_t EventTest; + + memset(&TestMsg, 0, sizeof(TestMsg)); + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_MID_ERR_EID, "SAMPLE: invalid command packet,MID = 0x%x"); + + /* + * The CFE_MSG_GetMsgId() stub uses a data buffer to hold the + * message ID values to return. + */ + TestMsgId = CFE_SB_ValueToMsgId(SAMPLE_APP_CMD_MID); + FcnCode = SAMPLE_APP_NOOP_CC; + MsgSize = sizeof(TestMsg.Noop); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); + SAMPLE_APP_TaskPipe(&TestMsg.SBBuf); + + TestMsgId = CFE_SB_ValueToMsgId(SAMPLE_APP_SEND_HK_MID); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); + SAMPLE_APP_TaskPipe(&TestMsg.SBBuf); + + /* invalid message id */ + TestMsgId = CFE_SB_INVALID_MSG_ID; + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); + SAMPLE_APP_TaskPipe(&TestMsg.SBBuf); + + /* + * Confirm that the event was generated only _once_ + */ + UtAssert_UINT32_EQ(EventTest.MatchCount, 1); +} + +void Test_SAMPLE_APP_ProcessGroundCommand(void) +{ + /* + * Test Case For: + * void SAMPLE_APP_ProcessGroundCommand + */ + CFE_MSG_FcnCode_t FcnCode; + size_t Size; + CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(1); + + /* a buffer large enough for any command message */ + union + { + CFE_SB_Buffer_t SBBuf; + SAMPLE_APP_NoopCmd_t Noop; + SAMPLE_APP_ResetCountersCmd_t Reset; + SAMPLE_APP_ProcessCmd_t Process; + } TestMsg; + UT_CheckEvent_t EventTest; + + memset(&TestMsg, 0, sizeof(TestMsg)); + + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_CMD_LEN_ERR_EID, + "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u"); + + /* + * call with each of the supported command codes + * The CFE_MSG_GetFcnCode stub allows the code to be + * set to whatever is needed. There is no return + * value here and the actual implementation of these + * commands have separate test cases, so this just + * needs to exercise the "switch" statement. + */ + + /* test dispatch of NOOP */ + FcnCode = SAMPLE_APP_NOOP_CC; + Size = sizeof(TestMsg.Noop); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); + + SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); + + UtAssert_STUB_COUNT(SAMPLE_APP_NoopCmd, 1); + + FcnCode = SAMPLE_APP_NOOP_CC; + Size = sizeof(TestMsg.Noop) - 1; + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); + + SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); + + UtAssert_STUB_COUNT(SAMPLE_APP_NoopCmd, 1); + UtAssert_UINT32_EQ(EventTest.MatchCount, 1); + + /* test dispatch of RESET */ + FcnCode = SAMPLE_APP_RESET_COUNTERS_CC; + Size = sizeof(TestMsg.Reset); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); + + SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); + + UtAssert_STUB_COUNT(SAMPLE_APP_ResetCountersCmd, 1); + + FcnCode = SAMPLE_APP_RESET_COUNTERS_CC; + Size = sizeof(TestMsg.Reset) - 1; + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); + + SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); + + UtAssert_STUB_COUNT(SAMPLE_APP_ResetCountersCmd, 1); + UtAssert_UINT32_EQ(EventTest.MatchCount, 2); + + /* test dispatch of PROCESS */ + /* note this will end up calling SAMPLE_APP_Process(), and as such it needs to + * avoid dereferencing a table which does not exist. */ + FcnCode = SAMPLE_APP_PROCESS_CC; + Size = sizeof(TestMsg.Process); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_UNREGISTERED); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); + + SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); + + UtAssert_STUB_COUNT(SAMPLE_APP_ProcessCmd, 1); + + FcnCode = SAMPLE_APP_PROCESS_CC; + Size = sizeof(TestMsg.Process) - 1; + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); + + SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); + + UtAssert_STUB_COUNT(SAMPLE_APP_ProcessCmd, 1); + UtAssert_UINT32_EQ(EventTest.MatchCount, 3); + + /* test an invalid CC */ + FcnCode = 1000; + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_CC_ERR_EID, "Invalid ground command code: CC = %d"); + SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); + + /* + * Confirm that the event was generated only _once_ + */ + UtAssert_UINT32_EQ(EventTest.MatchCount, 1); +} + +void Test_SAMPLE_APP_VerifyCmdLength(void) +{ + /* + * Test Case For: + * bool SAMPLE_APP_VerifyCmdLength + */ + UT_CheckEvent_t EventTest; + size_t size = 1; + CFE_MSG_FcnCode_t fcncode = 2; + CFE_SB_MsgId_t msgid = CFE_SB_ValueToMsgId(3); + + /* + * test a match case + */ + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &size, sizeof(size), false); + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_CMD_LEN_ERR_EID, + "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u"); + + SAMPLE_APP_VerifyCmdLength(NULL, size); + + /* + * Confirm that the event was NOT generated + */ + UtAssert_UINT32_EQ(EventTest.MatchCount, 0); + + /* + * test a mismatch case + */ + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &size, sizeof(size), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &msgid, sizeof(msgid), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &fcncode, sizeof(fcncode), false); + SAMPLE_APP_VerifyCmdLength(NULL, size + 1); + + /* + * Confirm that the event WAS generated + */ + UtAssert_UINT32_EQ(EventTest.MatchCount, 1); +} + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(SAMPLE_APP_TaskPipe); + ADD_TEST(SAMPLE_APP_ProcessGroundCommand); + ADD_TEST(SAMPLE_APP_VerifyCmdLength); +} diff --git a/unit-test/coveragetest/coveragetest_sample_app_utils.c b/unit-test/coveragetest/coveragetest_sample_app_utils.c new file mode 100644 index 0000000..72b32e2 --- /dev/null +++ b/unit-test/coveragetest/coveragetest_sample_app_utils.c @@ -0,0 +1,97 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* +** File: coveragetest_sample_app.c +** +** Purpose: +** Coverage Unit Test cases for the Sample Application +** +** Notes: +** This implements various test cases to exercise all code +** paths through all functions defined in the Sample application. +** +** It is primarily focused at providing examples of the various +** stub configurations, hook functions, and wrapper calls that +** are often needed when coercing certain code paths through +** complex functions. +*/ + +/* + * Includes + */ +#include "sample_lib.h" /* For SAMPLE_LIB_Function */ +#include "sample_app_coveragetest_common.h" + +/* +********************************************************************************** +** TEST CASE FUNCTIONS +********************************************************************************** +*/ + +void Test_SAMPLE_APP_TblValidationFunc(void) +{ + /* + * Test Case For: + * int32 SAMPLE_APP_TblValidationFunc( void *TblData ) + */ + SAMPLE_APP_ExampleTable_t TestTblData; + + memset(&TestTblData, 0, sizeof(TestTblData)); + + /* nominal case (0) should succeed */ + UtAssert_INT32_EQ(SAMPLE_APP_TblValidationFunc(&TestTblData), CFE_SUCCESS); + + /* error case should return SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE */ + TestTblData.Int1 = 1 + SAMPLE_APP_TBL_ELEMENT_1_MAX; + UtAssert_INT32_EQ(SAMPLE_APP_TblValidationFunc(&TestTblData), SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE); +} + +void Test_SAMPLE_APP_GetCrc(void) +{ + /* + * Test Case For: + * void SAMPLE_APP_GetCrc( const char *TableName ) + */ + + /* + * The only branch point here is CFE_TBL_GetInfo() + * + * Either way this function just does a write to syslog, + * and it is the same in both cases, just with + * a different message. This could actually verify + * the message using a hook function, if desired. + */ + + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetInfo), CFE_TBL_ERR_INVALID_NAME); + SAMPLE_APP_GetCrc("UT"); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 1); + + UT_ClearDefaultReturnValue(UT_KEY(CFE_TBL_GetInfo)); + SAMPLE_APP_GetCrc("UT"); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 2); +} + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(SAMPLE_APP_TblValidationFunc); + ADD_TEST(SAMPLE_APP_GetCrc); +} diff --git a/unit-test/coveragetest/sample_app_coveragetest_common.h b/unit-test/coveragetest/sample_app_coveragetest_common.h index e571cb5..792ee5b 100644 --- a/unit-test/coveragetest/sample_app_coveragetest_common.h +++ b/unit-test/coveragetest/sample_app_coveragetest_common.h @@ -33,11 +33,17 @@ #include "uttest.h" #include "utstubs.h" +#include "setup.h" +#include "eventcheck.h" + #include "cfe.h" #include "sample_app_eventids.h" #include "sample_app.h" +#include "sample_app_dispatch.h" #include "sample_app_cmds.h" #include "sample_app_utils.h" +#include "sample_app_msgids.h" +#include "sample_app_msg.h" #include "sample_app_tbl.h" /* @@ -45,14 +51,4 @@ */ #define ADD_TEST(test) UtTest_Add((Test_##test), Sample_UT_Setup, Sample_UT_TearDown, #test) -/* - * Setup function prior to every test - */ -void Sample_UT_Setup(void); - -/* - * Teardown function after every test - */ -void Sample_UT_TearDown(void); - #endif /* SAMPLE_APP_COVERAGETEST_COMMON_H */ diff --git a/unit-test/stubs/sample_app_cmds_stubs.c b/unit-test/stubs/sample_app_cmds_stubs.c new file mode 100644 index 0000000..e53ec8a --- /dev/null +++ b/unit-test/stubs/sample_app_cmds_stubs.c @@ -0,0 +1,90 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in sample_app_cmds header + */ + +#include "sample_app_cmds.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for SAMPLE_APP_NoopCmd() + * ---------------------------------------------------- + */ +CFE_Status_t SAMPLE_APP_NoopCmd(const SAMPLE_APP_NoopCmd_t *Msg) +{ + UT_GenStub_SetupReturnBuffer(SAMPLE_APP_NoopCmd, CFE_Status_t); + + UT_GenStub_AddParam(SAMPLE_APP_NoopCmd, const SAMPLE_APP_NoopCmd_t *, Msg); + + UT_GenStub_Execute(SAMPLE_APP_NoopCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(SAMPLE_APP_NoopCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for SAMPLE_APP_ProcessCmd() + * ---------------------------------------------------- + */ +CFE_Status_t SAMPLE_APP_ProcessCmd(const SAMPLE_APP_ProcessCmd_t *Msg) +{ + UT_GenStub_SetupReturnBuffer(SAMPLE_APP_ProcessCmd, CFE_Status_t); + + UT_GenStub_AddParam(SAMPLE_APP_ProcessCmd, const SAMPLE_APP_ProcessCmd_t *, Msg); + + UT_GenStub_Execute(SAMPLE_APP_ProcessCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(SAMPLE_APP_ProcessCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for SAMPLE_APP_ResetCountersCmd() + * ---------------------------------------------------- + */ +CFE_Status_t SAMPLE_APP_ResetCountersCmd(const SAMPLE_APP_ResetCountersCmd_t *Msg) +{ + UT_GenStub_SetupReturnBuffer(SAMPLE_APP_ResetCountersCmd, CFE_Status_t); + + UT_GenStub_AddParam(SAMPLE_APP_ResetCountersCmd, const SAMPLE_APP_ResetCountersCmd_t *, Msg); + + UT_GenStub_Execute(SAMPLE_APP_ResetCountersCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(SAMPLE_APP_ResetCountersCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for SAMPLE_APP_SendHkCmd() + * ---------------------------------------------------- + */ +CFE_Status_t SAMPLE_APP_SendHkCmd(const SAMPLE_APP_SendHkCmd_t *Msg) +{ + UT_GenStub_SetupReturnBuffer(SAMPLE_APP_SendHkCmd, CFE_Status_t); + + UT_GenStub_AddParam(SAMPLE_APP_SendHkCmd, const SAMPLE_APP_SendHkCmd_t *, Msg); + + UT_GenStub_Execute(SAMPLE_APP_SendHkCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(SAMPLE_APP_SendHkCmd, CFE_Status_t); +} diff --git a/unit-test/stubs/sample_app_dispatch_stubs.c b/unit-test/stubs/sample_app_dispatch_stubs.c new file mode 100644 index 0000000..7d956f4 --- /dev/null +++ b/unit-test/stubs/sample_app_dispatch_stubs.c @@ -0,0 +1,67 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in sample_app_dispatch header + */ + +#include "sample_app_dispatch.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for SAMPLE_APP_ProcessGroundCommand() + * ---------------------------------------------------- + */ +void SAMPLE_APP_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr) +{ + UT_GenStub_AddParam(SAMPLE_APP_ProcessGroundCommand, const CFE_SB_Buffer_t *, SBBufPtr); + + UT_GenStub_Execute(SAMPLE_APP_ProcessGroundCommand, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for SAMPLE_APP_TaskPipe() + * ---------------------------------------------------- + */ +void SAMPLE_APP_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr) +{ + UT_GenStub_AddParam(SAMPLE_APP_TaskPipe, const CFE_SB_Buffer_t *, SBBufPtr); + + UT_GenStub_Execute(SAMPLE_APP_TaskPipe, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for SAMPLE_APP_VerifyCmdLength() + * ---------------------------------------------------- + */ +bool SAMPLE_APP_VerifyCmdLength(const CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength) +{ + UT_GenStub_SetupReturnBuffer(SAMPLE_APP_VerifyCmdLength, bool); + + UT_GenStub_AddParam(SAMPLE_APP_VerifyCmdLength, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(SAMPLE_APP_VerifyCmdLength, size_t, ExpectedLength); + + UT_GenStub_Execute(SAMPLE_APP_VerifyCmdLength, Basic, NULL); + + return UT_GenStub_GetReturnValue(SAMPLE_APP_VerifyCmdLength, bool); +} diff --git a/unit-test/stubs/sample_app_global_stubs.c b/unit-test/stubs/sample_app_global_stubs.c new file mode 100644 index 0000000..c80a9d0 --- /dev/null +++ b/unit-test/stubs/sample_app_global_stubs.c @@ -0,0 +1,27 @@ +/************************************************************************ + * NASA Docket No. GSC-18,920-1, and identified as “Core Flight + * System (cFS) Health & Safety (HS) Application version 2.4.1” + * + * Copyright (c) 2021 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +#include "sample_app.h" + +/* UT includes */ +#include "uttest.h" +#include "utassert.h" +#include "utstubs.h" + +SAMPLE_APP_Data_t SAMPLE_APP_Data; diff --git a/unit-test/inc/ut_sample_app.h b/unit-test/stubs/sample_app_stubs.c similarity index 58% rename from unit-test/inc/ut_sample_app.h rename to unit-test/stubs/sample_app_stubs.c index 858ef29..4001c1b 100644 --- a/unit-test/inc/ut_sample_app.h +++ b/unit-test/stubs/sample_app_stubs.c @@ -19,32 +19,33 @@ /** * @file * - * - * Purpose: - * Extra scaffolding functions for the sample_app unit test - * - * Notes: - * This is an extra UT-specific extern declaration - * to obtain access to an internal data structure - * - * UT often needs to modify internal data structures in ways that - * actual applications never would (bypassing the normal API) in - * order to exercise or set up for off-nominal cases. + * Auto-Generated stub implementations for functions defined in sample_app header */ -#ifndef UT_SAMPLE_APP_H -#define UT_SAMPLE_APP_H +#include "sample_app.h" +#include "utgenstub.h" /* - * Necessary to include these here to get the definition of the - * "SAMPLE_APP_Data_t" typedef. + * ---------------------------------------------------- + * Generated stub function for SAMPLE_APP_Init() + * ---------------------------------------------------- */ -#include "sample_app_eventids.h" -#include "sample_app.h" +int32 SAMPLE_APP_Init(void) +{ + UT_GenStub_SetupReturnBuffer(SAMPLE_APP_Init, int32); + + UT_GenStub_Execute(SAMPLE_APP_Init, Basic, NULL); + + return UT_GenStub_GetReturnValue(SAMPLE_APP_Init, int32); +} /* - * Allow UT access to the global "SAMPLE_APP_Data" object. + * ---------------------------------------------------- + * Generated stub function for SAMPLE_APP_Main() + * ---------------------------------------------------- */ -extern SAMPLE_APP_Data_t SAMPLE_APP_Data; +void SAMPLE_APP_Main(void) +{ -#endif /* UT_SAMPLE_APP_H */ + UT_GenStub_Execute(SAMPLE_APP_Main, Basic, NULL); +} diff --git a/unit-test/stubs/sample_app_utils_stubs.c b/unit-test/stubs/sample_app_utils_stubs.c new file mode 100644 index 0000000..346a29a --- /dev/null +++ b/unit-test/stubs/sample_app_utils_stubs.c @@ -0,0 +1,54 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in sample_app_utils header + */ + +#include "sample_app_utils.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for SAMPLE_APP_GetCrc() + * ---------------------------------------------------- + */ +void SAMPLE_APP_GetCrc(const char *TableName) +{ + UT_GenStub_AddParam(SAMPLE_APP_GetCrc, const char *, TableName); + + UT_GenStub_Execute(SAMPLE_APP_GetCrc, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for SAMPLE_APP_TblValidationFunc() + * ---------------------------------------------------- + */ +int32 SAMPLE_APP_TblValidationFunc(void *TblData) +{ + UT_GenStub_SetupReturnBuffer(SAMPLE_APP_TblValidationFunc, int32); + + UT_GenStub_AddParam(SAMPLE_APP_TblValidationFunc, void *, TblData); + + UT_GenStub_Execute(SAMPLE_APP_TblValidationFunc, Basic, NULL); + + return UT_GenStub_GetReturnValue(SAMPLE_APP_TblValidationFunc, int32); +} From d96999c0563a2e81e7539a416ff5370d6c703d09 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 1 Nov 2023 10:23:31 -0400 Subject: [PATCH 15/23] Fix #211, add DisplayParam command The display param command shows an example of how to pass in and use a parameter with a command. 3 types are illustrated; a signed and unsigned int, and a string. --- config/default_sample_app_fcncodes.h | 1 + config/default_sample_app_interface_cfg.h | 44 +++++++++++++++++++ config/default_sample_app_mission_cfg.h | 2 +- config/default_sample_app_msgdefs.h | 9 +++- config/default_sample_app_msgstruct.h | 6 +++ fsw/inc/sample_app_eventids.h | 1 + fsw/src/sample_app_cmds.c | 14 ++++++ fsw/src/sample_app_cmds.h | 1 + fsw/src/sample_app_dispatch.c | 10 +++-- mission_build.cmake | 2 + .../coveragetest_sample_app_cmds.c | 42 ++++++++++++++---- .../coveragetest_sample_app_dispatch.c | 23 ++++++++++ unit-test/stubs/sample_app_cmds_stubs.c | 16 +++++++ 13 files changed, 157 insertions(+), 14 deletions(-) create mode 100644 config/default_sample_app_interface_cfg.h diff --git a/config/default_sample_app_fcncodes.h b/config/default_sample_app_fcncodes.h index aec457f..b701c1c 100644 --- a/config/default_sample_app_fcncodes.h +++ b/config/default_sample_app_fcncodes.h @@ -38,5 +38,6 @@ #define SAMPLE_APP_NOOP_CC 0 #define SAMPLE_APP_RESET_COUNTERS_CC 1 #define SAMPLE_APP_PROCESS_CC 2 +#define SAMPLE_APP_DISPLAY_PARAM_CC 3 #endif diff --git a/config/default_sample_app_interface_cfg.h b/config/default_sample_app_interface_cfg.h new file mode 100644 index 0000000..aac83dd --- /dev/null +++ b/config/default_sample_app_interface_cfg.h @@ -0,0 +1,44 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * SAMPLE_APP Application Public Definitions + * + * This provides default values for configurable items that affect + * the interface(s) of this module. This includes the CMD/TLM message + * interface, tables definitions, and any other data products that + * serve to exchange information with other entities. + * + * @note This file may be overridden/superceded by mission-provided defintions + * either by overriding this header or by generating definitions from a command/data + * dictionary tool. + */ +#ifndef SAMPLE_APP_INTERFACE_CFG_H +#define SAMPLE_APP_INTERFACE_CFG_H + +/** + * \brief Length of string buffer in the Display Value command + * + * The Display Value command offers an example of how to use command + * parameters of different types. This macro controls the length + * of the string parameter. + */ +#define SAMPLE_APP_STRING_VAL_LEN 10 + +#endif diff --git a/config/default_sample_app_mission_cfg.h b/config/default_sample_app_mission_cfg.h index 93d3307..9c5d166 100644 --- a/config/default_sample_app_mission_cfg.h +++ b/config/default_sample_app_mission_cfg.h @@ -31,6 +31,6 @@ #ifndef SAMPLE_APP_MISSION_CFG_H #define SAMPLE_APP_MISSION_CFG_H -/* Placeholder - SAMPLE_APP currently has no mission-scope config options */ +#include "sample_app_interface_cfg.h" #endif diff --git a/config/default_sample_app_msgdefs.h b/config/default_sample_app_msgdefs.h index 7ea7b82..1e4d10e 100644 --- a/config/default_sample_app_msgdefs.h +++ b/config/default_sample_app_msgdefs.h @@ -29,12 +29,19 @@ #include "common_types.h" #include "sample_app_fcncodes.h" +typedef struct SAMPLE_APP_DisplayParam_Payload +{ + uint32 ValU32; /**< 32 bit unsigned integer value */ + int16 ValI16; /**< 16 bit signed integer value */ + char ValStr[SAMPLE_APP_STRING_VAL_LEN]; /**< An example string */ +} SAMPLE_APP_DisplayParam_Payload_t; + /*************************************************************************/ /* ** Type definition (Sample App housekeeping) */ -typedef struct +typedef struct SAMPLE_APP_HkTlm_Payload { uint8 CommandErrorCounter; uint8 CommandCounter; diff --git a/config/default_sample_app_msgstruct.h b/config/default_sample_app_msgstruct.h index 90d1a47..03327c9 100644 --- a/config/default_sample_app_msgstruct.h +++ b/config/default_sample_app_msgstruct.h @@ -60,6 +60,12 @@ typedef struct CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ } SAMPLE_APP_ProcessCmd_t; +typedef struct +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + SAMPLE_APP_DisplayParam_Payload_t Payload; +} SAMPLE_APP_DisplayParamCmd_t; + /*************************************************************************/ /* ** Type definition (Sample App housekeeping) diff --git a/fsw/inc/sample_app_eventids.h b/fsw/inc/sample_app_eventids.h index fdbe613..06406d8 100644 --- a/fsw/inc/sample_app_eventids.h +++ b/fsw/inc/sample_app_eventids.h @@ -33,5 +33,6 @@ #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 #endif /* SAMPLE_APP_EVENTS_H */ diff --git a/fsw/src/sample_app_cmds.c b/fsw/src/sample_app_cmds.c index 6dfe79f..e30fe32 100644 --- a/fsw/src/sample_app_cmds.c +++ b/fsw/src/sample_app_cmds.c @@ -143,3 +143,17 @@ CFE_Status_t SAMPLE_APP_ProcessCmd(const SAMPLE_APP_ProcessCmd_t *Msg) return CFE_SUCCESS; } + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* A simple example command that displays a passed-in value */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +CFE_Status_t SAMPLE_APP_DisplayParamCmd(const SAMPLE_APP_DisplayParamCmd_t *Msg) +{ + CFE_EVS_SendEvent(SAMPLE_APP_VALUE_INF_EID, CFE_EVS_EventType_INFORMATION, + "SAMPLE_APP: ValU32=%lu, ValI16=%d, ValStr=%s", (unsigned long)Msg->Payload.ValU32, + (int)Msg->Payload.ValI16, Msg->Payload.ValStr); + + return CFE_SUCCESS; +} diff --git a/fsw/src/sample_app_cmds.h b/fsw/src/sample_app_cmds.h index 384ebe8..8b99259 100644 --- a/fsw/src/sample_app_cmds.h +++ b/fsw/src/sample_app_cmds.h @@ -34,5 +34,6 @@ CFE_Status_t SAMPLE_APP_SendHkCmd(const SAMPLE_APP_SendHkCmd_t *Msg); CFE_Status_t SAMPLE_APP_ResetCountersCmd(const SAMPLE_APP_ResetCountersCmd_t *Msg); CFE_Status_t SAMPLE_APP_ProcessCmd(const SAMPLE_APP_ProcessCmd_t *Msg); CFE_Status_t SAMPLE_APP_NoopCmd(const SAMPLE_APP_NoopCmd_t *Msg); +CFE_Status_t SAMPLE_APP_DisplayParamCmd(const SAMPLE_APP_DisplayParamCmd_t *Msg); #endif /* SAMPLE_APP_CMDS_H */ diff --git a/fsw/src/sample_app_dispatch.c b/fsw/src/sample_app_dispatch.c index 7e2a256..4928cb7 100644 --- a/fsw/src/sample_app_dispatch.c +++ b/fsw/src/sample_app_dispatch.c @@ -78,7 +78,7 @@ void SAMPLE_APP_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr) CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &CommandCode); /* - ** Process "known" SAMPLE app ground commands + ** Process SAMPLE app ground commands */ switch (CommandCode) { @@ -87,7 +87,6 @@ void SAMPLE_APP_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr) { SAMPLE_APP_NoopCmd((const SAMPLE_APP_NoopCmd_t *)SBBufPtr); } - break; case SAMPLE_APP_RESET_COUNTERS_CC: @@ -95,7 +94,6 @@ void SAMPLE_APP_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr) { SAMPLE_APP_ResetCountersCmd((const SAMPLE_APP_ResetCountersCmd_t *)SBBufPtr); } - break; case SAMPLE_APP_PROCESS_CC: @@ -103,7 +101,13 @@ void SAMPLE_APP_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr) { SAMPLE_APP_ProcessCmd((const SAMPLE_APP_ProcessCmd_t *)SBBufPtr); } + break; + case SAMPLE_APP_DISPLAY_PARAM_CC: + if (SAMPLE_APP_VerifyCmdLength(&SBBufPtr->Msg, sizeof(SAMPLE_APP_DisplayParamCmd_t))) + { + SAMPLE_APP_DisplayParamCmd((const SAMPLE_APP_DisplayParamCmd_t *)SBBufPtr); + } break; /* default case already found during FC vs length test */ diff --git a/mission_build.cmake b/mission_build.cmake index 9b7d460..1cbd57f 100644 --- a/mission_build.cmake +++ b/mission_build.cmake @@ -11,6 +11,7 @@ # The list of header files that control the SAMPLE_APP configuration set(SAMPLE_APP_MISSION_CONFIG_FILE_LIST sample_app_fcncodes.h + sample_app_interface_cfg.h sample_app_mission_cfg.h sample_app_perfids.h sample_app_msg.h @@ -24,6 +25,7 @@ set(SAMPLE_APP_MISSION_CONFIG_FILE_LIST if (CFE_EDS_ENABLED_BUILD) # In an EDS-based build, these files come generated from the EDS tool + set(SAMPLE_APP_CFGFILE_SRC_sample_app_interface_cfg "sample_app_eds_designparameters.h") set(SAMPLE_APP_CFGFILE_SRC_sample_app_tbldefs "sample_app_eds_typedefs.h") set(SAMPLE_APP_CFGFILE_SRC_sample_app_tblstruct "sample_app_eds_typedefs.h") set(SAMPLE_APP_CFGFILE_SRC_sample_app_msgdefs "sample_app_eds_typedefs.h") diff --git a/unit-test/coveragetest/coveragetest_sample_app_cmds.c b/unit-test/coveragetest/coveragetest_sample_app_cmds.c index 218ea96..036dbc0 100644 --- a/unit-test/coveragetest/coveragetest_sample_app_cmds.c +++ b/unit-test/coveragetest/coveragetest_sample_app_cmds.c @@ -143,11 +143,11 @@ void Test_SAMPLE_APP_ProcessCmd(void) UtAssert_INT32_EQ(SAMPLE_APP_ProcessCmd(&TestMsg), CFE_SUCCESS); /* - * Successful operation results in two calls to CFE_ES_WriteToSysLog() - one - * in this function reporting the table values, and one through - * SAMPLE_APP_GetCrc(). + * This only needs to account for the call to CFE_ES_WriteToSysLog() directly + * invoked by the unit under test. Note that in this build environment, the + * SAMPLE_APP_GetCrc() function is a stub. */ - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 2); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 1); /* * Confirm that the CFE_TBL_GetAddress() call was done @@ -168,19 +168,42 @@ void Test_SAMPLE_APP_ProcessCmd(void) */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_UNREGISTERED); UtAssert_INT32_EQ(SAMPLE_APP_ProcessCmd(&TestMsg), CFE_TBL_ERR_UNREGISTERED); - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 3); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 2); /* * Configure CFE_TBL_ReleaseAddress() to return an error, exercising the * error return path. - * Confirm three additional calls to CFE_ES_WriteToSysLog() - one - * reporting the table values, one through SAMPLE_APP_GetCrc() and one - * through the CFE_TBL_ReleaseAddress() error path. + * Confirm two additional calls to CFE_ES_WriteToSysLog() - one + * reporting the table values, and one through the CFE_TBL_ReleaseAddress() + * error path. */ UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS); UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_ReleaseAddress), CFE_TBL_ERR_NO_ACCESS); UtAssert_INT32_EQ(SAMPLE_APP_ProcessCmd(&TestMsg), CFE_TBL_ERR_NO_ACCESS); - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 6); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 4); +} + +void Test_SAMPLE_APP_DisplayParamCmd(void) +{ + /* + * Test Case For: + * void SAMPLE_APP_DisplayParamCmd( const SAMPLE_APP_DisplayParamCmd_t *Msg ) + */ + SAMPLE_APP_DisplayParamCmd_t TestMsg; + UT_CheckEvent_t EventTest; + + memset(&TestMsg, 0, sizeof(TestMsg)); + + UT_CHECKEVENT_SETUP(&EventTest, SAMPLE_APP_VALUE_INF_EID, "SAMPLE_APP: ValU32=%lu, ValI16=%d, ValStr=%s"); + TestMsg.Payload.ValU32 = 10; + TestMsg.Payload.ValI16 = -4; + snprintf(TestMsg.Payload.ValStr, sizeof(TestMsg.Payload.ValStr), "Hello"); + + UtAssert_INT32_EQ(SAMPLE_APP_DisplayParamCmd(&TestMsg), CFE_SUCCESS); + /* + * Confirm that the event was generated + */ + UtAssert_UINT32_EQ(EventTest.MatchCount, 1); } /* @@ -192,4 +215,5 @@ void UtTest_Setup(void) ADD_TEST(SAMPLE_APP_NoopCmd); ADD_TEST(SAMPLE_APP_ResetCountersCmd); ADD_TEST(SAMPLE_APP_ProcessCmd); + ADD_TEST(SAMPLE_APP_DisplayParamCmd); } diff --git a/unit-test/coveragetest/coveragetest_sample_app_dispatch.c b/unit-test/coveragetest/coveragetest_sample_app_dispatch.c index bf644f9..a968286 100644 --- a/unit-test/coveragetest/coveragetest_sample_app_dispatch.c +++ b/unit-test/coveragetest/coveragetest_sample_app_dispatch.c @@ -109,6 +109,7 @@ void Test_SAMPLE_APP_ProcessGroundCommand(void) SAMPLE_APP_NoopCmd_t Noop; SAMPLE_APP_ResetCountersCmd_t Reset; SAMPLE_APP_ProcessCmd_t Process; + SAMPLE_APP_DisplayParamCmd_t DisplayParam; } TestMsg; UT_CheckEvent_t EventTest; @@ -195,6 +196,28 @@ void Test_SAMPLE_APP_ProcessGroundCommand(void) UtAssert_STUB_COUNT(SAMPLE_APP_ProcessCmd, 1); UtAssert_UINT32_EQ(EventTest.MatchCount, 3); + /* test dispatch of DISPLAY_PARAM */ + FcnCode = SAMPLE_APP_DISPLAY_PARAM_CC; + Size = sizeof(TestMsg.DisplayParam); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); + + SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); + + UtAssert_STUB_COUNT(SAMPLE_APP_DisplayParamCmd, 1); + + FcnCode = SAMPLE_APP_DISPLAY_PARAM_CC; + Size = sizeof(TestMsg.DisplayParam) - 1; + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); + UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); + + SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); + + UtAssert_STUB_COUNT(SAMPLE_APP_DisplayParamCmd, 1); + UtAssert_UINT32_EQ(EventTest.MatchCount, 4); + /* test an invalid CC */ FcnCode = 1000; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); diff --git a/unit-test/stubs/sample_app_cmds_stubs.c b/unit-test/stubs/sample_app_cmds_stubs.c index e53ec8a..bfa80ce 100644 --- a/unit-test/stubs/sample_app_cmds_stubs.c +++ b/unit-test/stubs/sample_app_cmds_stubs.c @@ -25,6 +25,22 @@ #include "sample_app_cmds.h" #include "utgenstub.h" +/* + * ---------------------------------------------------- + * Generated stub function for SAMPLE_APP_DisplayParamCmd() + * ---------------------------------------------------- + */ +CFE_Status_t SAMPLE_APP_DisplayParamCmd(const SAMPLE_APP_DisplayParamCmd_t *Msg) +{ + UT_GenStub_SetupReturnBuffer(SAMPLE_APP_DisplayParamCmd, CFE_Status_t); + + UT_GenStub_AddParam(SAMPLE_APP_DisplayParamCmd, const SAMPLE_APP_DisplayParamCmd_t *, Msg); + + UT_GenStub_Execute(SAMPLE_APP_DisplayParamCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(SAMPLE_APP_DisplayParamCmd, CFE_Status_t); +} + /* * ---------------------------------------------------- * Generated stub function for SAMPLE_APP_NoopCmd() From bb6c4fd0dbb707114444f9e0f2d894d2a0e76a49 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 13 Nov 2023 11:45:51 -0500 Subject: [PATCH 16/23] Updating documentation and version numbers for v1.3.0-rc4+dev65 --- CHANGELOG.md | 6 ++++++ fsw/src/sample_app_version.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d59533b..4b16d91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Development Build: 1.3.0-rc4+dev65 +- bring sample_app fully into compliance +- Rename CommandCode variable to FcnCode +- Add check for success of CFE_TBL_Load() during Initialization +- See , , and + ## Development Build: v1.3.0-rc4+dev56 - Apply consistent Event ID names to common events - Remove component-specific cFE header #includes diff --git a/fsw/src/sample_app_version.h b/fsw/src/sample_app_version.h index b29b42d..4498804 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 56 /*!< Development Build: Number of commits since baseline */ +#define SAMPLE_APP_BUILD_NUMBER 65 /*!< Development Build: Number of commits since baseline */ #define SAMPLE_APP_BUILD_BASELINE \ "v1.3.0-rc4" /*!< Development Build: git tag that is the base for the current development */ From cd247517fca46414331b7f9492c2fff371d9c3de Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 7 Dec 2023 10:34:02 -0500 Subject: [PATCH 17/23] Fix #219, define msgids via topicids The MsgID value is a conversion from TopicID --- arch_build.cmake | 8 +++++++- config/default_sample_app_msgids.h | 11 +++++----- config/default_sample_app_topicids.h | 30 ++++++++++++++++++++++++++++ mission_build.cmake | 1 + 4 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 config/default_sample_app_topicids.h diff --git a/arch_build.cmake b/arch_build.cmake index d2d95e2..c526397 100644 --- a/arch_build.cmake +++ b/arch_build.cmake @@ -20,8 +20,14 @@ set(SAMPLE_APP_PLATFORM_CONFIG_FILE_LIST # This makes them individually overridable by the missions, without modifying # the distribution default copies foreach(SAMPLE_APP_CFGFILE ${SAMPLE_APP_PLATFORM_CONFIG_FILE_LIST}) + get_filename_component(CFGKEY "${SAMPLE_APP_CFGFILE}" NAME_WE) + if (DEFINED SAMPLE_APP_CFGFILE_SRC_${CFGKEY}) + set(DEFAULT_SOURCE GENERATED_FILE "${SAMPLE_APP_CFGFILE_SRC_${CFGKEY}}") + else() + set(DEFAULT_SOURCE FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${SAMPLE_APP_CFGFILE}") + endif() generate_config_includefile( FILE_NAME "${SAMPLE_APP_CFGFILE}" - FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${SAMPLE_APP_CFGFILE}" + ${DEFAULT_SOURCE} ) endforeach() diff --git a/config/default_sample_app_msgids.h b/config/default_sample_app_msgids.h index 6b11e55..652c544 100644 --- a/config/default_sample_app_msgids.h +++ b/config/default_sample_app_msgids.h @@ -23,10 +23,11 @@ #ifndef SAMPLE_APP_MSGIDS_H #define SAMPLE_APP_MSGIDS_H -/* V1 Command Message IDs must be 0x18xx */ -#define SAMPLE_APP_CMD_MID 0x1882 -#define SAMPLE_APP_SEND_HK_MID 0x1883 -/* V1 Telemetry Message IDs must be 0x08xx */ -#define SAMPLE_APP_HK_TLM_MID 0x0883 +#include "cfe_core_api_base_msgids.h" +#include "sample_app_topicids.h" + +#define SAMPLE_APP_CMD_MID CFE_PLATFORM_CMD_TOPICID_TO_MIDV(SAMPLE_APP_CMD_TOPICID) +#define SAMPLE_APP_SEND_HK_MID CFE_PLATFORM_CMD_TOPICID_TO_MIDV(SAMPLE_APP_SEND_HK_TOPICID) +#define SAMPLE_APP_HK_TLM_MID CFE_PLATFORM_TLM_TOPICID_TO_MIDV(SAMPLE_APP_HK_TLM_TOPICID) #endif diff --git a/config/default_sample_app_topicids.h b/config/default_sample_app_topicids.h new file mode 100644 index 0000000..cfb25b0 --- /dev/null +++ b/config/default_sample_app_topicids.h @@ -0,0 +1,30 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * SAMPLE_APP Application Topic IDs + */ +#ifndef SAMPLE_APP_TOPICIDS_H +#define SAMPLE_APP_TOPICIDS_H + +#define SAMPLE_APP_CMD_TOPICID 0x82 +#define SAMPLE_APP_SEND_HK_TOPICID 0x83 +#define SAMPLE_APP_HK_TLM_TOPICID 0x83 + +#endif diff --git a/mission_build.cmake b/mission_build.cmake index 1cbd57f..7c156c6 100644 --- a/mission_build.cmake +++ b/mission_build.cmake @@ -20,6 +20,7 @@ set(SAMPLE_APP_MISSION_CONFIG_FILE_LIST sample_app_tbl.h sample_app_tbldefs.h sample_app_tblstruct.h + sample_app_topicids.h ) if (CFE_EDS_ENABLED_BUILD) From fb8894048d291deb5cd054b0ba8ed0465b4ae0ec Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 12 Dec 2023 08:51:19 -0500 Subject: [PATCH 18/23] Updating documentation and version numbers for v1.3.0-rc4+dev69 --- CHANGELOG.md | 6 +++++- fsw/src/sample_app_version.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b16d91..f444e2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## Development Build: 1.3.0-rc4+dev65 +## Development Build: v1.3.0-rc4+dev69 +- define msgids via topicids +- See + +## Development Build: v1.3.0-rc4+dev65 - bring sample_app fully into compliance - Rename CommandCode variable to FcnCode - Add check for success of CFE_TBL_Load() during Initialization diff --git a/fsw/src/sample_app_version.h b/fsw/src/sample_app_version.h index 4498804..be86775 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 65 /*!< Development Build: Number of commits since baseline */ +#define SAMPLE_APP_BUILD_NUMBER 69 /*!< Development Build: Number of commits since baseline */ #define SAMPLE_APP_BUILD_BASELINE \ "v1.3.0-rc4" /*!< Development Build: git tag that is the base for the current development */ From c7966512a4f6a61a99c0b6bda9cc367ef53d610e Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 13 Dec 2023 14:00:39 -0500 Subject: [PATCH 19/23] Fix #222, add CFE_MISSION prefix to topicids --- config/default_sample_app_msgids.h | 6 +++--- config/default_sample_app_topicids.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/default_sample_app_msgids.h b/config/default_sample_app_msgids.h index 652c544..d3c0c16 100644 --- a/config/default_sample_app_msgids.h +++ b/config/default_sample_app_msgids.h @@ -26,8 +26,8 @@ #include "cfe_core_api_base_msgids.h" #include "sample_app_topicids.h" -#define SAMPLE_APP_CMD_MID CFE_PLATFORM_CMD_TOPICID_TO_MIDV(SAMPLE_APP_CMD_TOPICID) -#define SAMPLE_APP_SEND_HK_MID CFE_PLATFORM_CMD_TOPICID_TO_MIDV(SAMPLE_APP_SEND_HK_TOPICID) -#define SAMPLE_APP_HK_TLM_MID CFE_PLATFORM_TLM_TOPICID_TO_MIDV(SAMPLE_APP_HK_TLM_TOPICID) +#define SAMPLE_APP_CMD_MID CFE_PLATFORM_CMD_TOPICID_TO_MIDV(CFE_MISSION_SAMPLE_APP_CMD_TOPICID) +#define SAMPLE_APP_SEND_HK_MID CFE_PLATFORM_CMD_TOPICID_TO_MIDV(CFE_MISSION_SAMPLE_APP_SEND_HK_TOPICID) +#define SAMPLE_APP_HK_TLM_MID CFE_PLATFORM_TLM_TOPICID_TO_MIDV(CFE_MISSION_SAMPLE_APP_HK_TLM_TOPICID) #endif diff --git a/config/default_sample_app_topicids.h b/config/default_sample_app_topicids.h index cfb25b0..c78676e 100644 --- a/config/default_sample_app_topicids.h +++ b/config/default_sample_app_topicids.h @@ -23,8 +23,8 @@ #ifndef SAMPLE_APP_TOPICIDS_H #define SAMPLE_APP_TOPICIDS_H -#define SAMPLE_APP_CMD_TOPICID 0x82 -#define SAMPLE_APP_SEND_HK_TOPICID 0x83 -#define SAMPLE_APP_HK_TLM_TOPICID 0x83 +#define CFE_MISSION_SAMPLE_APP_CMD_TOPICID 0x82 +#define CFE_MISSION_SAMPLE_APP_SEND_HK_TOPICID 0x83 +#define CFE_MISSION_SAMPLE_APP_HK_TLM_TOPICID 0x83 #endif From bd145c805b2eed7b2711e3334bb1d57b21b4a51e Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 13 Dec 2023 14:48:22 -0500 Subject: [PATCH 20/23] Fix #224, initial inclusion of EDS file --- CMakeLists.txt | 11 +- eds/sample_app.xml | 140 ++++++++++++++++++ fsw/src/sample_app_eds_dispatch.c | 88 +++++++++++ .../coveragetest_sample_app_eds_dispatch.c | 62 ++++++++ 4 files changed, 300 insertions(+), 1 deletion(-) create mode 100644 eds/sample_app.xml create mode 100644 fsw/src/sample_app_eds_dispatch.c create mode 100644 unit-test/coveragetest/coveragetest_sample_app_eds_dispatch.c diff --git a/CMakeLists.txt b/CMakeLists.txt index de47fce..de20ccd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,19 @@ project(CFE_SAMPLE_APP C) set(APP_SRC_FILES fsw/src/sample_app.c fsw/src/sample_app_cmds.c - fsw/src/sample_app_dispatch.c fsw/src/sample_app_utils.c ) +if (CFE_EDS_ENABLED_BUILD) + list(APPEND APP_SRC_FILES + fsw/src/sample_app_eds_dispatch.c + ) +else() + list(APPEND APP_SRC_FILES + fsw/src/sample_app_dispatch.c + ) +endif() + # Create the app module add_cfe_app(sample_app ${APP_SRC_FILES}) diff --git a/eds/sample_app.xml b/eds/sample_app.xml new file mode 100644 index 0000000..a34a4cf --- /dev/null +++ b/eds/sample_app.xml @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fsw/src/sample_app_eds_dispatch.c b/fsw/src/sample_app_eds_dispatch.c new file mode 100644 index 0000000..156973f --- /dev/null +++ b/fsw/src/sample_app_eds_dispatch.c @@ -0,0 +1,88 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * \file + * This file contains the source code for the Sample App. + */ + +/* +** Include Files: +*/ +#include "sample_app.h" +#include "sample_app_dispatch.h" +#include "sample_app_cmds.h" +#include "sample_app_eventids.h" +#include "sample_app_msgids.h" +#include "sample_app_msg.h" + +#include "sample_app_eds_dispatcher.h" +#include "sample_app_eds_dictionary.h" + +/* + * Define a lookup table for SAMPLE app command codes + */ +static const SAMPLE_APP_Application_Component_Telecommand_DispatchTable_t SAMPLE_TC_DISPATCH_TABLE = { + .CMD = {.NoopCmd_indication = SAMPLE_APP_NoopCmd, + .ResetCountersCmd_indication = SAMPLE_APP_ResetCountersCmd, + .ProcessCmd_indication = SAMPLE_APP_ProcessCmd, + .DisplayParamCmd_indication = SAMPLE_APP_DisplayParamCmd}, + .SEND_HK = {.indication = SAMPLE_APP_SendHkCmd}}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/ +/* */ +/* Purpose: */ +/* This routine will process any packet that is received on the SAMPLE */ +/* command pipe. */ +/* */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +void SAMPLE_APP_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr) +{ + CFE_Status_t Status; + CFE_SB_MsgId_t MsgId; + CFE_MSG_Size_t MsgSize; + CFE_MSG_FcnCode_t MsgFc; + + Status = SAMPLE_APP_Application_Component_Telecommand_Dispatch(CFE_SB_Telecommand_indication_Command_ID, SBBufPtr, + &SAMPLE_TC_DISPATCH_TABLE); + + if (Status != CFE_SUCCESS) + { + CFE_MSG_GetMsgId(&SBBufPtr->Msg, &MsgId); + CFE_MSG_GetSize(&SBBufPtr->Msg, &MsgSize); + CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &MsgFc); + ++SAMPLE_APP_Data.ErrCounter; + + if (Status == CFE_STATUS_UNKNOWN_MSG_ID) + { + CFE_EVS_SendEvent(SAMPLE_APP_MID_ERR_EID, CFE_EVS_EventType_ERROR, + "SAMPLE: invalid command packet,MID = 0x%x", (unsigned int)CFE_SB_MsgIdToValue(MsgId)); + } + else if (Status == CFE_STATUS_WRONG_MSG_LENGTH) + { + CFE_EVS_SendEvent(SAMPLE_APP_CMD_LEN_ERR_EID, CFE_EVS_EventType_ERROR, + "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u", + (unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)MsgFc, (unsigned int)MsgSize); + } + else + { + CFE_EVS_SendEvent(SAMPLE_APP_CC_ERR_EID, CFE_EVS_EventType_ERROR, + "SAMPLE: Invalid ground command code: CC = %d", (int)MsgFc); + } + } +} diff --git a/unit-test/coveragetest/coveragetest_sample_app_eds_dispatch.c b/unit-test/coveragetest/coveragetest_sample_app_eds_dispatch.c new file mode 100644 index 0000000..1f06fa9 --- /dev/null +++ b/unit-test/coveragetest/coveragetest_sample_app_eds_dispatch.c @@ -0,0 +1,62 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* +** Purpose: +** Coverage Unit Test cases for the SAMPLE Application +** +** Notes: +** This implements various test cases to exercise all code +** paths through all functions defined in the SAMPLE application. +** +** It is primarily focused at providing examples of the various +** stub configurations, hook functions, and wrapper calls that +** are often needed when coercing certain code paths through +** complex functions. +*/ + +/* + * Includes + */ + +#include "sample_app_coveragetest_common.h" +#include "sample_app.h" +#include "sample_app_dispatch.h" +#include "sample_app_cmds.h" + +/* +********************************************************************************** +** TEST CASE FUNCTIONS +********************************************************************************** +*/ + +void Test_SAMPLE_APP_TaskPipe(void) +{ + /* + * Test Case For: + * void SAMPLE_APP_TaskPipe + */ +} + +/* + * Register the test cases to execute with the unit test tool + */ +void UtTest_Setup(void) +{ + ADD_TEST(SAMPLE_APP_TaskPipe); +} From a4f544b45c00497c0bd1a930f260699a6b1a6495 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 26 Dec 2023 11:24:40 -0500 Subject: [PATCH 21/23] Fix #206, updating sample_app to use new versioning system. --- fsw/src/sample_app.c | 6 +++++- fsw/src/sample_app.h | 1 + fsw/src/sample_app_version.h | 26 ++++++++++++++++---------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/fsw/src/sample_app.c b/fsw/src/sample_app.c index b3b7e8a..6a96de4 100644 --- a/fsw/src/sample_app.c +++ b/fsw/src/sample_app.c @@ -110,6 +110,7 @@ void SAMPLE_APP_Main(void) int32 SAMPLE_APP_Init(void) { int32 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)); @@ -191,8 +192,11 @@ 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_EVS_SendEvent(SAMPLE_APP_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "Sample App Initialized.%s", - SAMPLE_APP_VERSION_STRING); + VersionString); } return status; diff --git a/fsw/src/sample_app.h b/fsw/src/sample_app.h index 321d1d8..c2cac81 100644 --- a/fsw/src/sample_app.h +++ b/fsw/src/sample_app.h @@ -29,6 +29,7 @@ ** Required header files. */ #include "cfe.h" +#include "cfe_config.h" #include "sample_app_mission_cfg.h" #include "sample_app_platform_cfg.h" diff --git a/fsw/src/sample_app_version.h b/fsw/src/sample_app_version.h index be86775..c218b4c 100644 --- a/fsw/src/sample_app_version.h +++ b/fsw/src/sample_app_version.h @@ -27,16 +27,22 @@ /* Development Build Macro Definitions */ -#define SAMPLE_APP_BUILD_NUMBER 69 /*!< Development Build: Number of commits since baseline */ -#define SAMPLE_APP_BUILD_BASELINE \ - "v1.3.0-rc4" /*!< Development Build: git tag that is the base for the current development */ +#define SAMPLE_APP_BUILD_NUMBER 69 /*!< 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 */ /* * Version Macros, see \ref cfsversions for definitions. */ #define SAMPLE_APP_MAJOR_VERSION 1 /*!< @brief Major version number. */ #define SAMPLE_APP_MINOR_VERSION 1 /*!< @brief Minor version number. */ -#define SAMPLE_APP_REVISION 99 /*!< @brief Revision version number. Value of 99 indicates a development version.*/ +#define SAMPLE_APP_REVISION 0 /*!< @brief Revision version number. Value of 0 indicates a development version.*/ + +/** + * @brief Last official release. + */ +#define SAMPLE_APP_LAST_OFFICIAL "v1.1.0" /*! * @brief Mission revision. @@ -57,12 +63,12 @@ */ #define SAMPLE_APP_VERSION SAMPLE_APP_BUILD_BASELINE "+dev" SAMPLE_APP_STR(SAMPLE_APP_BUILD_NUMBER) -/*! @brief Development Build Version String. - * @details Reports the current development build's baseline, number, and name. Also includes a note about the latest - * official version. @n See @ref cfsversions for format differences between development and release versions. +/** + * @brief Max Version String length. + * + * Maximum length that an OSAL version string can be. + * */ -#define SAMPLE_APP_VERSION_STRING \ - " Sample App DEVELOPMENT BUILD " SAMPLE_APP_VERSION \ - ", Last Official Release: v1.1.0" /* For full support please use this version */ +#define SAMPLE_APP_CFG_MAX_VERSION_STR_LEN 256 #endif /* SAMPLE_APP_VERSION_H */ From 6f29a5e2a8a98892fe54856988189ed8f3f4054c Mon Sep 17 00:00:00 2001 From: Dylan Date: Wed, 17 Jan 2024 14:13:13 -0500 Subject: [PATCH 22/23] Updating documentation and version numbers for equuleus-rc1+dev36 --- CHANGELOG.md | 4 ++++ fsw/src/sample_app_version.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f444e2a..1024d1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Development Build: equuleus-rc1+dev36 +- updating sample_app to use new versioning system +- See + ## Development Build: v1.3.0-rc4+dev69 - define msgids via topicids - See diff --git a/fsw/src/sample_app_version.h b/fsw/src/sample_app_version.h index c218b4c..fd9349b 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 69 /*!< Development Build: Number of commits since baseline */ +#define SAMPLE_APP_BUILD_NUMBER 36 /*!< 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 */ From 41018a883e41e6f411062f1d8861c80dc453a1cf Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 6 Mar 2024 19:30:24 -0500 Subject: [PATCH 23/23] Fix #228, apply name changes to EDS dispatcher Renames symbols to match recent EdsLib change --- fsw/src/sample_app_eds_dispatch.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fsw/src/sample_app_eds_dispatch.c b/fsw/src/sample_app_eds_dispatch.c index 156973f..6751e43 100644 --- a/fsw/src/sample_app_eds_dispatch.c +++ b/fsw/src/sample_app_eds_dispatch.c @@ -37,7 +37,7 @@ /* * Define a lookup table for SAMPLE app command codes */ -static const SAMPLE_APP_Application_Component_Telecommand_DispatchTable_t SAMPLE_TC_DISPATCH_TABLE = { +static const EdsDispatchTable_SAMPLE_APP_Application_CFE_SB_Telecommand_t SAMPLE_TC_DISPATCH_TABLE = { .CMD = {.NoopCmd_indication = SAMPLE_APP_NoopCmd, .ResetCountersCmd_indication = SAMPLE_APP_ResetCountersCmd, .ProcessCmd_indication = SAMPLE_APP_ProcessCmd, @@ -58,8 +58,7 @@ void SAMPLE_APP_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr) CFE_MSG_Size_t MsgSize; CFE_MSG_FcnCode_t MsgFc; - Status = SAMPLE_APP_Application_Component_Telecommand_Dispatch(CFE_SB_Telecommand_indication_Command_ID, SBBufPtr, - &SAMPLE_TC_DISPATCH_TABLE); + Status = EdsDispatch_SAMPLE_APP_Application_Telecommand(SBBufPtr, &SAMPLE_TC_DISPATCH_TABLE); if (Status != CFE_SUCCESS) {