Skip to content

Commit

Permalink
Fix #387, Update minor out-of-family naming/consistency issues in CF
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Dec 16, 2023
1 parent ecbf0c6 commit bdabfd7
Show file tree
Hide file tree
Showing 19 changed files with 505 additions and 537 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A clear and concise description of what the contribution is.
**Testing performed**
Steps taken to test the contribution:
1. Build steps '...'
1. Execution steps '...'
2. Execution steps '...'

**Expected behavior changes**
A clear and concise description of how this contribution will change behavior and level of impact.
Expand Down
4 changes: 2 additions & 2 deletions config/default_cf_msgstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ typedef struct CF_DisableEngineCmd
*
* For command details see #CF_RESET_CC
*/
typedef struct CF_ResetCmd
typedef struct CF_ResetCountersCmd
{
CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */
CF_UnionArgs_Payload_t Payload; /**< \brief Generic command arguments */
} CF_ResetCmd_t;
} CF_ResetCountersCmd_t;

/**
* \brief Freeze command structure
Expand Down
13 changes: 12 additions & 1 deletion fsw/inc/cf_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
*
* Failure from create pipe call during engine channel initialization
*/
#define CF_CR_PIPE_ERR_EID (31)
#define CF_CR_CHANNEL_PIPE_ERR_EID (31)

/**
* \brief CF Channel Message Subscription Failed Event ID
Expand Down Expand Up @@ -212,6 +212,17 @@
*/
#define CF_EID_ERR_INIT_OUTGOING_SIZE (35)

/**
* \brief CF Create SB Command Pipe at Initialization Failed Event ID
*
* \par Type: ERROR
*
* \par Cause:
*
* Failure from create command pipe call during application initialization
*/
#define CF_CR_PIPE_ERR_EID (36)

/**************************************************************************
* CF_PDU event IDs - Protocol data unit
*/
Expand Down
68 changes: 30 additions & 38 deletions fsw/src/cf_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CF_AppData_t CF_AppData;
*-----------------------------------------------------------------*/
void CF_HkCmd(void)
{
CFE_MSG_SetMsgTime(CFE_MSG_PTR(CF_AppData.hk.TelemetryHeader), CFE_TIME_GetTime());
CFE_SB_TimeStampMsg(CFE_MSG_PTR(CF_AppData.hk.TelemetryHeader));
/* return value ignored */ CFE_SB_TransmitMsg(CFE_MSG_PTR(CF_AppData.hk.TelemetryHeader), true);
}

Expand Down Expand Up @@ -82,23 +82,23 @@ void CF_CheckTables(void)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_CHECK_REL, CFE_EVS_EventType_ERROR,
"CF: error in CFE_TBL_ReleaseAddress (check), returned 0x%08lx", (unsigned long)status);
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
CF_AppData.RunStatus = CFE_ES_RunStatus_APP_ERROR;
}

status = CFE_TBL_Manage(CF_AppData.config_handle);
if (status < CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_CHECK_MAN, CFE_EVS_EventType_ERROR,
"CF: error in CFE_TBL_Manage (check), returned 0x%08lx", (unsigned long)status);
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
CF_AppData.RunStatus = CFE_ES_RunStatus_APP_ERROR;
}

status = CFE_TBL_GetAddress((void *)&CF_AppData.config_table, CF_AppData.config_handle);
if (status < CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_TBL_CHECK_GA, CFE_EVS_EventType_ERROR,
"CF: failed to get table address (check), returned 0x%08lx", (unsigned long)status);
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
CF_AppData.RunStatus = CFE_ES_RunStatus_APP_ERROR;
}
}
}
Expand Down Expand Up @@ -197,13 +197,16 @@ CFE_Status_t CF_TableInit(void)
* See description in cf_app.h for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_Status_t CF_Init(void)
CFE_Status_t CF_AppInit(void)

Check notice

Code scanning / CodeQL-coding-standard

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
CFE_Status_t status;
static const CFE_SB_MsgId_Atom_t MID_VALUES[] = {CF_CMD_MID, CF_SEND_HK_MID, CF_WAKE_UP_MID};
uint32 i;

CF_AppData.run_status = CFE_ES_RunStatus_APP_RUN;
CF_AppData.RunStatus = CFE_ES_RunStatus_APP_RUN;

