Skip to content

Commit

Permalink
Fix #265, change variable names to be more informative
Browse files Browse the repository at this point in the history
  • Loading branch information
havencarlson committed Sep 20, 2023
1 parent 196574d commit 76ad4ad
Show file tree
Hide file tree
Showing 45 changed files with 2,862 additions and 2,862 deletions.
562 changes: 281 additions & 281 deletions fsw/src/cf_cfdp.c

Large diffs are not rendered by default.

168 changes: 84 additions & 84 deletions fsw/src/cf_cfdp.h

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions fsw/src/cf_cfdp_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
* See description in cf_cfdp_dispatch.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
void CF_CFDP_R_DispatchRecv(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph,
const CF_CFDP_R_SubstateDispatchTable_t *dispatch, CF_CFDP_StateRecvFunc_t fd_fn)
{
CF_Assert(t->state_data.r.sub_state < CF_RxSubState_NUM_STATES);
CF_Assert(txn->state_data.receive.sub_state < CF_RxSubState_NUM_STATES);
CF_CFDP_StateRecvFunc_t selected_handler;
CF_Logical_PduFileDirectiveHeader_t *fdh;

Expand All @@ -52,29 +52,29 @@ void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
fdh = &ph->fdirective;
if (fdh->directive_code < CF_CFDP_FileDirective_INVALID_MAX)
{
if (dispatch->state[t->state_data.r.sub_state] != NULL)
if (dispatch->state[txn->state_data.receive.sub_state] != NULL)
{
selected_handler = dispatch->state[t->state_data.r.sub_state]->fdirective[fdh->directive_code];
selected_handler = dispatch->state[txn->state_data.receive.sub_state]->fdirective[fdh->directive_code];
}
}
else
{
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.spurious;
++CF_AppData.hk.channel_hk[txn->chan_num].counters.recv.spurious;
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",
(t->state == CF_TxnState_R2), (unsigned long)t->history->src_eid,
(unsigned long)t->history->seq_num, fdh->directive_code, t->state_data.r.sub_state);
(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);
}
}
else
{
if (!CF_TxnStatus_IsError(t->history->txn_stat))
if (!CF_TxnStatus_IsError(txn->history->txn_stat))
{
selected_handler = fd_fn;
}
else
{
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.dropped;
++CF_AppData.hk.channel_hk[txn->chan_num].counters.recv.dropped;
}
}

Expand All @@ -84,7 +84,7 @@ void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
*/
if (selected_handler != NULL)
{
selected_handler(t, ph);
selected_handler(txn, ph);
}
}

Expand All @@ -94,10 +94,10 @@ void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
* See description in cf_cfdp_dispatch.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
void CF_CFDP_S_DispatchRecv(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph,
const CF_CFDP_S_SubstateRecvDispatchTable_t *dispatch)
{
CF_Assert(t->state_data.s.sub_state < CF_TxSubState_NUM_STATES);
CF_Assert(txn->state_data.s.sub_state < CF_TxSubState_NUM_STATES);
const CF_CFDP_FileDirectiveDispatchTable_t *substate_tbl;
CF_CFDP_StateRecvFunc_t selected_handler;
CF_Logical_PduFileDirectiveHeader_t * fdh;
Expand All @@ -110,26 +110,26 @@ void CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
if (fdh->directive_code < CF_CFDP_FileDirective_INVALID_MAX)
{
/* This should be silent (no event) if no handler is defined in the table */
substate_tbl = dispatch->substate[t->state_data.s.sub_state];
substate_tbl = dispatch->substate[txn->state_data.s.sub_state];
if (substate_tbl != NULL)
{
selected_handler = substate_tbl->fdirective[fdh->directive_code];
}
}
else
{
++CF_AppData.hk.channel_hk[t->chan_num].counters.recv.spurious;
++CF_AppData.hk.channel_hk[txn->chan_num].counters.recv.spurious;
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",
(t->state == CF_TxnState_S2), (unsigned long)t->history->src_eid,
(unsigned long)t->history->seq_num, fdh->directive_code, t->state_data.s.sub_state);
(txn->state == CF_TxnState_S2), (unsigned long)txn->history->src_eid,
(unsigned long)txn->history->seq_num, fdh->directive_code, txn->state_data.s.sub_state);
}
}
else
{
CFE_EVS_SendEvent(CF_EID_ERR_CFDP_S_NON_FD_PDU, CFE_EVS_EventType_ERROR,
"CF S%d(%lu:%lu): received non-file directive PDU", (t->state == CF_TxnState_S2),
(unsigned long)t->history->src_eid, (unsigned long)t->history->seq_num);
"CF S%d(%lu:%lu): received non-file directive PDU", (txn->state == CF_TxnState_S2),
(unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num);
}

