From 68f464e5b926afd36c9e4d817cdba09db6c1d102 Mon Sep 17 00:00:00 2001 From: Kyuwon Jeong Date: Mon, 16 Nov 2026 22:36:03 +0900 Subject: [PATCH] Fix #527, Honor dequeue_enabled when starting pending transactions The per-channel dequeue_enabled flag was still set by the enable/disable dequeue commands and the configuration table, but nothing read it after the state machine rework in a0914c4, so pending transactions were always started. Check the flag in CF_CFDP_StartFirstPending() so that transactions stay on the PEND queue while dequeue is disabled. Transactions that are already active are not affected. --- fsw/src/cf_cfdp.c | 6 ++++++ fsw/src/cf_cfdp.h | 5 +++++ unit-test/cf_cfdp_tests.c | 15 +++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index 110b126a..106096a8 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -1472,6 +1472,12 @@ bool CF_CFDP_StartFirstPending(CF_Channel_t *chan) { CF_Transaction_t *txn; + if (!chan->config.dequeue_enabled) + { + /* dequeue is disabled on this channel, leave pending transactions on the PEND queue */ + return false; + } + if (chan->qs[CF_QueueIdx_PEND] == NULL) { /* nothing pending */ diff --git a/fsw/src/cf_cfdp.h b/fsw/src/cf_cfdp.h index c1eb2d9b..ac5d8d17 100644 --- a/fsw/src/cf_cfdp.h +++ b/fsw/src/cf_cfdp.h @@ -917,8 +917,13 @@ void CF_CFDP_SetupTxTransaction(CF_Transaction_t *txn); * and prepares for it to be activated. * * @par Assumptions, External Events, and Notes: + * Nothing is pulled while dequeue is disabled on the channel. Transactions + * that are already active are not affected. * * @param chan Channel pointer + * + * @retval true if a pending transaction was started + * @retval false if dequeue is disabled or the PEND queue is empty */ bool CF_CFDP_StartFirstPending(CF_Channel_t *chan); diff --git a/unit-test/cf_cfdp_tests.c b/unit-test/cf_cfdp_tests.c index 71748555..0f84ad1a 100644 --- a/unit-test/cf_cfdp_tests.c +++ b/unit-test/cf_cfdp_tests.c @@ -1848,14 +1848,21 @@ void Test_CF_CFDP_StartFirstPending(void) UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); /* nothing pending */ + chan->config.dequeue_enabled = true; UtAssert_BOOL_FALSE(CF_CFDP_StartFirstPending(chan)); - txn->flags.com.q_index = CF_QueueIdx_PEND; - chan->qs[CF_QueueIdx_PEND] = &txn->cl_node; - - /* this dequeues */ + txn->flags.com.q_index = CF_QueueIdx_PEND; + chan->qs[CF_QueueIdx_PEND] = &txn->cl_node; chan->stat.q_size[txn->flags.com.q_index] = 1; + /* dequeue disabled, the transaction must stay on the PEND queue */ + chan->config.dequeue_enabled = false; + UtAssert_BOOL_FALSE(CF_CFDP_StartFirstPending(chan)); + UtAssert_ADDRESS_EQ(chan->qs[CF_QueueIdx_PEND], &txn->cl_node); + UtAssert_UINT32_EQ(txn->flags.com.q_index, CF_QueueIdx_PEND); + + /* this dequeues */ + chan->config.dequeue_enabled = true; UtAssert_BOOL_TRUE(CF_CFDP_StartFirstPending(chan)); }