Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/default_sample_app_msgdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ typedef struct SAMPLE_APP_HkTlm_Payload
{
uint8 CommandCounter;
uint8 CommandErrorCounter;
uint8 spare[2];
} SAMPLE_APP_HkTlm_Payload_t;

#endif
52 changes: 36 additions & 16 deletions fsw/src/sample_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ void SAMPLE_APP_Main(void)
}
else
{
CFE_EVS_SendEvent(SAMPLE_APP_PIPE_ERR_EID, CFE_EVS_EventType_ERROR,
CFE_EVS_SendEvent(SAMPLE_APP_PIPE_ERR_EID,
CFE_EVS_EventType_ERROR,
"SAMPLE APP: SB Pipe Read Error, App Will Exit");

SAMPLE_APP_Data.RunStatus = CFE_ES_RunStatus_APP_ERROR;
Expand Down Expand Up @@ -130,18 +131,22 @@ CFE_Status_t SAMPLE_APP_Init(void)
/*
** 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),
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_PLATFORM_PIPE_DEPTH,
status = CFE_SB_CreatePipe(&SAMPLE_APP_Data.CommandPipe,
SAMPLE_APP_PLATFORM_PIPE_DEPTH,
SAMPLE_APP_PLATFORM_PIPE_NAME);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(SAMPLE_APP_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR,
"Sample App: Error creating SB Command Pipe, RC = 0x%08lX", (unsigned long)status);
CFE_EVS_SendEvent(SAMPLE_APP_CR_PIPE_ERR_EID,
CFE_EVS_EventType_ERROR,
"Sample App: Error creating SB Command Pipe, RC = 0x%08lX",
(unsigned long)status);
}
}

Expand All @@ -153,8 +158,10 @@ CFE_Status_t SAMPLE_APP_Init(void)
status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(SAMPLE_APP_SEND_HK_MID), SAMPLE_APP_Data.CommandPipe);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(SAMPLE_APP_SUB_HK_ERR_EID, CFE_EVS_EventType_ERROR,
"Sample App: Error Subscribing to HK request, RC = 0x%08lX", (unsigned long)status);
CFE_EVS_SendEvent(SAMPLE_APP_SUB_HK_ERR_EID,
CFE_EVS_EventType_ERROR,
"Sample App: Error Subscribing to HK request, RC = 0x%08lX",
(unsigned long)status);
}
}

Expand All @@ -166,8 +173,10 @@ CFE_Status_t SAMPLE_APP_Init(void)
status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(SAMPLE_APP_CMD_MID), SAMPLE_APP_Data.CommandPipe);
if (status != CFE_SUCCESS)
{
CFE_EVS_SendEvent(SAMPLE_APP_SUB_CMD_ERR_EID, CFE_EVS_EventType_ERROR,
"Sample App: Error Subscribing to Commands, RC = 0x%08lX", (unsigned long)status);
CFE_EVS_SendEvent(SAMPLE_APP_SUB_CMD_ERR_EID,
CFE_EVS_EventType_ERROR,
"Sample App: Error Subscribing to Commands, RC = 0x%08lX",
(unsigned long)status);
}
}

Expand All @@ -176,22 +185,33 @@ CFE_Status_t SAMPLE_APP_Init(void)
/*
** Register Example Table(s)
*/
status = CFE_TBL_Register(&SAMPLE_APP_Data.TblHandles[0], "ExampleTable", sizeof(SAMPLE_APP_ExampleTable_t),
CFE_TBL_OPT_DEFAULT, SAMPLE_APP_TblValidationFunc);
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_EVS_SendEvent(SAMPLE_APP_TABLE_REG_ERR_EID, CFE_EVS_EventType_ERROR,
"Sample App: Error Registering Example Table, RC = 0x%08lX", (unsigned long)status);
CFE_EVS_SendEvent(SAMPLE_APP_TABLE_REG_ERR_EID,
CFE_EVS_EventType_ERROR,
"Sample App: Error Registering Example Table, RC = 0x%08lX",
(unsigned long)status);
}
else
{
status = CFE_TBL_Load(SAMPLE_APP_Data.TblHandles[0], CFE_TBL_SRC_FILE, SAMPLE_APP_PLATFORM_TABLE_FILE);
}

CFE_Config_GetVersionString(VersionString, SAMPLE_APP_CFG_MAX_VERSION_STR_LEN, "Sample App", SAMPLE_APP_VERSION,
SAMPLE_APP_BUILD_CODENAME, SAMPLE_APP_LAST_OFFICIAL);
CFE_Config_GetVersionString(VersionString,
SAMPLE_APP_CFG_MAX_VERSION_STR_LEN,
"Sample App",
SAMPLE_APP_VERSION,
SAMPLE_APP_BUILD_CODENAME,
SAMPLE_APP_LAST_OFFICIAL);

CFE_EVS_SendEvent(SAMPLE_APP_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "Sample App Initialized.%s",
CFE_EVS_SendEvent(SAMPLE_APP_INIT_INF_EID,
CFE_EVS_EventType_INFORMATION,
"Sample App Initialized.%s",
VersionString);
}

Expand Down
4 changes: 2 additions & 2 deletions fsw/src/sample_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ typedef struct
/*
** Command interface counters...
*/
uint8 CmdCounter;
uint8 ErrCounter;
uint8 CommandCounter;
uint8 CommandErrorCounter;

/*
** Housekeeping telemetry packet...
Expand Down
31 changes: 18 additions & 13 deletions fsw/src/sample_app_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ CFE_Status_t SAMPLE_APP_SendHkCmd(const SAMPLE_APP_SendHkCmd_t *Msg)
/*
** Get command execution counters...
*/
SAMPLE_APP_Data.HkTlm.Payload.CommandErrorCounter = SAMPLE_APP_Data.ErrCounter;
SAMPLE_APP_Data.HkTlm.Payload.CommandCounter = SAMPLE_APP_Data.CmdCounter;
SAMPLE_APP_Data.HkTlm.Payload.CommandErrorCounter = SAMPLE_APP_Data.CommandErrorCounter;
SAMPLE_APP_Data.HkTlm.Payload.CommandCounter = SAMPLE_APP_Data.CommandCounter;

/*
** Send housekeeping telemetry packet...
Expand All @@ -78,9 +78,11 @@ CFE_Status_t SAMPLE_APP_SendHkCmd(const SAMPLE_APP_SendHkCmd_t *Msg)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
CFE_Status_t SAMPLE_APP_NoopCmd(const SAMPLE_APP_NoopCmd_t *Msg)
{
SAMPLE_APP_Data.CmdCounter++;
SAMPLE_APP_Data.CommandCounter++;

CFE_EVS_SendEvent(SAMPLE_APP_NOOP_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;
Expand All @@ -95,8 +97,8 @@ CFE_Status_t SAMPLE_APP_NoopCmd(const SAMPLE_APP_NoopCmd_t *Msg)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
CFE_Status_t SAMPLE_APP_ResetCountersCmd(const SAMPLE_APP_ResetCountersCmd_t *Msg)
{
SAMPLE_APP_Data.CmdCounter = 0;
SAMPLE_APP_Data.ErrCounter = 0;
SAMPLE_APP_Data.CommandCounter = 0;
SAMPLE_APP_Data.CommandErrorCounter = 0;

CFE_EVS_SendEvent(SAMPLE_APP_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "SAMPLE: RESET command");

Expand All @@ -112,12 +114,12 @@ CFE_Status_t SAMPLE_APP_ResetCountersCmd(const SAMPLE_APP_ResetCountersCmd_t *Ms
CFE_Status_t SAMPLE_APP_ProcessCmd(const SAMPLE_APP_ProcessCmd_t *Msg)
{
CFE_Status_t Status;
void * TblAddr;
void *TblAddr;
SAMPLE_APP_ExampleTable_t *TblPtr;
const char * TableName = "SAMPLE_APP.ExampleTable";
const char *TableName = "SAMPLE_APP.ExampleTable";

/* Sample Use of Example Table */
SAMPLE_APP_Data.CmdCounter++;
SAMPLE_APP_Data.CommandCounter++;
Status = CFE_TBL_GetAddress(&TblAddr, SAMPLE_APP_Data.TblHandles[0]);
if (Status < CFE_SUCCESS)
{
Expand Down Expand Up @@ -152,10 +154,13 @@ CFE_Status_t SAMPLE_APP_ProcessCmd(const SAMPLE_APP_ProcessCmd_t *Msg)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
CFE_Status_t SAMPLE_APP_DisplayParamCmd(const SAMPLE_APP_DisplayParamCmd_t *Msg)
{
SAMPLE_APP_Data.CmdCounter++;
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);
SAMPLE_APP_Data.CommandCounter++;
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;
}
2 changes: 1 addition & 1 deletion fsw/src/sample_app_cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#include "sample_app_msg.h"

CFE_Status_t SAMPLE_APP_SendHkCmd(const SAMPLE_APP_SendHkCmd_t *Msg);
CFE_Status_t SAMPLE_APP_NoopCmd(const SAMPLE_APP_NoopCmd_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 */
18 changes: 12 additions & 6 deletions fsw/src/sample_app_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,17 @@ bool SAMPLE_APP_VerifyCmdLength(const CFE_MSG_Message_t *MsgPtr, size_t Expected
CFE_MSG_GetMsgId(MsgPtr, &MsgId);
CFE_MSG_GetFcnCode(MsgPtr, &FcnCode);

CFE_EVS_SendEvent(SAMPLE_APP_CMD_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)CFE_SB_MsgIdToValue(MsgId),
(unsigned int)FcnCode,
(unsigned int)ActualLength,
(unsigned int)ExpectedLength);

result = false;

SAMPLE_APP_Data.ErrCounter++;
SAMPLE_APP_Data.CommandErrorCounter++;
}

return result;
Expand Down Expand Up @@ -110,9 +113,10 @@ void SAMPLE_APP_ProcessGroundCommand(const CFE_SB_Buffer_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",
CFE_EVS_SendEvent(SAMPLE_APP_CC_ERR_EID,
CFE_EVS_EventType_ERROR,
"Invalid ground command code: CC = %d",
CommandCode);
break;
}
Expand Down Expand Up @@ -155,7 +159,9 @@ void SAMPLE_APP_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr)
else
{
/* Unknown command */
CFE_EVS_SendEvent(SAMPLE_APP_MID_ERR_EID, CFE_EVS_EventType_ERROR, "SAMPLE: invalid command packet,MID = 0x%x",
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));
}
}
4 changes: 2 additions & 2 deletions fsw/src/sample_app_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#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);
void SAMPLE_APP_ProcessGroundCommand(const CFE_SB_Buffer_t *SBBufPtr);
void SAMPLE_APP_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr);

