Skip to content

Commit

Permalink
update canardCleanupStaleTransfers to cleanup stale tx as well
Browse files Browse the repository at this point in the history
  • Loading branch information
bugobliterator authored and tridge committed Jun 7, 2023
1 parent 04ac7f5 commit c4431b8
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions canard.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,41 @@ void canardCleanupStaleTransfers(CanardInstance* ins, uint64_t current_time_usec
state = canardRxFromIdx(&ins->allocator, state->next);
}
}

#if CANARD_MULTI_IFACE || CANARD_ENABLE_DEADLINE
// remove stale TX transfers
CanardTxQueueItem* prev_item = ins->tx_queue, * item = ins->tx_queue;
while (item != NULL)
{
#if CANARD_MULTI_IFACE && CANARD_ENABLE_DEADLINE
if ((current_time_usec > item->frame.deadline_usec) || item->frame.iface_mask == 0)
#elif CANARD_MULTI_IFACE
if (item->frame.iface_mask == 0)
#else
if (current_time_usec > item->frame.deadline_usec)
#endif
{
if (item == ins->tx_queue)
{
ins->tx_queue = ins->tx_queue->next;
freeBlock(&ins->allocator, item);
item = ins->tx_queue;
prev_item = item;
}
else
{
prev_item->next = item->next;
freeBlock(&ins->allocator, item);
item = prev_item->next;
}
}
else
{
prev_item = item;
item = item->next;
}
}
#endif
}

int16_t canardDecodeScalar(const CanardRxTransfer* transfer,
Expand Down

0 comments on commit c4431b8

Please sign in to comment.