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 3, 2023
1 parent 08a2e0c commit 69277a8
Show file tree
Hide file tree
Showing 13 changed files with 765 additions and 793 deletions.
2 changes: 1 addition & 1 deletion docs/dox_src/cfs_cf.dox
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@

cf_platform_cfg.h uses macro definitions for configurable options, while cf_def_config.c
uses a table. cf_def_config.c parameters can be accessed using the get/set functions
CF_CmdGetParam() and CF_CmdSetParam().
CF_GetParamCmd() and CF_SetParamCmd().

CF expects to receive a CF_WAKEUP_MID message from the SCH (scheduler) app at a fixed
rate. The number of wakeups per second is reflected in the configuration table. This
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
28 changes: 14 additions & 14 deletions fsw/inc/cf_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ typedef struct CF_HkChannel_Data
*/
typedef struct CF_HkPacket
{
CFE_MSG_TelemetryHeader_t tlm_header; /**< \brief Telemetry header */
CF_HkCmdCounters_t counters; /**< \brief Command counters */
uint8 spare[4]; /**< \brief Alignment spare (CF_HkCmdCounters_t is 4 bytes) */
CFE_MSG_TelemetryHeader_t TelemetryHeader; /**< \brief Telemetry header */
CF_HkCmdCounters_t counters; /**< \brief Command counters */
uint8 spare[4]; /**< \brief Alignment spare (CF_HkCmdCounters_t is 4 bytes) */

CF_HkChannel_Data_t channel_hk[CF_NUM_CHANNELS]; /**< \brief Per channel housekeeping data */
} CF_HkPacket_t;
Expand All @@ -134,17 +134,17 @@ typedef struct CF_HkPacket
*/
typedef struct CF_EotPacket
{
CFE_MSG_TelemetryHeader_t tlm_header; /**< \brief Telemetry header */
CF_TransactionSeq_t seq_num; /**< \brief transaction identifier, stays constant for entire transfer */
uint32 channel; /**< \brief Channel number */
uint32 direction; /**< \brief direction of this transaction */
uint32 state; /**< \brief Transaction state */
uint32 txn_stat; /**< \brief final status code of transaction (extended CFDP CC) */
CF_EntityId_t src_eid; /**< \brief the source eid of the transaction */
CF_EntityId_t peer_eid; /**< \brief peer_eid is always the "other guy", same src_eid for RX */
uint32 fsize; /**< \brief File size */
uint32 crc_result; /**< \brief CRC result */
CF_TxnFilenames_t fnames; /**< \brief file names associated with this transaction */
CFE_MSG_TelemetryHeader_t TelemetryHeader; /**< \brief Telemetry header */
CF_TransactionSeq_t seq_num; /**< \brief transaction identifier, stays constant for entire transfer */
uint32 channel; /**< \brief Channel number */
uint32 direction; /**< \brief direction of this transaction */
uint32 state; /**< \brief Transaction state */
uint32 txn_stat; /**< \brief final status code of transaction (extended CFDP CC) */
CF_EntityId_t src_eid; /**< \brief the source eid of the transaction */
CF_EntityId_t peer_eid; /**< \brief peer_eid is always the "other guy", same src_eid for RX */
uint32 fsize; /**< \brief File size */
uint32 crc_result; /**< \brief CRC result */
CF_TxnFilenames_t fnames; /**< \brief file names associated with this transaction */
} CF_EotPacket_t;

/**
Expand Down
72 changes: 32 additions & 40 deletions fsw/src/cf_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ CF_AppData_t CF_AppData;
*-----------------------------------------------------------------*/
void CF_HkCmd(void)
{
CFE_MSG_SetMsgTime(&CF_AppData.hk.tlm_header.Msg, CFE_TIME_GetTime());
/* return value ignored */ CFE_SB_TransmitMsg(&CF_AppData.hk.tlm_header.Msg, true);
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,15 +197,18 @@ 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;
/* Zero-out global data structure */
memset(&CF_AppData, 0, sizeof(CF_AppData));

CFE_MSG_Init(&CF_AppData.hk.tlm_header.Msg, CFE_SB_ValueToMsgId(CF_HK_TLM_MID), sizeof(CF_AppData.hk));
CF_AppData.RunStatus = CFE_ES_RunStatus_APP_RUN;

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

status = CFE_EVS_Register(NULL, 0, CFE_EVS_EventFilter_BINARY);
if (status != CFE_SUCCESS)
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.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 @@ -79,9 +79,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 @@ -172,7 +172,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 @@ -193,12 +193,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
12 changes: 6 additions & 6 deletions 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 Expand Up @@ -1610,10 +1610,10 @@ void CF_CFDP_ResetTransaction(CF_Transaction_t *txn, int keep_history)
CF_Channel_t *chan = &CF_AppData.engine.channels[txn->chan_num];
CF_Assert(txn->chan_num < CF_NUM_CHANNELS);

if ( txn->flags.com.q_index == CF_QueueIdx_FREE)
if (txn->flags.com.q_index == CF_QueueIdx_FREE)
{
CFE_EVS_SendEvent(CF_EID_DBG_RESET_FREED_XACT, CFE_EVS_EventType_DEBUG, \
"CF: attempt to reset a transaction that has already been freed");
CFE_EVS_SendEvent(CF_EID_DBG_RESET_FREED_XACT, CFE_EVS_EventType_DEBUG,
"CF: attempt to reset a transaction that has already been freed");
return;
}

Expand Down Expand Up @@ -1720,7 +1720,7 @@ void CF_CFDP_SendEotPkt(CF_Transaction_t *txn)

if (PktBuf != NULL)
{
CFE_MSG_Init(&PktBuf->eot.tlm_header.Msg, CFE_SB_ValueToMsgId(CF_EOT_TLM_MID), sizeof(PktBuf->eot));
CFE_MSG_Init(&PktBuf->eot.TelemetryHeader.Msg, CFE_SB_ValueToMsgId(CF_EOT_TLM_MID), sizeof(PktBuf->eot));

PktBuf->eot.channel = txn->chan_num;
PktBuf->eot.direction = txn->history->dir;
Expand All @@ -1736,7 +1736,7 @@ void CF_CFDP_SendEotPkt(CF_Transaction_t *txn)
/*
** Timestamp and send eod of transaction telemetry
*/
CFE_SB_TimeStampMsg(&PktBuf->eot.tlm_header.Msg);
CFE_SB_TimeStampMsg(&PktBuf->eot.TelemetryHeader.Msg);
CFE_SB_TransmitBuffer(&PktBuf->SBBuf, true);
}
}
Expand Down
Loading

0 comments on commit 69277a8

Please sign in to comment.