Skip to content

Commit

Permalink
reset_transaction and others
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Jul 12, 2024
1 parent e192dfc commit eec4ab6
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 92 deletions.
26 changes: 13 additions & 13 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void CF_CFDP_DecodeStart(CF_DecoderState_t *pdec, const void *msgbuf, CF_Logical
void CF_CFDP_ArmAckTimer(CF_Transaction_t *txn)
{
CF_Timer_InitRelSec(&txn->ack_timer, CF_AppData.config_table->chan[txn->chan_num].ack_timer_s);
txn->flags.com.ack_timer_armed = 1;
txn->flags.com.ack_timer_armed = true;
}

/*----------------------------------------------------------------
Expand Down Expand Up @@ -252,7 +252,7 @@ CF_Logical_PduBuffer_t *CF_CFDP_ConstructPduHeader(const CF_Transaction_t *txn,

hdr->version = 1;
hdr->pdu_type = (directive_code == 0); /* set to '1' for file data PDU, '0' for a directive PDU */
hdr->direction = (towards_sender != 0); /* set to '1' for toward sender, '0' for toward receiver */
hdr->direction = (towards_sender != false); /* set to '1' for toward sender, '0' for toward receiver */
hdr->txm_mode = (CF_CFDP_GetClass(txn) == CF_CFDP_CLASS_1); /* set to '1' for class 1 data, '0' for class 2 */

/* choose the larger of the two EIDs to determine size */
Expand Down Expand Up @@ -896,7 +896,7 @@ void CF_CFDP_RecvIdle(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph)
{
/* NOTE: whether or not class 1 or 2, get a free chunks. It's cheap, and simplifies cleanup path */
txn->state = ph->pdu_header.txm_mode ? CF_TxnState_R1 : CF_TxnState_R2;
txn->flags.rx.md_recv = 1;
txn->flags.rx.md_recv = true;
CF_CFDP_R_Init(txn); /* initialize R */
}
else
Expand All @@ -918,7 +918,7 @@ void CF_CFDP_RecvIdle(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph)
if (txn->state == CF_TxnState_IDLE)
{
/* state was not changed, so free the transaction */
CF_CFDP_ResetTransaction(txn, 0);
CF_CFDP_ResetTransaction(txn, false);
}
}

Expand Down Expand Up @@ -1289,7 +1289,7 @@ CFE_Status_t CF_CFDP_TxFile(const char *src_filename, const char *dst_filename,
CF_CFDP_TxFile_Initiate(txn, cfdp_class, keep, chan_num, priority, dest_id);

++chan->num_cmd_tx;
txn->flags.tx.cmd_tx = 1;
txn->flags.tx.cmd_tx = true;
}

return ret;
Expand All @@ -1316,8 +1316,8 @@ static CFE_Status_t CF_CFDP_PlaybackDir_Initiate(CF_Playback_t *pb, const char *
}
else
{
pb->diropen = 1;
pb->busy = 1;
pb->diropen = true;
pb->busy = true;
pb->keep = keep;
pb->priority = priority;
pb->dest_id = dest_id;
Expand Down Expand Up @@ -1417,15 +1417,15 @@ void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *chan, CF_Playback_t *pb)
{
/* PFTO: can we figure out the difference between "end of dir" and an error? */
OS_DirectoryClose(pb->dir_id);
pb->diropen = 0;
pb->diropen = false;
}
}

if (!pb->diropen && !pb->num_ts)
{
/* the directory has been exhausted, and there are no more active transactions
* for this playback -- so mark it as not busy */
pb->busy = 0;
pb->busy = false;
}
}