/* check that there's a valid function pointer. If there isn't,
Expand All @@ -140,7 +140,7 @@ void CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
* ignore the received packet and keep chugging along. */
if (selected_handler)
{
selected_handler(t, ph);
selected_handler(txn, ph);
}
}

Expand All @@ -150,14 +150,14 @@ void CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
* See description in cf_cfdp_dispatch.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_CFDP_S_DispatchTransmit(CF_Transaction_t *t, const CF_CFDP_S_SubstateSendDispatchTable_t *dispatch)
void CF_CFDP_S_DispatchTransmit(CF_Transaction_t *txn, const CF_CFDP_S_SubstateSendDispatchTable_t *dispatch)
{
CF_CFDP_StateSendFunc_t selected_handler;

selected_handler = dispatch->substate[t->state_data.s.sub_state];
selected_handler = dispatch->substate[txn->state_data.s.sub_state];
if (selected_handler != NULL)
{
selected_handler(t);
selected_handler(txn);
}
}

Expand All @@ -167,15 +167,15 @@ void CF_CFDP_S_DispatchTransmit(CF_Transaction_t *t, const CF_CFDP_S_SubstateSen
* See description in cf_cfdp_dispatch.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_CFDP_TxStateDispatch(CF_Transaction_t *t, const CF_CFDP_TxnSendDispatchTable_t *dispatch)
void CF_CFDP_TxStateDispatch(CF_Transaction_t *txn, const CF_CFDP_TxnSendDispatchTable_t *dispatch)
{
CF_CFDP_StateSendFunc_t selected_handler;

CF_Assert(t->state < CF_TxnState_INVALID);
selected_handler = dispatch->tx[t->state];
CF_Assert(txn->state < CF_TxnState_INVALID);
selected_handler = dispatch->tx[txn->state];
if (selected_handler != NULL)
{
selected_handler(t);
selected_handler(txn);
}
}

Expand All @@ -185,15 +185,15 @@ void CF_CFDP_TxStateDispatch(CF_Transaction_t *t, const CF_CFDP_TxnSendDispatchT
* See description in cf_cfdp_dispatch.h for argument/return detail
*
*-----------------------------------------------------------------*/
void CF_CFDP_RxStateDispatch(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
void CF_CFDP_RxStateDispatch(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph,
const CF_CFDP_TxnRecvDispatchTable_t *dispatch)
{
CF_CFDP_StateRecvFunc_t selected_handler;

CF_Assert(t->state < CF_TxnState_INVALID);
selected_handler = dispatch->rx[t->state];
CF_Assert(txn->state < CF_TxnState_INVALID);
selected_handler = dispatch->rx[txn->state];
if (selected_handler != NULL)
{
selected_handler(t, ph);
selected_handler(txn, ph);
}
}
28 changes: 14 additions & 14 deletions fsw/src/cf_cfdp_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
* used on the transmit side, where a PDU will likely be generated/sent by the handler being
* invoked.
*
* @param[inout] t The transaction object
* @param[inout] txn The transaction object
*/
typedef void (*CF_CFDP_StateSendFunc_t)(CF_Transaction_t *t);
typedef void (*CF_CFDP_StateSendFunc_t)(CF_Transaction_t *txn);

/**
* @brief A function for dispatching actions to a handler, with existing PDU data
Expand All @@ -47,10 +47,10 @@ typedef void (*CF_CFDP_StateSendFunc_t)(CF_Transaction_t *t);
* used on the receive side where a PDU buffer is associated with the activity, which is then
* interpreted by the handler being invoked.
*
* @param[inout] t The transaction object
* @param[inout] txn The transaction object
* @param[inout] ph The PDU buffer currently being received/processed
*/
typedef void (*CF_CFDP_StateRecvFunc_t)(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph);
typedef void (*CF_CFDP_StateRecvFunc_t)(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph);

/**
* @brief A table of transmit handler functions based on transaction state
Expand Down Expand Up @@ -129,12 +129,12 @@ typedef struct
*
* Receive file transactions primarily only react/respond to received PDUs
*
* @param t Transaction
* @param txn Transaction
* @param ph PDU Buffer
* @param dispatch Dispatch table for file directive PDUs
* @param fd_fn Function to handle file data PDUs
*/
void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
void CF_CFDP_R_DispatchRecv(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph,
const CF_CFDP_R_SubstateDispatchTable_t *dispatch, CF_CFDP_StateRecvFunc_t fd_fn);

/************************************************************************/
Expand All @@ -144,11 +144,11 @@ void CF_CFDP_R_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
* Send file transactions also react/respond to received PDUs. Note that
* a file data PDU is not expected here.
*
* @param t Transaction
* @param txn Transaction
* @param ph PDU Buffer
* @param dispatch Dispatch table for file directive PDUs
*/
void CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
void CF_CFDP_S_DispatchRecv(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph,
const CF_CFDP_S_SubstateRecvDispatchTable_t *dispatch);

/************************************************************************/
Expand All @@ -160,10 +160,10 @@ void CF_CFDP_S_DispatchRecv(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
* This does not have an existing PDU buffer at the time of dispatch, but one may
* be generated by the invoked function.
*
* @param t Transaction
* @param txn Transaction
* @param dispatch State-based dispatch table
*/
void CF_CFDP_S_DispatchTransmit(CF_Transaction_t *t, const CF_CFDP_S_SubstateSendDispatchTable_t *dispatch);
void CF_CFDP_S_DispatchTransmit(CF_Transaction_t *txn, const CF_CFDP_S_SubstateSendDispatchTable_t *dispatch);

/************************************************************************/
/**
Expand All @@ -172,20 +172,20 @@ void CF_CFDP_S_DispatchTransmit(CF_Transaction_t *t, const CF_CFDP_S_SubstateSen
* This does not have an existing PDU buffer at the time of dispatch, but one may
* be generated by the invoked function.
*
* @param t Transaction
* @param txn Transaction
* @param dispatch Transaction State-based Dispatch table
*/
void CF_CFDP_TxStateDispatch(CF_Transaction_t *t, const CF_CFDP_TxnSendDispatchTable_t *dispatch);
void CF_CFDP_TxStateDispatch(CF_Transaction_t *txn, const CF_CFDP_TxnSendDispatchTable_t *dispatch);

/************************************************************************/
/**
* @brief Top-level Dispatch function receive a PDU based on current state of a transaction
*
* @param t Transaction
* @param txn Transaction
* @param ph Received PDU Buffer
* @param dispatch Transaction State-based Dispatch table
*/
void CF_CFDP_RxStateDispatch(CF_Transaction_t *t, CF_Logical_PduBuffer_t *ph,
void CF_CFDP_RxStateDispatch(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph,
const CF_CFDP_TxnRecvDispatchTable_t *dispatch);

#endif /* CF_CFDP_DISPATCH_H */
Loading

0 comments on commit 76ad4ad

Please sign in to comment.