Skip to content

Commit

Permalink
Merge pull request #225 from jphickey/fix-224-eds
Browse files Browse the repository at this point in the history
Fix #224, initial inclusion of EDS file
  • Loading branch information
dmknutsen authored Dec 15, 2023
2 parents 81d8351 + bd145c8 commit e1b76be
Show file tree
Hide file tree
Showing 4 changed files with 300 additions and 1 deletion.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
140 changes: 140 additions & 0 deletions eds/sample_app.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
GSC-18128-1, "Core Flight Executive Version 6.7"
LEW-19710-1, "CCSDS electronic data sheet implementation"
Copyright (c) 2006-2019 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.
This document adheres to the Electronic Data Sheet (EDS) XML schema
as prescribed in CCSDS book 876.0.
Purpose:
This describes all interface objects for the Executive Services (CFE_ES)
core application
-->
<PackageFile xmlns="http://www.ccsds.org/schema/sois/seds">
<Package name="SAMPLE_APP" shortDescription="Sample Application Package">

<DataTypeSet>

<StringDataType name="ExampleString" length="${SAMPLE_APP/STRING_VAL_LEN}" />

<ContainerDataType name="DisplayParam_Payload" shortDescription="Example Command with a payload/argument">
<EntryList>
<Entry name="ValU32" type="BASE_TYPES/uint32" shortDescription="32 bit unsigned integer value" />
<Entry name="ValI16" type="BASE_TYPES/int16" shortDescription="16 bit signed integer value" />
<Entry name="ValStr" type="ExampleString" shortDescription="An example string" />
</EntryList>
</ContainerDataType>

<ContainerDataType name="HkTlm_Payload" shortDescription="Sample App Housekeeping Content">
<EntryList>
<Entry name="CommandCounter" type="BASE_TYPES/uint8" />
<Entry name="CommandErrorCounter" type="BASE_TYPES/uint8" />
</EntryList>
</ContainerDataType>

<ContainerDataType name="SendHkCmd" baseType="CFE_HDR/CommandHeader">
</ContainerDataType>

<ContainerDataType name="CommandBase" baseType="CFE_HDR/CommandHeader">
</ContainerDataType>

<ContainerDataType name="HkTlm" baseType="CFE_HDR/TelemetryHeader">
<EntryList>
<Entry type="HkTlm_Payload" name="Payload" />
</EntryList>
</ContainerDataType>

<ContainerDataType name="NoopCmd" baseType="CommandBase">
<ConstraintSet>
<ValueConstraint entry="Sec.FunctionCode" value="0" />
</ConstraintSet>
</ContainerDataType>

<ContainerDataType name="ResetCountersCmd" baseType="CommandBase">
<ConstraintSet>
<ValueConstraint entry="Sec.FunctionCode" value="1" />
</ConstraintSet>
</ContainerDataType>

<ContainerDataType name="ProcessCmd" baseType="CommandBase">
<ConstraintSet>
<ValueConstraint entry="Sec.FunctionCode" value="2" />
</ConstraintSet>
</ContainerDataType>

<ContainerDataType name="DisplayParamCmd" baseType="CommandBase">
<ConstraintSet>
<ValueConstraint entry="Sec.FunctionCode" value="3" />
</ConstraintSet>
<EntryList>
<Entry type="DisplayParam_Payload" name="Payload" />
</EntryList>
</ContainerDataType>

<!-- Note the type name here must be "ExampleTable" to match the C table definition file,
but the source code uses the type "ExampleTable" -->
<ContainerDataType name="ExampleTable" shortDescription="Example ExampleTable structure">
<EntryList>
<Entry name="Int1" type="BASE_TYPES/uint16" />
<Entry name="Int2" type="BASE_TYPES/uint16" />
</EntryList>
</ContainerDataType>

</DataTypeSet>

<ComponentSet>
<Component name="Application">
<RequiredInterfaceSet>
<Interface name="CMD" shortDescription="Software bus telecommand interface" type="CFE_SB/Telecommand">
<GenericTypeMapSet>
<GenericTypeMap name="TelecommandDataType" type="CommandBase" />
</GenericTypeMapSet>
</Interface>
<Interface name="SEND_HK" shortDescription="Send telemetry command interface" type="CFE_SB/Telecommand">
<!-- This uses a bare spacepacket with no payload -->
<GenericTypeMapSet>
<GenericTypeMap name="TelecommandDataType" type="SendHkCmd" />
</GenericTypeMapSet>
</Interface>
<Interface name="HK_TLM" shortDescription="Software bus housekeeping telemetry interface" type="CFE_SB/Telemetry">
<GenericTypeMapSet>
<GenericTypeMap name="TelemetryDataType" type="HkTlm" />
</GenericTypeMapSet>
</Interface>
</RequiredInterfaceSet>
<Implementation>
<VariableSet>
<Variable type="BASE_TYPES/uint16" readOnly="true" name="CmdTopicId" initialValue="${CFE_MISSION/SAMPLE_APP_CMD_TOPICID}" />
<Variable type="BASE_TYPES/uint16" readOnly="true" name="SendHkTopicId" initialValue="${CFE_MISSION/SAMPLE_APP_SEND_HK_TOPICID}" />
<Variable type="BASE_TYPES/uint16" readOnly="true" name="HkTlmTopicId" initialValue="${CFE_MISSION/SAMPLE_APP_HK_TLM_TOPICID}" />
</VariableSet>
<!-- Assign fixed numbers to the "TopicId" parameter of each interface -->
<ParameterMapSet>
<ParameterMap interface="CMD" parameter="TopicId" variableRef="CmdTopicId" />
<ParameterMap interface="SEND_HK" parameter="TopicId" variableRef="SendHkTopicId" />
<ParameterMap interface="HK_TLM" parameter="TopicId" variableRef="HkTlmTopicId" />
</ParameterMapSet>
</Implementation>
</Component>
</ComponentSet>

</Package>
</PackageFile>
88 changes: 88 additions & 0 deletions fsw/src/sample_app_eds_dispatch.c
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
62 changes: 62 additions & 0 deletions unit-test/coveragetest/coveragetest_sample_app_eds_dispatch.c
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit e1b76be

Please sign in to comment.