Expand Down Expand Up @@ -1503,7 +1503,7 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan)
{
/* timer was not set, so set it now */
CF_Timer_InitRelSec(&poll->interval_timer, pd->interval_sec);
poll->timer_set = 1;
poll->timer_set = true;
}
else if (CF_Timer_Expired(&poll->interval_timer))
{
Expand All @@ -1512,7 +1512,7 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan)
chan_index, pd->priority, pd->dest_eid);
if (!ret)
{
poll->timer_set = 0;
poll->timer_set = false;
}
else
{
Expand Down Expand Up @@ -1586,7 +1586,7 @@ void CF_CFDP_CycleEngine(void)
* See description in cf_cfdp.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_CFDP_ResetTransaction(CF_Transaction_t *txn, int keep_history)
void CF_CFDP_ResetTransaction(CF_Transaction_t *txn, bool keep_history)
{
char * filename;
char destination[OS_MAX_PATH_LEN];
Expand Down Expand Up @@ -1759,7 +1759,7 @@ void CF_CFDP_CancelTransaction(CF_Transaction_t *txn)
void (*fns[2])(CF_Transaction_t * txn) = {CF_CFDP_R_Cancel, CF_CFDP_S_Cancel};
if (!txn->flags.com.canceled)
{
txn->flags.com.canceled = 1;
txn->flags.com.canceled = true;
CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_CANCEL_REQUEST_RECEIVED);
fns[!!CF_CFDP_IsSender(txn)](txn);
}
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/cf_cfdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void CF_CFDP_DecodeStart(CF_DecoderState_t *pdec, const void *msgbuf, CF_Logical
* @param txn Pointer to the transaction object
* @param keep_history Whether the transaction info should be preserved in history
*/
void CF_CFDP_ResetTransaction(CF_Transaction_t *txn, int keep_history);
void CF_CFDP_ResetTransaction(CF_Transaction_t *txn, bool keep_history);

/************************************************************************/
/** @brief Helper function to store transaction status code only
Expand Down
42 changes: 21 additions & 21 deletions fsw/src/cf_cfdp_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void CF_CFDP_R2_SetFinTxnStatus(CF_Transaction_t *txn, CF_TxnStatus_t txn_stat)
*-----------------------------------------------------------------*/
void CF_CFDP_R1_Reset(CF_Transaction_t *txn)
{
CF_CFDP_ResetTransaction(txn, 1);
CF_CFDP_ResetTransaction(txn, true);
}

/*----------------------------------------------------------------
Expand Down Expand Up @@ -115,8 +115,8 @@ CFE_Status_t CF_CFDP_R_CheckCrc(CF_Transaction_t *txn, uint32 expected_crc)
void CF_CFDP_R2_Complete(CF_Transaction_t *txn, int ok_to_send_nak)
{
uint32 ret;
int send_nak = 0;
int send_fin = 0;
int send_nak = false;
int send_fin = false;
/* checking if r2 is complete. Check NAK list, and send NAK if appropriate */
/* if all data is present, then there will be no gaps in the chunk */

Expand All @@ -125,7 +125,7 @@ void CF_CFDP_R2_Complete(CF_Transaction_t *txn, int ok_to_send_nak)
/* first, check if md is received. If not, send specialized NAK */
if (!txn->flags.rx.md_recv)
{
send_nak = 1;
send_nak = true;
}
else
{
Expand All @@ -135,12 +135,12 @@ void CF_CFDP_R2_Complete(CF_Transaction_t *txn, int ok_to_send_nak)
if (ret)
{
/* there is at least 1 gap, so send a NAK */
send_nak = 1;
send_nak = true;
}
else if (txn->flags.rx.eof_recv)
{
/* the EOF was received, and there are no NAKs -- process completion in send FIN state */
send_fin = 1;
send_fin = true;
}
}

Expand All @@ -155,21 +155,21 @@ void CF_CFDP_R2_Complete(CF_Transaction_t *txn, int ok_to_send_nak)
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_R_NAK_LIMIT, CFE_EVS_EventType_ERROR,
"CF R%d(%lu:%lu): NAK limited reach", (txn->state == CF_TxnState_R2),
(unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num);
send_fin = 1;
send_fin = true;
++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.nak_limit;
/* don't use CF_CFDP_R2_SetFinTxnStatus because many places in this function set send_fin */
CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_NAK_LIMIT_REACHED);
txn->state_data.receive.r2.acknak_count = 0; /* reset for fin/ack */
}
else
{
txn->flags.rx.send_nak = 1;
txn->flags.rx.send_nak = true;
}
}

