From bd145c805b2eed7b2711e3334bb1d57b21b4a51e Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 13 Dec 2023 14:48:22 -0500 Subject: [PATCH] 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); +}