Skip to content

Commit 913b5fc

Browse files
authored
Merge pull request #381 from skliper/fix380-no_delay_poll
Fix #380, Support polling with no delay
2 parents 930b0e5 + 9c85db0 commit 913b5fc

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

fsw/inc/cf_tbldefs.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@
3333
*/
3434
typedef struct CF_PollDir
3535
{
36-
uint32 interval_sec; /**<
37-
* \brief number of seconds to wait before trying a new directory.
38-
*
39-
* Must be >0 or slot is inactive.
40-
*/
36+
uint32 interval_sec; /**< \brief number of seconds to wait before trying a new directory */
4137

4238
uint8 priority; /**< \brief priority to use when placing transactions on the pending queue */
4339
CF_CFDP_Class_t cfdp_class; /**< \brief the CFDP class to send */

fsw/src/cf_cfdp.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -1510,12 +1510,11 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c)
15101510
pd = &cc->polldir[i];
15111511
count_check = 0;
15121512

1513-
if (pd->enabled && pd->interval_sec)
1513+
if (pd->enabled)
15141514
{
1515-
/* only handle polling for polldirs configured with a non-zero interval */
15161515
if (!p->pb.busy && !p->pb.num_ts)
15171516
{
1518-
if (!p->timer_set)
1517+
if (!p->timer_set && pd->interval_sec)
15191518
{
15201519
/* timer was not set, so set it now */
15211520
CF_Timer_InitRelSec(&p->interval_timer, pd->interval_sec);
@@ -1539,7 +1538,9 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *c)
15391538
}
15401539
}
15411540
else
1541+
{
15421542
CF_Timer_Tick(&p->interval_timer);
1543+
}
15431544
}
15441545
else
15451546
{

unit-test/cf_cfdp_tests.c

+9-7
Original file line numberDiff line numberDiff line change
@@ -1137,27 +1137,29 @@ void Test_CF_CFDP_ProcessPollingDirectories(void)
11371137
pdcfg = &config->chan[UT_CFDP_CHANNEL].polldir[0];
11381138
poll = &c->poll[0];
11391139

1140-
/* nominal call, w/engine disabled (noop) */
1140+
/* nominal call, polldir disabled (noop) */
11411141
UtAssert_VOIDCALL(CF_CFDP_ProcessPollingDirectories(c));
11421142
UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[UT_CFDP_CHANNEL].poll_counter, 0);
11431143

1144-
/* nominal call, w/engine enabled, polldir enabled but interval_sec == 0 */
1145-
CF_AppData.engine.enabled = 1;
1146-
pdcfg->enabled = 1;
1144+
/* nominal call, polldir enabled but interval_sec == 0 */
1145+
/* Will tick because CF_Timer_Expired stub returns 0 by default (not expired) */
1146+
pdcfg->enabled = 1;
11471147
UtAssert_VOIDCALL(CF_CFDP_ProcessPollingDirectories(c));
1148-
UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[UT_CFDP_CHANNEL].poll_counter, 0);
1148+
UtAssert_BOOL_FALSE(poll->timer_set);
1149+
UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[UT_CFDP_CHANNEL].poll_counter, 1);
1150+
UtAssert_STUB_COUNT(CF_Timer_Tick, 1);
11491151

11501152
/* with interval_sec nonzero the timer should get set, but not tick */
11511153
pdcfg->interval_sec = 1;
11521154
UtAssert_VOIDCALL(CF_CFDP_ProcessPollingDirectories(c));
11531155
UtAssert_BOOL_TRUE(poll->timer_set);
1154-
UtAssert_STUB_COUNT(CF_Timer_Tick, 0);
1156+
UtAssert_STUB_COUNT(CF_Timer_Tick, 1);
11551157
UtAssert_UINT32_EQ(CF_AppData.hk.channel_hk[UT_CFDP_CHANNEL].poll_counter, 1);
11561158

11571159
/* call again should tick */
11581160
UtAssert_VOIDCALL(CF_CFDP_ProcessPollingDirectories(c));
11591161
UtAssert_BOOL_TRUE(poll->timer_set);
1160-
UtAssert_STUB_COUNT(CF_Timer_Tick, 1);
1162+
UtAssert_STUB_COUNT(CF_Timer_Tick, 2);
11611163

11621164
/* call again timer should expire and start a playback */
11631165
UT_SetDeferredRetcode(UT_KEY(CF_Timer_Expired), 1, true);

0 commit comments

Comments
 (0)