#endif /* SAMPLE_APP_DISPATCH_H */
23 changes: 15 additions & 8 deletions fsw/src/sample_app_eds_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* Define a lookup table for SAMPLE app command codes
*/
/* clang-format off */
static const EdsDispatchTable_EdsComponent_SAMPLE_APP_Application_CFE_SB_Telecommand_t SAMPLE_TC_DISPATCH_TABLE =
static const EdsDispatchTable_EdsComponent_SAMPLE_APP_Application_CFE_SB_Telecommand_t SAMPLE_TC_DISPATCH_TABLE =
{
.CMD =
{
Expand Down Expand Up @@ -75,23 +75,30 @@ void SAMPLE_APP_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr)
CFE_MSG_GetMsgId(&SBBufPtr->Msg, &MsgId);
CFE_MSG_GetSize(&SBBufPtr->Msg, &MsgSize);
CFE_MSG_GetFcnCode(&SBBufPtr->Msg, &MsgFc);
++SAMPLE_APP_Data.ErrCounter;
++SAMPLE_APP_Data.CommandErrorCounter;

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));
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,
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);
(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);
CFE_EVS_SendEvent(SAMPLE_APP_CC_ERR_EID,
CFE_EVS_EventType_ERROR,
"SAMPLE: Invalid ground command code: CC = %d",
(int)MsgFc);
}
}
}
17 changes: 9 additions & 8 deletions fsw/src/sample_app_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@