/* Zero-out global data structure */
memset(&CF_AppData, 0, sizeof(CF_AppData));

CFE_MSG_Init(CFE_MSG_PTR(CF_AppData.hk.TelemetryHeader), CFE_SB_ValueToMsgId(CF_HK_TLM_MID), sizeof(CF_AppData.hk));

Expand All @@ -214,19 +217,19 @@ CFE_Status_t CF_Init(void)
}
else
{
status = CFE_SB_CreatePipe(&CF_AppData.cmd_pipe, CF_PIPE_DEPTH, CF_PIPE_NAME);
status = CFE_SB_CreatePipe(&CF_AppData.CmdPipe, CF_PIPE_DEPTH, CF_PIPE_NAME);
if (status != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("CF app: error creating pipe %s, returned 0x%08lx", CF_PIPE_NAME,
(unsigned long)status);
CFE_EVS_SendEvent(CF_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR,
"CF app: error creating pipe %s, returned 0x%08lx", CF_PIPE_NAME, (unsigned long)status);
}
}

if (status == CFE_SUCCESS)
{
for (i = 0; i < (sizeof(MID_VALUES) / sizeof(MID_VALUES[0])); ++i)
{
status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(MID_VALUES[i]), CF_AppData.cmd_pipe);
status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(MID_VALUES[i]), CF_AppData.CmdPipe);
if (status != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("CF app: failed to subscribe to MID 0x%04lx, returned 0x%08lx",
Expand All @@ -248,13 +251,8 @@ CFE_Status_t CF_Init(void)

if (status == CFE_SUCCESS)
{
status =
CFE_EVS_SendEvent(CF_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "CF Initialized. Version %d.%d.%d.%d",
CF_MAJOR_VERSION, CF_MINOR_VERSION, CF_REVISION, CF_MISSION_REV);
if (status != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("CF: error sending init event, returned 0x%08lx", (unsigned long)status);
}
CFE_EVS_SendEvent(CF_INIT_INF_EID, CFE_EVS_EventType_INFORMATION, "CF Initialized. Version %d.%d.%d.%d",
CF_MAJOR_VERSION, CF_MINOR_VERSION, CF_REVISION, CF_MISSION_REV);
}

return status;
Expand All @@ -279,16 +277,16 @@ void CF_WakeUp(void)
* See description in cf_app.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_ProcessMsg(CFE_SB_Buffer_t *msg)
void CF_ProcessMsg(CFE_SB_Buffer_t *BufPtr)

Check notice

Code scanning / CodeQL-coding-standard

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
CFE_SB_MsgId_t msg_id = CFE_SB_INVALID_MSG_ID;
CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID;

CFE_MSG_GetMsgId(&msg->Msg, &msg_id);
CFE_MSG_GetMsgId(&BufPtr->Msg, &MessageID);

switch (CFE_SB_MsgIdToValue(msg_id))
switch (CFE_SB_MsgIdToValue(MessageID))
{
case CF_CMD_MID:
CF_ProcessGroundCommand(msg);
CF_ProcessGroundCommand(BufPtr);
break;

case CF_WAKE_UP_MID:
Expand All @@ -303,7 +301,7 @@ void CF_ProcessMsg(CFE_SB_Buffer_t *msg)
default:
++CF_AppData.hk.Payload.counters.err;
CFE_EVS_SendEvent(CF_EID_ERR_INIT_CMD_LENGTH, CFE_EVS_EventType_ERROR,
"CF: invalid command packet id=0x%lx", (unsigned long)CFE_SB_MsgIdToValue(msg_id));
"CF: invalid command packet id=0x%lx", (unsigned long)CFE_SB_MsgIdToValue(MessageID));
break;
}
}
Expand All @@ -317,38 +315,32 @@ void CF_ProcessMsg(CFE_SB_Buffer_t *msg)
void CF_AppMain(void)
{
int32 status;
CFE_SB_Buffer_t *msg;
CFE_SB_Buffer_t *BufPtr = NULL;

CFE_ES_PerfLogEntry(CF_PERF_ID_APPMAIN);

status = CF_Init();
status = CF_AppInit();
if (status != CFE_SUCCESS)
{
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
CF_AppData.RunStatus = CFE_ES_RunStatus_APP_ERROR;
}

msg = NULL;

while (CFE_ES_RunLoop(&CF_AppData.run_status))
while (CFE_ES_RunLoop(&CF_AppData.RunStatus))

Check warning

Code scanning / CodeQL-coding-standard

Side effect in a Boolean expression Warning

This Boolean expression is not side-effect free.
{
CFE_ES_PerfLogExit(CF_PERF_ID_APPMAIN);

status = CFE_SB_ReceiveBuffer(&msg, CF_AppData.cmd_pipe, CF_RCVMSG_TIMEOUT);
status = CFE_SB_ReceiveBuffer(&BufPtr, CF_AppData.CmdPipe, CF_RCVMSG_TIMEOUT);
CFE_ES_PerfLogEntry(CF_PERF_ID_APPMAIN);

/*
* note that CFE_SB_ReceiveBuffer() guarantees that a CFE_SUCCESS status is accompanied by
* a valid (non-NULL) output message pointer. However the unit test can force this condition.
*/
if (status == CFE_SUCCESS && msg != NULL)
if (status == CFE_SUCCESS)
{
CF_ProcessMsg(msg);
CF_ProcessMsg(BufPtr);
}
else if (status != CFE_SB_TIME_OUT && status != CFE_SB_NO_MESSAGE)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_MSG_RECV, CFE_EVS_EventType_ERROR,
"CF: exiting due to CFE_SB_ReceiveBuffer error 0x%08lx", (unsigned long)status);
CF_AppData.run_status = CFE_ES_RunStatus_APP_ERROR;
CF_AppData.RunStatus = CFE_ES_RunStatus_APP_ERROR;
}
else
{
Expand All @@ -357,5 +349,5 @@ void CF_AppMain(void)
}

