Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #60, rework loop in CF_CFDP_CycleTx #165

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions fsw/src/cf_cfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1101,30 +1101,38 @@ int CF_CFDP_CycleTxFirstActive(CF_CListNode_t *node, void *context)
*-----------------------------------------------------------------*/
void CF_CFDP_CycleTx(CF_Channel_t *c)
{
CF_Transaction_t *t;
CF_CFDP_CycleTx_args_t args;

if (CF_AppData.config_table->chan[(c - CF_AppData.engine.channels)].dequeue_enabled)
{
CF_CFDP_CycleTx_args_t args = {c, 0};
args = (CF_CFDP_CycleTx_args_t) {c, 0};

/* loop through as long as there are pending transactions, and a message buffer to send their pdus on */

/* NOTE: tick processesing is higher priority than sending new filedata pdus, so only send however many
* PDUs that can be sent once we get to here */
if (!c->cur)
{ /* don't enter if cur is set, since we need to pick up where we left off on tick processing next wakeup */
goto entry_jump; /* code reviewers won't like this */
while (!args.ran_one && c->qs[CF_QueueIdx_PEND])

while (true)
{
/* didn't find anything on TXA to run, so pop one off Q_PEND and try again.
* Keep going until CF_QueueIdx_PEND is empty or something is run */
CF_Transaction_t *t = container_of(c->qs[CF_QueueIdx_PEND], CF_Transaction_t, cl_node);
CF_MoveTransaction(t, CF_QueueIdx_TXA);
/* args is ok, still { c, 0 } */
entry_jump:
/* Attempt to run something on TXA */
CF_CList_Traverse(c->qs[CF_QueueIdx_TXA], CF_CFDP_CycleTxFirstActive, &args);

/* Keep going until CF_QueueIdx_PEND is empty or something is run */
if (args.ran_one || c->qs[CF_QueueIdx_PEND] == NULL)
{
break;
}

t = container_of(c->qs[CF_QueueIdx_PEND], CF_Transaction_t, cl_node);
CF_MoveTransaction(t, CF_QueueIdx_TXA);
}
}

c->cur =
NULL; /* in case the loop exited due to no message buffers, clear it and start from the top next time */
/* in case the loop exited due to no message buffers, clear it and start from the top next time */
c->cur = NULL;
}
}

Expand Down