if (send_fin)
{
txn->flags.rx.complete = 1; /* latch completeness, since send_fin is cleared later */
txn->flags.rx.complete = true; /* latch completeness, since send_fin is cleared later */

/* the transaction is now considered complete, but this will not overwrite an
* error status code if there was one set */
Expand Down Expand Up @@ -333,15 +333,15 @@ void CF_CFDP_R2_SubstateRecvEof(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *p
{
eof = &ph->int_header.eof;

txn->flags.rx.eof_recv = 1;
txn->flags.rx.eof_recv = true;

/* need to remember the EOF CRC for later */
txn->state_data.receive.r2.eof_crc = eof->crc;
txn->state_data.receive.r2.eof_size = eof->size;

/* 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 = true; /* 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 @@ -511,15 +511,15 @@ CFE_Status_t CF_CFDP_R_SubstateSendNak(CF_Transaction_t *txn)
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 */
txn->flags.rx.complete = true; /* we know md was received, and there's no gaps -- it's complete */
ret = CFE_SUCCESS;
}
else
{
/* gaps are present, so let's send the NAK PDU */
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 */
txn->flags.rx.fd_nak_sent = true; /* 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
that function we need to test handling it here */
Expand Down Expand Up @@ -703,7 +703,7 @@ CFE_Status_t CF_CFDP_R2_CalcCrcChunk(CF_Transaction_t *txn)
CF_CFDP_R2_SetFinTxnStatus(txn, CF_TxnStatus_FILE_CHECKSUM_FAILURE);
}

txn->flags.com.crc_calc = 1;
txn->flags.com.crc_calc = true;

ret = CFE_SUCCESS;
}
Expand Down Expand Up @@ -855,7 +855,7 @@ void CF_CFDP_R2_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph)
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 = true;
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 */
}
Expand Down Expand Up @@ -927,7 +927,7 @@ void CF_CFDP_R_Cancel(CF_Transaction_t *txn)
/* for cancel, only need to send FIN if R2 */
if ((txn->state == CF_TxnState_R2) && (txn->state_data.receive.sub_state < CF_RxSubState_WAIT_FOR_FIN_ACK))
{
txn->flags.rx.send_fin = 1;
txn->flags.rx.send_fin = true;
}
else
{
Expand Down Expand Up @@ -975,7 +975,7 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn, int *cont /* unused */)
CF_CFDP_R_SendInactivityEvent(txn);

CF_CFDP_R2_SetFinTxnStatus(txn, CF_TxnStatus_INACTIVITY_DETECTED);
txn->flags.rx.inactivity_fired = 1;
txn->flags.rx.inactivity_fired = true;
}
else
{
Expand All @@ -994,21 +994,21 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn, int *cont /* unused */)
* CF_SEND_PDU_ERROR */
if (sret != CF_SEND_PDU_NO_BUF_AVAIL_ERROR)
{
txn->flags.rx.send_ack = 0;
txn->flags.rx.send_ack = false;
}
}
else if (txn->flags.rx.send_nak)
{
if (!CF_CFDP_R_SubstateSendNak(txn))
{
txn->flags.rx.send_nak = 0; /* will re-enter on error */
txn->flags.rx.send_nak = false; /* will re-enter on error */
}
}
else if (txn->flags.rx.send_fin)
{
if (!CF_CFDP_R2_SubstateSendFin(txn))
{
txn->flags.rx.send_fin = 0; /* will re-enter on error */
txn->flags.rx.send_fin = false; /* will re-enter on error */
}
}
else
Expand Down Expand Up @@ -1044,7 +1044,7 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn, int *cont /* unused */)
}
else
{
txn->flags.rx.send_fin = 1;
txn->flags.rx.send_fin = true;
}
}

Expand Down
14 changes: 7 additions & 7 deletions fsw/src/cf_cfdp_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*-----------------------------------------------------------------*/
static inline void CF_CFDP_S_Reset(CF_Transaction_t *txn)
{
CF_CFDP_ResetTransaction(txn, 1);
CF_CFDP_ResetTransaction(txn, true);
}

