Skip to content

Commit

Permalink
Fix #265, Updates from review of variable name changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jphickey committed Sep 29, 2023
1 parent c2725b1 commit 157e04a
Show file tree
Hide file tree
Showing 26 changed files with 230 additions and 209 deletions.
41 changes: 21 additions & 20 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ CFE_Status_t CF_CFDP_SendMd(CF_Transaction_t *txn)
md->source_filename.length =
CF_strnlen(txn->history->fnames.src_filename, sizeof(txn->history->fnames.src_filename));
md->source_filename.data_ptr = txn->history->fnames.src_filename;
md->dest_filename.length = CF_strnlen(txn->history->fnames.dst_filename, sizeof(txn->history->fnames.dst_filename));
md->dest_filename.length =
CF_strnlen(txn->history->fnames.dst_filename, sizeof(txn->history->fnames.dst_filename));
md->dest_filename.data_ptr = txn->history->fnames.dst_filename;

CF_CFDP_EncodeMd(ph->penc, md);
Expand Down Expand Up @@ -683,8 +684,8 @@ CFE_Status_t CF_CFDP_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph)
}
else
{
lv_ret = CF_CFDP_CopyStringFromLV(txn->history->fnames.dst_filename, sizeof(txn->history->fnames.dst_filename),
&md->dest_filename);
lv_ret = CF_CFDP_CopyStringFromLV(txn->history->fnames.dst_filename,
sizeof(txn->history->fnames.dst_filename), &md->dest_filename);
if (lv_ret < 0)
{
CFE_EVS_SendEvent(CF_EID_ERR_PDU_INVALID_DST_LEN, CFE_EVS_EventType_ERROR,
Expand Down Expand Up @@ -947,8 +948,8 @@ CFE_Status_t CF_CFDP_InitEngine(void)
{
/* initialize all transaction nodes */
CF_History_t * history;
CF_Transaction_t * txn = CF_AppData.engine.transactions;
CF_ChunkWrapper_t *cw = CF_AppData.engine.chunks;
CF_Transaction_t * txn = CF_AppData.engine.transactions;
CF_ChunkWrapper_t *cw = CF_AppData.engine.chunks;
CFE_Status_t ret = CFE_SUCCESS;
int chunk_mem_offset = 0;
int i;
Expand Down Expand Up @@ -1056,7 +1057,7 @@ CFE_Status_t CF_CFDP_InitEngine(void)
CFE_Status_t CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context)
{
CF_CFDP_CycleTx_args_t *args = (CF_CFDP_CycleTx_args_t *)context;
CF_Transaction_t * txn = container_of(node, CF_Transaction_t, cl_node);
CF_Transaction_t * txn = container_of(node, CF_Transaction_t, cl_node);
CFE_Status_t ret = 1; /* default option is exit traversal */

if (txn->flags.com.suspended)
Expand Down Expand Up @@ -1136,7 +1137,7 @@ CFE_Status_t CF_CFDP_DoTick(CF_CListNode_t *node, void *context)
{
CFE_Status_t 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 * txn = container_of(node, CF_Transaction_t, cl_node);
CF_Transaction_t * txn = container_of(node, CF_Transaction_t, cl_node);
if (!args->chan->cur || (args->chan->cur == txn))
{
/* found where we left off, so clear that and move on */
Expand Down Expand Up @@ -1387,7 +1388,7 @@ CFE_Status_t CF_CFDP_PlaybackDir(const char *src_filename, const char *dst_filen
*-----------------------------------------------------------------*/
void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *chan, CF_Playback_t *pb)
{
CF_Transaction_t *pt;
CF_Transaction_t *txn;
os_dirent_t dirent;
int32 status;

Expand All @@ -1408,24 +1409,24 @@ void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *chan, CF_Playback_t *pb)
continue;
}

pt = CF_FindUnusedTransaction(chan);
txn = CF_FindUnusedTransaction(chan);
CF_Assert(pt); /* should be impossible not to have one because there are limits on the number of uses of
them */

/* the -1 below is to make room for the slash */
snprintf(pt->history->fnames.src_filename, sizeof(pt->history->fnames.src_filename), "%.*s/%.*s",
snprintf(txn->history->fnames.src_filename, sizeof(txn->history->fnames.src_filename), "%.*s/%.*s",
CF_FILENAME_MAX_PATH - 1, pb->fnames.src_filename, CF_FILENAME_MAX_NAME - 1, dirent.FileName);
snprintf(pt->history->fnames.dst_filename, sizeof(pt->history->fnames.dst_filename), "%.*s/%.*s",
snprintf(txn->history->fnames.dst_filename, sizeof(txn->history->fnames.dst_filename), "%.*s/%.*s",
CF_FILENAME_MAX_PATH - 1, pb->fnames.dst_filename, CF_FILENAME_MAX_NAME - 1, dirent.FileName);

/* in case snprintf didn't have room for NULL terminator */
pt->history->fnames.src_filename[CF_FILENAME_MAX_LEN - 1] = 0;
pt->history->fnames.dst_filename[CF_FILENAME_MAX_LEN - 1] = 0;
txn->history->fnames.src_filename[CF_FILENAME_MAX_LEN - 1] = 0;
txn->history->fnames.dst_filename[CF_FILENAME_MAX_LEN - 1] = 0;

CF_CFDP_TxFile_Initiate(pt, pb->cfdp_class, pb->keep, (chan - CF_AppData.engine.channels), pb->priority,
CF_CFDP_TxFile_Initiate(txn, pb->cfdp_class, pb->keep, (chan - CF_AppData.engine.channels), pb->priority,
pb->dest_id);

pt->pb = pb;
txn->pb = pb;
++pb->num_ts;
}
else
Expand Down Expand Up @@ -1504,7 +1505,7 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan)

for (i = 0; i < CF_MAX_POLLING_DIR_PER_CHAN; ++i)
{
poll = &chan->poll[i];
poll = &chan->poll[i];
chan_index = (chan - CF_AppData.engine.channels);
cc = &CF_AppData.config_table->chan[chan_index];
pd = &cc->polldir[i];
Expand All @@ -1523,8 +1524,8 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan)
else if (CF_Timer_Expired(&poll->interval_timer))
{
/* the timer has expired */
ret = CF_CFDP_PlaybackDir_Initiate(&poll->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0, chan_index,
pd->priority, pd->dest_eid);
ret = CF_CFDP_PlaybackDir_Initiate(&poll->pb, pd->src_dir, pd->dst_dir, pd->cfdp_class, 0,
chan_index, pd->priority, pd->dest_eid);
if (!ret)
{
poll->timer_set = 0;
Expand Down Expand Up @@ -1570,7 +1571,7 @@ void CF_CFDP_CycleEngine(void)
{
for (i = 0; i < CF_NUM_CHANNELS; ++i)
{
chan = &CF_AppData.engine.channels[i];
chan = &CF_AppData.engine.channels[i];
CF_AppData.engine.outgoing_counter = 0;

/* consume all received messages, even if channel is frozen */
Expand Down Expand Up @@ -1606,7 +1607,7 @@ void CF_CFDP_ResetTransaction(CF_Transaction_t *txn, int keep_history)
char * filename;
char destination[OS_MAX_PATH_LEN];
osal_status_t status = OS_ERROR;
CF_Channel_t *chan = &CF_AppData.engine.channels[txn->chan_num];
CF_Channel_t *chan = &CF_AppData.engine.channels[txn->chan_num];
CF_Assert(txn->chan_num < CF_NUM_CHANNELS);

CF_CFDP_SendEotPkt(txn);
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/cf_cfdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
typedef struct CF_CFDP_CycleTx_args
{
CF_Channel_t *chan; /**< \brief channel structure */
CF_Channel_t *chan; /**< \brief channel structure */
int ran_one; /**< \brief should be set to 1 if a transaction was cycled */
} CF_CFDP_CycleTx_args_t;

Expand All @@ -42,7 +42,7 @@ typedef struct CF_CFDP_CycleTx_args
*/
typedef struct CF_CFDP_Tick_args
{
CF_Channel_t *chan; /**< \brief channel structure */
CF_Channel_t *chan; /**< \brief channel structure */
void (*fn)(CF_Transaction_t *, int *); /**< \brief function pointer */
int early_exit; /**< \brief early exit result */
int cont; /**< \brief if 1, then re-traverse the list */
Expand Down
6 changes: 4 additions & 2 deletions fsw/src/cf_cfdp_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ void CF_CFDP_R_DispatchRecv(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph,
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_DC_INV, CFE_EVS_EventType_ERROR,
"CF R%d(%lu:%lu): received PDU with invalid directive code %d for sub-state %d",
(txn->state == CF_TxnState_R2), (unsigned long)txn->history->src_eid,
(unsigned long)txn->history->seq_num, fdh->directive_code, txn->state_data.receive.sub_state);
(unsigned long)txn->history->seq_num, fdh->directive_code,
txn->state_data.receive.sub_state);
}
}
else
Expand Down Expand Up @@ -122,7 +123,8 @@ void CF_CFDP_S_DispatchRecv(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph,
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_DC_INV, CFE_EVS_EventType_ERROR,
"CF S%d(%lu:%lu): received PDU with invalid directive code %d for sub-state %d",
(txn->state == CF_TxnState_S2), (unsigned long)txn->history->src_eid,
(unsigned long)txn->history->seq_num, fdh->directive_code, txn->state_data.send.sub_state);
(unsigned long)txn->history->seq_num, fdh->directive_code,
txn->state_data.send.sub_state);
}
}
else
Expand Down
43 changes: 23 additions & 20 deletions fsw/src/cf_cfdp_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ void CF_CFDP_R1_Reset(CF_Transaction_t *txn)
void CF_CFDP_R2_Reset(CF_Transaction_t *txn)
{
if ((txn->state_data.receive.sub_state == CF_RxSubState_WAIT_FOR_FIN_ACK) ||
(txn->state_data.receive.r2.eof_cc != CF_CFDP_ConditionCode_NO_ERROR) || CF_TxnStatus_IsError(txn->history->txn_stat) ||
txn->flags.com.canceled)
(txn->state_data.receive.r2.eof_cc != CF_CFDP_ConditionCode_NO_ERROR) ||
CF_TxnStatus_IsError(txn->history->txn_stat) || txn->flags.com.canceled)
{
CF_CFDP_R1_Reset(txn); /* it's done */
}
Expand Down Expand Up @@ -210,8 +210,8 @@ CFE_Status_t CF_CFDP_R_ProcessFd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *
{
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_SEEK_FD, CFE_EVS_EventType_ERROR,
"CF R%d(%lu:%lu): failed to seek offset %ld, got %ld", (txn->state == CF_TxnState_R2),
(unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num, (long)fd->offset,
(long)fret);
(unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num,
(long)fd->offset, (long)fret);
CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_FILE_SIZE_ERROR);
++CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.file_seek;
ret = CF_ERROR; /* connection will reset in caller */
Expand Down Expand Up @@ -263,7 +263,8 @@ CFE_Status_t CF_CFDP_R_SubstateRecvEof(CF_Transaction_t *txn, CF_Logical_PduBuff
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_SIZE_MISMATCH, CFE_EVS_EventType_ERROR,
"CF R%d(%lu:%lu): EOF file size mismatch: got %lu expected %lu",
(txn->state == CF_TxnState_R2), (unsigned long)txn->history->src_eid,
(unsigned long)txn->history->seq_num, (unsigned long)eof->size, (unsigned long)txn->fsize);
(unsigned long)txn->history->seq_num, (unsigned long)eof->size,
(unsigned long)txn->fsize);
++CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.file_size_mismatch;
ret = CF_REC_PDU_FSIZE_MISMATCH_ERROR;
}
Expand Down Expand Up @@ -340,7 +341,7 @@ void CF_CFDP_R2_SubstateRecvEof(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *p

/* always ACK the EOF, even if we're not done */
txn->state_data.receive.r2.eof_cc = eof->cc;
txn->flags.rx.send_ack = 1; /* defer sending ACK to tick handling */
txn->flags.rx.send_ack = 1; /* defer sending ACK to tick handling */

/* only check for complete if EOF with no errors */
if (txn->state_data.receive.r2.eof_cc == CF_CFDP_ConditionCode_NO_ERROR)
Expand Down Expand Up @@ -503,21 +504,21 @@ CFE_Status_t CF_CFDP_R_SubstateSendNak(CF_Transaction_t *txn)
nak->scope_start = 0;
cret = CF_ChunkList_ComputeGaps(&txn->chunks->chunks,
(txn->chunks->chunks.count < txn->chunks->chunks.max_chunks)
? txn->chunks->chunks.max_chunks
: (txn->chunks->chunks.max_chunks - 1),
? txn->chunks->chunks.max_chunks
: (txn->chunks->chunks.max_chunks - 1),
txn->fsize, 0, CF_CFDP_R2_GapCompute, &args);

if (!cret)
{
/* no gaps left, so go ahead and check for completion */
txn->flags.rx.complete = 1; /* we know md was received, and there's no gaps -- it's complete */
ret = CFE_SUCCESS;
ret = CFE_SUCCESS;
}
else
{
/* gaps are present, so let's send the NAK PDU */
nak->scope_end = 0;
sret = CF_CFDP_SendNak(txn, ph);
nak->scope_end = 0;
sret = CF_CFDP_SendNak(txn, ph);
txn->flags.rx.fd_nak_sent = 1; /* latch that at least one NAK has been sent requesting filedata */
CF_Assert(sret != CF_SEND_PDU_ERROR); /* NOTE: this CF_Assert is here because CF_CFDP_SendNak()
does not return CF_SEND_PDU_ERROR, so if it's ever added to
Expand Down Expand Up @@ -836,8 +837,8 @@ void CF_CFDP_R2_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph)
}
else
{
ret =
CF_WrappedOpenCreate(&txn->fd, txn->history->fnames.dst_filename, OS_FILE_FLAG_NONE, OS_READ_WRITE);
ret = CF_WrappedOpenCreate(&txn->fd, txn->history->fnames.dst_filename, OS_FILE_FLAG_NONE,
OS_READ_WRITE);
if (ret < 0)
{
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_OPEN, CFE_EVS_EventType_ERROR,
Expand All @@ -846,17 +847,17 @@ void CF_CFDP_R2_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph)
(unsigned long)txn->history->seq_num, (long)ret);
CF_CFDP_R2_SetFinTxnStatus(txn, CF_TxnStatus_FILESTORE_REJECTION);
++CF_AppData.hk.channel_hk[txn->chan_num].counters.fault.file_open;
txn->fd = OS_OBJECT_ID_UNDEFINED; /* just in case */
txn->fd = OS_OBJECT_ID_UNDEFINED; /* just in case */
success = false;
}
}

if (success)
{
txn->state_data.receive.cached_pos = 0; /* reset psn due to open */
txn->flags.rx.md_recv = 1;
txn->flags.rx.md_recv = 1;
txn->state_data.receive.r2.acknak_count = 0; /* in case part of NAK */
CF_CFDP_R2_Complete(txn, 1); /* check for completion now that md is received */
CF_CFDP_R2_Complete(txn, 1); /* check for completion now that md is received */
}
}
}
Expand Down Expand Up @@ -985,8 +986,8 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn, int *cont /* unused */)
/* rx maintenance: possibly process send_eof_ack, send_nak or send_fin */
if (txn->flags.rx.send_ack)
{
sret = CF_CFDP_SendAck(txn, CF_CFDP_AckTxnStatus_ACTIVE, CF_CFDP_FileDirective_EOF, txn->state_data.receive.r2.eof_cc,
txn->history->peer_eid, txn->history->seq_num);
sret = CF_CFDP_SendAck(txn, CF_CFDP_AckTxnStatus_ACTIVE, CF_CFDP_FileDirective_EOF,
txn->state_data.receive.r2.eof_cc, txn->history->peer_eid, txn->history->seq_num);
CF_Assert(sret != CF_SEND_PDU_ERROR);

/* if CFE_SUCCESS, then move on in the state machine. CF_CFDP_SendAck does not return
Expand Down Expand Up @@ -1030,7 +1031,8 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn, int *cont /* unused */)
++txn->state_data.receive.r2.acknak_count;

/* Check limit and handle if needed */
if (txn->state_data.receive.r2.acknak_count >= CF_AppData.config_table->chan[txn->chan_num].ack_limit)
if (txn->state_data.receive.r2.acknak_count >=
CF_AppData.config_table->chan[txn->chan_num].ack_limit)
{
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_ACK_LIMIT, CFE_EVS_EventType_ERROR,
"CF R2(%lu:%lu): ACK limit reached, no fin-ack",
Expand All @@ -1048,7 +1050,8 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn, int *cont /* unused */)

if (success)
{
CF_CFDP_ArmAckTimer(txn); /* whether sending FIN or waiting for more filedata, need ACK timer armed */
/* whether sending FIN or waiting for more filedata, need ACK timer armed */
CF_CFDP_ArmAckTimer(txn);
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_cfdp_r.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
typedef struct
{
CF_Transaction_t * txn; /**< \brief Current transaction being processed */
CF_Transaction_t * txn; /**< \brief Current transaction being processed */
CF_Logical_PduNak_t *nak; /**< \brief Current NAK PDU contents */
} CF_GapComputeArgs_t;

Expand Down
Loading

0 comments on commit 157e04a

Please sign in to comment.