Skip to content

Commit

Permalink
Merge branches 'fix-110-149-more-renames', 'fix-32-cf-assert-debug-on…
Browse files Browse the repository at this point in the history
…ly', 'fix-129-check-fd-pdu-flags' and 'fix-148-msgid-type' into jph-wip-baseline-20220106
  • Loading branch information
jphickey committed Jan 6, 2022
5 parents b6de205 + 5855cf0 + 743aaf3 + 0f2f11c + c43981b commit 86fcd5b
Show file tree
Hide file tree
Showing 27 changed files with 442 additions and 663 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ include_directories(${CFS_IO_LIB_MISSION_DIR}/fsw/public_inc)

set(APP_SRC_FILES
fsw/src/cf_app.c
fsw/src/cf_assert.c
fsw/src/cf_cfdp.c
fsw/src/cf_cfdp_r.c
fsw/src/cf_cfdp_s.c
Expand Down
4 changes: 2 additions & 2 deletions fsw/platform_inc/cf_tbldefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ typedef struct CF_ChannelConfig
uint32 max_outgoing_messages_per_wakeup; /* max number of messages to send per wakeup (0 - unlimited) */
uint32 rx_max_messages_per_wakeup; /* max number of rx messages to process per wakeup */

uint16 apid_input; /* apid for incoming messages */
uint16 apid_output; /* apid for outgoing messages */
CFE_SB_MsgId_Atom_t mid_input; /* msgid integer value for incoming messages */
CFE_SB_MsgId_Atom_t mid_output; /* msgid integer value for outgoing messages */

uint16 pipe_depth_input; /* depth of pipe to receive incoming pdu */

Expand Down
26 changes: 12 additions & 14 deletions fsw/src/cf_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,14 @@ int32 CF_Init(void)
{CF_EID_ERR_CMD_WHIST_WRITE, 0x0000},
};

int32 status = CFE_SUCCESS;
int32 status = CFE_SUCCESS;
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;

CFE_MSG_Init(&CF_AppData.hk.tlm_header.Msg, CF_HK_TLM_MID, sizeof(CF_AppData.hk));
CFE_MSG_Init(&CF_AppData.cfg.tlm_header.Msg, CF_CONFIG_TLM_MID, sizeof(CF_AppData.cfg));
CFE_MSG_Init(&CF_AppData.hk.tlm_header.Msg, CFE_SB_ValueToMsgId(CF_HK_TLM_MID), sizeof(CF_AppData.hk));
CFE_MSG_Init(&CF_AppData.cfg.tlm_header.Msg, CFE_SB_ValueToMsgId(CF_CONFIG_TLM_MID), sizeof(CF_AppData.cfg));

if ((status = CFE_EVS_Register(cf_event_filters, sizeof(cf_event_filters) / sizeof(*cf_event_filters),
CFE_EVS_EventFilter_BINARY)) != CFE_SUCCESS)
Expand All @@ -362,17 +364,13 @@ int32 CF_Init(void)
goto err_out;
}

for (i = 0; i < (sizeof(MID_VALUES) / sizeof(MID_VALUES[0])); ++i)
{
const CFE_SB_MsgId_t mids[] = {CF_CMD_MID, CF_SEND_HK_MID, CF_WAKE_UP_MID};
int i;

for (i = 0; i < (sizeof(mids) / sizeof(*mids)); ++i)
if ((status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(MID_VALUES[i]), CF_AppData.cmd_pipe)) != CFE_SUCCESS)
{
if ((status = CFE_SB_Subscribe(mids[i], CF_AppData.cmd_pipe)) != CFE_SUCCESS)
{
CFE_ES_WriteToSysLog("CF app: failed to subscribe to MID 0x%04x, returned 0x%08x", mids[i], status);
goto err_out;
}
CFE_ES_WriteToSysLog("CF app: failed to subscribe to MID 0x%04lx, returned 0x%08lx",
(unsigned long)MID_VALUES[i], (unsigned long)status);
goto err_out;
}
}

Expand Down Expand Up @@ -435,7 +433,7 @@ void CF_ProcessMsg(CFE_SB_Buffer_t *msg)

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

