Skip to content

Commit

Permalink
Fix nasa#211, add DisplayValue command
Browse files Browse the repository at this point in the history
The display value 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.
  • Loading branch information
jphickey committed Nov 1, 2023
1 parent d18673e commit b5aea12
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 5 deletions.
1 change: 1 addition & 0 deletions config/default_sample_app_fcncodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 44 additions & 0 deletions config/default_sample_app_interface_cfg.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion config/default_sample_app_mission_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion config/default_sample_app_msgdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,19 @@
#include "common_types.h"
#include "sample_app_fcncodes.h"

typedef struct SAMPLE_APP_DisplayValue_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_DisplayValue_Payload_t;

/*************************************************************************/
/*
** Type definition (Sample App housekeeping)
*/

typedef struct
typedef struct SAMPLE_APP_HkTlm_Payload
{
uint8 CommandErrorCounter;
uint8 CommandCounter;
Expand Down
6 changes: 6 additions & 0 deletions config/default_sample_app_msgstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_DisplayValue_Payload_t Payload;
} SAMPLE_APP_DisplayParamCmd_t;

/*************************************************************************/
/*
** Type definition (Sample App housekeeping)
Expand Down
1 change: 1 addition & 0 deletions fsw/inc/sample_app_eventids.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
14 changes: 14 additions & 0 deletions fsw/src/sample_app_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions fsw/src/sample_app_cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
10 changes: 7 additions & 3 deletions fsw/src/sample_app_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -87,23 +87,27 @@ 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:
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;

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 */
Expand Down
2 changes: 2 additions & 0 deletions mission_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
16 changes: 16 additions & 0 deletions unit-test/stubs/sample_app_cmds_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b5aea12

Please sign in to comment.