/*----------------------------------------------------------------
Expand All @@ -62,7 +62,7 @@ CFE_Status_t CF_CFDP_S_SendEof(CF_Transaction_t *txn)
if (!txn->flags.com.crc_calc)
{
CF_CRC_Finalize(&txn->crc);
txn->flags.com.crc_calc = 1;
txn->flags.com.crc_calc = true;
}
return CF_CFDP_SendEof(txn);
}
Expand Down Expand Up @@ -93,7 +93,7 @@ void CF_CFDP_S1_SubstateSendEof(CF_Transaction_t *txn)
void CF_CFDP_S2_SubstateSendEof(CF_Transaction_t *txn)
{
txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_EOF_ACK;
txn->flags.com.ack_timer_armed = 1; /* will cause tick to see ack_timer as expired, and act */
txn->flags.com.ack_timer_armed = true; /* will cause tick to see ack_timer as expired, and act */

/* no longer need to send file data PDU except in the case of NAK response */

Expand Down Expand Up @@ -250,7 +250,7 @@ CFE_Status_t CF_CFDP_S_CheckAndRespondNak(CF_Transaction_t *txn)
{
const CF_Chunk_t *chunk;
CFE_Status_t sret;
CFE_Status_t ret = 0;
CFE_Status_t ret = CFE_SUCCESS;

if (txn->flags.tx.md_need_send)
{
Expand All @@ -263,7 +263,7 @@ CFE_Status_t CF_CFDP_S_CheckAndRespondNak(CF_Transaction_t *txn)
{
if (sret == CFE_SUCCESS)
{
txn->flags.tx.md_need_send = 0;
txn->flags.tx.md_need_send = false;
}
/* unless CF_SEND_PDU_ERROR, return 1 to keep caller from sending file data */
ret = 1; /* 1 means nak processed, so don't send filedata */
Expand Down Expand Up @@ -494,7 +494,7 @@ void CF_CFDP_S2_Nak(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph)
if (sr->offset_start == 0 && sr->offset_end == 0)
{
/* need to re-send metadata PDU */
txn->flags.tx.md_need_send = 1;
txn->flags.tx.md_need_send = true;
}
else
{
Expand Down Expand Up @@ -566,7 +566,7 @@ void CF_CFDP_S2_WaitForEofAck(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph)
else
{
txn->state_data.send.sub_state = CF_TxSubState_WAIT_FOR_FIN;
txn->flags.com.ack_timer_armed = 0; /* just wait for FIN now, nothing to re-send */
txn->flags.com.ack_timer_armed = false; /* just wait for FIN now, nothing to re-send */
}
}
else
Expand Down
8 changes: 4 additions & 4 deletions fsw/src/cf_clist.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void CF_CList_Traverse(CF_CListNode_t *start, CF_CListFn_t fn, void *context)
{
CF_CListNode_t *node = start;
CF_CListNode_t *node_next;
int last = 0;
bool last = false;

if (node)
{
Expand All @@ -200,7 +200,7 @@ void CF_CList_Traverse(CF_CListNode_t *start, CF_CListFn_t fn, void *context)
node_next = node->next;
if (node_next == start)
{
last = 1;
last = true;
}
if (!CF_CListTraverse_Status_IS_CONTINUE(fn(node, context)))
{
Expand Down Expand Up @@ -231,7 +231,7 @@ void CF_CList_Traverse_R(CF_CListNode_t *end, CF_CListFn_t fn, void *context)
{
CF_CListNode_t *node = end->prev;
CF_CListNode_t *node_next;
int last = 0;
bool last = false;

if (node)
{
Expand All @@ -243,7 +243,7 @@ void CF_CList_Traverse_R(CF_CListNode_t *end, CF_CListFn_t fn, void *context)
node_next = node->prev;
if (node_next == end)
{
last = 1;
last = true;
}

if (!CF_CListTraverse_Status_IS_CONTINUE(fn(node, context)))
Expand Down
Loading

0 comments on commit eec4ab6

Please sign in to comment.