switch (msg_id)
switch (CFE_SB_MsgIdToValue(msg_id))
{
case CF_CMD_MID:
CF_ProcessGroundCommand(msg);
Expand All @@ -453,7 +451,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%02x", msg_id);
"CF: invalid command packet id=0x%lx", (unsigned long)CFE_SB_MsgIdToValue(msg_id));
break;
}
}
Expand Down
35 changes: 0 additions & 35 deletions fsw/src/cf_assert.c

This file was deleted.

42 changes: 24 additions & 18 deletions fsw/src/cf_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,33 @@

#include "cfe.h"

extern void CF_HandleAssert(const char *file, int line);

/*
* Note that in some cases, code in CF may compute or store a value for the
* sole purpose of checking it with a CF_Assert(). If CF_Assert is then entirely
* compiled out with NDEBUG, the compiler may see that as an unused value and
* trigger a warning.
*
* To avoid this, a no-op inline function is used, such that the value in the
* CF_Assert call is still evaluated, but the result is ignored.
* CF_Assert statements within the code are primarily informational for developers,
* as the conditions within them should always be true. Barring any unforeseen
* bugs in the code, they should never get triggered. However, if the code is
* modified, these conditions could happen, so it is still worthwhile to keep
* these statements in the source code, so they can be enabled if necessary.
*/

#ifdef NDEBUG
/* this is release mode */
static inline void CF_NoAssert(bool cond)
{
/* no-op to avoid unused value warning */
}
#define CF_Assert(x) CF_NoAssert(x)
#else /* NDEBUG */
#ifdef CF_DEBUG_BUILD

/*
* Debug build:
* Translate CF_Assert to the system assert. Note that asserts may still get disabled
* if building with NDEBUG flag set, even if CF_DEBUG_BUILD flag is enabled.
*/
#include <assert.h>
#define CF_Assert(x) assert(x)
#endif /* !NDEBUG */

#else /* CF_DEBUG_BUILD */

/*
* Normal build:
* It should be impossible to get any conditions which are asserted, so it should
* be safe to turn these off. This is the configuration that the code should be
* normally tested and verified in.
*/
#define CF_Assert(x) /* no-op */

#endif /* CF_DEBUG_BUILD */
#endif /* !CF_ASSERT__H */
51 changes: 30 additions & 21 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,14 @@ int CF_CFDP_RecvFd(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph)
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.error;
ret = -1;
}
else if (ph->pdu_header.segment_meta_flag)
{
/* If recv PDU has the "segment_meta_flag" set, this is not currently handled in CF. */
CFE_EVS_SendEvent(CF_EID_ERR_PDU_FD_UNSUPPORTED, CFE_EVS_EventType_ERROR,
"CF: filedata pdu with segment metadata received");
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.error;
ret = -1;
}

return ret;
}
Expand Down Expand Up @@ -1107,13 +1115,13 @@ int32 CF_CFDP_InitEngine(void)
goto err_out;
}

if ((ret =
CFE_SB_SubscribeLocal(CF_AppData.config_table->chan[i].apid_input, CF_AppData.engine.channels[i].pipe,
CF_AppData.config_table->chan[i].pipe_depth_input)) != CFE_SUCCESS)
if ((ret = CFE_SB_SubscribeLocal(CFE_SB_ValueToMsgId(CF_AppData.config_table->chan[i].mid_input),
CF_AppData.engine.channels[i].pipe,
CF_AppData.config_table->chan[i].pipe_depth_input)) != CFE_SUCCESS)
{
CFE_EVS_SendEvent(CF_EID_ERR_INIT_SUB, CFE_EVS_EventType_ERROR,
"CF: failed to subscribe to MID 0x%04x, returned 0x%08x",
CF_AppData.config_table->chan[i].apid_input, ret);
CF_AppData.config_table->chan[i].mid_input, ret);
goto err_out;
}

