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
#687)

* Use blocking enqueue calls for radiolink and crtp to avoid packet loss

Part of fixes for issue #681.

* Assert in radiolink that we are not dropping pks

Co-authored-by: Wolfgang Hoenig <[email protected]>
Co-authored-by: Arnaud Taffanel <[email protected]>
  • Loading branch information
3 people authored Feb 9, 2021
1 parent 9e5fce6 commit d3d0044
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/hal/src/radiolink.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "ledseq.h"
#include "queuemonitor.h"
#include "static_mem.h"
#include "cfassert.h"

#define RADIOLINK_TX_QUEUE_SIZE (1)
#define RADIOLINK_CRTP_QUEUE_SIZE (5)
Expand Down Expand Up @@ -159,7 +160,8 @@ void radiolinkSyslinkDispatch(SyslinkPacket *slp)
if (slp->type == SYSLINK_RADIO_RAW)
{
slp->length--; // Decrease to get CRTP size.
xQueueSend(crtpPacketDelivery, &slp->length, 0);
// Assert that we are not dopping any packets
ASSERT(xQueueSend(crtpPacketDelivery, &slp->length, 0) == pdPASS);
ledseqRun(&seq_linkUp);
// If a radio packet is received, one can be sent
if (xQueueReceive(txQueue, &txPacket, 0) == pdTRUE)
Expand All @@ -170,6 +172,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 d3d0044

Please sign in to comment.