Skip to content

Commit

Permalink
Use blocking enqueue calls for radiolink and crtp to avoid packet loss
Browse files Browse the repository at this point in the history
Part of fixes for issue #681.
  • Loading branch information
whoenig committed Feb 6, 2021
1 parent 6b4cb3a commit 761834f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/hal/src/radiolink.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ void radiolinkSyslinkDispatch(SyslinkPacket *slp)
if (slp->type == SYSLINK_RADIO_RAW)
{
slp->length--; // Decrease to get CRTP size.
xQueueSend(crtpPacketDelivery, &slp->length, 0);
// Block, since we should never drop a packet
xQueueSend(crtpPacketDelivery, &slp->length, portMAX_DELAY);
ledseqRun(&seq_linkUp);
// If a radio packet is received, one can be sent
if (xQueueReceive(txQueue, &txPacket, 0) == pdTRUE)
Expand All @@ -170,6 +171,7 @@ void radiolinkSyslinkDispatch(SyslinkPacket *slp)
} else if (slp->type == SYSLINK_RADIO_RAW_BROADCAST)
{
slp->length--; // Decrease to get CRTP size.
// broadcasts are best effort, so no need to handle the case where the queue is full
xQueueSend(crtpPacketDelivery, &slp->length, 0);
ledseqRun(&seq_linkUp);
// no ack for broadcasts
Expand Down
7 changes: 2 additions & 5 deletions src/modules/src/crtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,8 @@ void crtpRxTask(void *param)
{
if (queues[p.port])
{
if (xQueueSend(queues[p.port], &p, 0) == errQUEUE_FULL)
{
// We should never drop packet
ASSERT(0);
}
// Block, since we should never drop a packet
xQueueSend(queues[p.port], &p, portMAX_DELAY);
}

if (callbacks[p.port])
Expand Down

0 comments on commit 761834f

Please sign in to comment.