Expand Down Expand Up @@ -1178,7 +1186,7 @@ int32 CF_CFDP_InitEngine(void)
** \endreturns
**
*************************************************************************/
int CF_CFDP_CycleTx_(CF_CListNode_t *node, void *context)
int CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context)
{
CF_CFDP_CycleTx_args_t *args = (CF_CFDP_CycleTx_args_t *)context;
CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node);
Expand Down Expand Up @@ -1246,7 +1254,7 @@ void CF_CFDP_CycleTx(CF_Channel_t *c)
CF_MoveTransaction(t, CF_QueueIdx_TXA);
/* args is ok, still { c, 0 } */
entry_jump:
CF_CList_Traverse(c->qs[CF_QueueIdx_TXA], CF_CFDP_CycleTx_, &args);
CF_CList_Traverse(c->qs[CF_QueueIdx_TXA], CF_CFDP_CycleTxFirstActive, &args);
}
}

Expand All @@ -1269,9 +1277,9 @@ void CF_CFDP_CycleTx(CF_Channel_t *c)
*************************************************************************/
int CF_CFDP_DoTick(CF_CListNode_t *node, void *context)
{
int ret = CF_CLIST_CONT; /* CF_CLIST_CONT means don't tick one, keep looking for cur */
tick_args_t *args = (tick_args_t *)context;
CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node);
int ret = CF_CLIST_CONT; /* CF_CLIST_CONT means don't tick one, keep looking for cur */
CF_CFDP_Tick_args_t *args = (CF_CFDP_Tick_args_t *)context;
CF_Transaction_t *t = container_of(node, CF_Transaction_t, cl_node);
if (!args->c->cur || (args->c->cur == t))
{
/* found where we left off, so clear that and move on */
Expand Down Expand Up @@ -1321,7 +1329,7 @@ void CF_CFDP_TickTransactions(CF_Channel_t *c)

for (; c->tick_type < CF_TickType_NUM_TYPES; ++c->tick_type)
{
tick_args_t args = {c, fns[c->tick_type], 0, 0};
CF_CFDP_Tick_args_t args = {c, fns[c->tick_type], 0, 0};

do
{
Expand Down Expand Up @@ -1384,8 +1392,8 @@ void CF_CFDP_InitTxnTxFile(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_class, uint
** t must not be NULL.
**
*************************************************************************/
static void CF_CFDP_TxFile_(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority,
CF_EntityId_t dest_id)
static void CF_CFDP_TxFile_Initiate(CF_Transaction_t *t, CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan,
uint8 priority, CF_EntityId_t dest_id)
{
CFE_EVS_SendEvent(CF_EID_INF_CFDP_S_START_SEND, CFE_EVS_EventType_INFORMATION,
"CF: start class %d tx of file %d:%.*s -> %d:%.*s", cfdp_class + 1,
Expand Down Expand Up @@ -1448,7 +1456,7 @@ int32 CF_CFDP_TxFile(const char *src_filename, const char *dst_filename, CF_CFDP
t->history->fnames.src_filename[sizeof(t->history->fnames.src_filename) - 1] = 0;
strncpy(t->history->fnames.dst_filename, dst_filename, sizeof(t->history->fnames.dst_filename) - 1);
t->history->fnames.dst_filename[sizeof(t->history->fnames.dst_filename) - 1] = 0;
CF_CFDP_TxFile_(t, cfdp_class, keep, chan, priority, dest_id);
CF_CFDP_TxFile_Initiate(t, cfdp_class, keep, chan, priority, dest_id);

++c->num_cmd_tx;
t->flags.tx.cmd_tx = 1;
Expand All @@ -1472,9 +1480,9 @@ int32 CF_CFDP_TxFile(const char *src_filename, const char *dst_filename, CF_CFDP
** \endreturns
**
*************************************************************************/
static int32 CF_CFDP_PlaybackDir_(CF_Playback_t *p, const char *src_filename, const char *dst_filename,
CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority,
CF_EntityId_t dest_id)
static int32 CF_CFDP_PlaybackDir_Initiate(CF_Playback_t *p, const char *src_filename, const char *dst_filename,
CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority,
CF_EntityId_t dest_id)
{
int32 ret = CFE_SUCCESS;

Expand Down Expand Up @@ -1544,7 +1552,7 @@ int32 CF_CFDP_PlaybackDir(const char *src_filename, const char *dst_filename, CF
return -1;
}

return CF_CFDP_PlaybackDir_(p, src_filename, dst_filename, cfdp_class, keep, chan, priority, dest_id);
return CF_CFDP_PlaybackDir_Initiate(p, src_filename, dst_filename, cfdp_class, keep, chan, priority, dest_id);
}

/************************************************************************/
Expand Down Expand Up @@ -1598,7 +1606,8 @@ void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *c, CF_Playback_t *p)
pt->history->fnames.src_filename[CF_FILENAME_MAX_LEN - 1] = 0;
pt->history->fnames.dst_filename[CF_FILENAME_MAX_LEN - 1] = 0;

CF_CFDP_TxFile_(pt, p->cfdp_class, p->keep, (c - CF_AppData.engine.channels), p->priority, p->dest_id);
CF_CFDP_TxFile_Initiate(pt, p->cfdp_class, p->keep, (c - CF_AppData.engine.channels), p->priority,
p->dest_id);

pt->p = p;
++p->num_ts;
Expand Down Expand Up @@ -1707,16 +1716,16 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c)
else if (CF_Timer_Expired(&p->interval_timer))
{
/* the timer has expired */
int ret = CF_CFDP_PlaybackDir_(&p->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0, chan_index,
pd->priority, pd->dest_eid);
int ret = CF_CFDP_PlaybackDir_Initiate(&p->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0,
chan_index, pd->priority, pd->dest_eid);
if (!ret)
{
p->timer_set = 0;
}
else
{
/* error occured in playback directory, so reset the timer */
/* an event is sent in CF_CFDP_PlaybackDir_ so there is no reason to
/* an event is sent in CF_CFDP_PlaybackDir_Initiate so there is no reason to
* to have another here */
CF_Timer_InitRelSec(&p->interval_timer, pd->interval_sec);
}
Expand Down
8 changes: 4 additions & 4 deletions fsw/src/cf_cfdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@

#include "cf_cfdp_types.h"

typedef struct CF_CFDP_CycleTx_args_t
typedef struct CF_CFDP_CycleTx_args
{
CF_Channel_t *c;
int ran_one;
} CF_CFDP_CycleTx_args_t;

typedef struct
typedef struct CF_CFDP_Tick_args
{
CF_Channel_t *c; /* IN param */
void (*fn)(CF_Transaction_t *, int *); /* IN param */
int early_exit; /* OUT param */
int cont; /* if 1, then re-traverse the list */
} tick_args_t;
} CF_CFDP_Tick_args_t;

void CF_CFDP_EncodeStart(CF_EncoderState_t *penc, void *msgbuf, CF_Logical_PduBuffer_t *ph, size_t encap_hdr_size,
size_t total_size);
Expand Down Expand Up @@ -110,7 +110,7 @@ void CF_CFDP_RecvIdle(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph);
int CF_CFDP_CloseFiles(CF_CListNode_t *n, void *context);

void CF_CFDP_CycleTx(CF_Channel_t *c);
int CF_CFDP_CycleTx_(CF_CListNode_t *node, void *context);
int CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context);
void CF_CFDP_TickTransactions(CF_Channel_t *c);
void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *c, CF_Playback_t *p);
void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c);
Expand Down
3 changes: 2 additions & 1 deletion fsw/src/cf_cfdp_sbintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *t, bool silent
goto error_out;
}

CFE_MSG_Init(&CF_AppData.engine.out.msg->Msg, CF_AppData.config_table->chan[t->chan_num].apid_output, 0);
CFE_MSG_Init(&CF_AppData.engine.out.msg->Msg,
CFE_SB_ValueToMsgId(CF_AppData.config_table->chan[t->chan_num].mid_output), 0);
++CF_AppData.engine.outgoing_counter; /* even if max_outgoing_messages_per_wakeup is 0 (unlimited), it's ok
to inc this */

Expand Down
Loading

0 comments on commit 86fcd5b

Please sign in to comment.