Check warning

Code scanning / CodeQL-coding-standard

Unbounded loop Warning

This loop does not have a fixed bound.

CFE_ES_PerfLogExit(CF_PERF_ID_APPMAIN);
CFE_ES_ExitApp(CF_AppData.run_status);
CFE_ES_ExitApp(CF_AppData.RunStatus);
}
12 changes: 6 additions & 6 deletions fsw/src/cf_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ typedef struct
{
CF_HkPacket_t hk;

uint32 run_status;
uint32 RunStatus;

CFE_SB_PipeId_t cmd_pipe;
CFE_SB_PipeId_t CmdPipe;

CFE_TBL_Handle_t config_handle;
CF_ConfigTable_t *config_table;
Expand Down Expand Up @@ -173,7 +173,7 @@ CFE_Status_t CF_TableInit(void);
* @retval Returns anything else on error.
*
*/
CFE_Status_t CF_Init(void);
CFE_Status_t CF_AppInit(void);

/************************************************************************/
/** @brief CF wakeup function
Expand All @@ -194,12 +194,12 @@ void CF_WakeUp(void);
* Process message packets received via the Software Bus command pipe
*
* @par Assumptions, External Events, and Notes:
* msg must not be NULL.
* BufPtr must not be NULL.
*
* @param[in] msg Software Bus message pointer
* @param[in] BufPtr Software Bus message pointer
*
*/
void CF_ProcessMsg(CFE_SB_Buffer_t *msg);
void CF_ProcessMsg(CFE_SB_Buffer_t *BufPtr);

/************************************************************************/
/** @brief CF app entry point
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ CFE_Status_t CF_CFDP_InitEngine(void)
nbuf);
if (ret != CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_CR_PIPE_ERR_EID, CFE_EVS_EventType_ERROR,
CFE_EVS_SendEvent(CF_CR_CHANNEL_PIPE_ERR_EID, CFE_EVS_EventType_ERROR,
"CF: failed to create pipe %s, returned 0x%08lx", nbuf, (unsigned long)ret);
break;
}
Expand Down
1 change: 0 additions & 1 deletion fsw/src/cf_clist.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* This file is intended to be a generic class that can be used in other apps.
*/

#include "cf_verify.h"
#include "cf_clist.h"
#include "cf_assert.h"

Expand Down
Loading

0 comments on commit bdabfd7

Please sign in to comment.