/* Development Build Macro Definitions */

#define SAMPLE_APP_BUILD_NUMBER 0
#define SAMPLE_APP_BUILD_BASELINE "v7.0.0" /*!< Development Build: git tag that is the base for the current development */
#define SAMPLE_APP_BUILD_NUMBER 0
#define SAMPLE_APP_BUILD_BASELINE \
"v7.0.0" /*!< Development Build: git tag that is the base for the current development */
#define SAMPLE_APP_BUILD_DEV_CYCLE "v7.0.0" /**< @brief Development: Release name for current development cycle */
#define SAMPLE_APP_BUILD_CODENAME "Draco" /**< @brief: Development: Code name for the current build */
#define SAMPLE_APP_BUILD_CODENAME "Draco" /**< @brief: Development: Code name for the current build */

/*
* Version Macros, see \ref cfsversions for definitions.
*/
#define SAMPLE_APP_MAJOR_VERSION 7 /*!< @brief Major version number. */
#define SAMPLE_APP_MINOR_VERSION 0 /*!< @brief Minor version number. */
#define SAMPLE_APP_REVISION 0 /*!< @brief Revision version number. Value of 0 indicates a development version.*/
#define SAMPLE_APP_MAJOR_VERSION 7 /*!< @brief Major version number. */
#define SAMPLE_APP_MINOR_VERSION 0 /*!< @brief Minor version number. */
#define SAMPLE_APP_REVISION 0 /*!< @brief Revision version number. Value of 0 indicates a development version.*/

/**
* @brief Last official release.
Expand Down Expand Up @@ -65,9 +66,9 @@

/**
* @brief Max Version String length.
*
*
* Maximum length that an OSAL version string can be.
*
*
*/
#define SAMPLE_APP_CFG_MAX_VERSION_STR_LEN 256

Expand Down
2 changes: 1 addition & 1 deletion fsw/tables/sample_app_tbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
** The following is an example of the declaration statement that defines the desired
** contents of the table image.
*/
SAMPLE_APP_ExampleTable_t ExampleTable = {1, 2};
SAMPLE_APP_ExampleTable_t ExampleTable = { 1, 2 };

/*
** The macro below identifies:
Expand Down
12 changes: 7 additions & 5 deletions unit-test/common/eventcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
/*
* 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)
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;
const char *Spec;

/*
* The CFE_EVS_SendEvent stub passes the EventID as the
Expand Down Expand Up @@ -110,8 +110,10 @@ static int32 UT_CheckEvent_Hook(void *UserObj, int32 StubRetcode, uint32 CallCou
* 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)
void UT_CheckEvent_Setup_Impl(UT_CheckEvent_t *Evt,
uint16 ExpectedEvent,
const char *EventName,
const char *ExpectedFormat)
{
if (ExpectedFormat == NULL)
{
Expand Down
6 changes: 4 additions & 2 deletions unit-test/common/eventcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ typedef struct
* 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);
void UT_CheckEvent_Setup_Impl(UT_CheckEvent_t *Evt,
uint16 ExpectedEvent,
const char *EventName,
const char *ExpectedFormat);

#endif
Loading
Loading