From 1d8a197a9c286d61b47d0904c0c7352838dc3a91 Mon Sep 17 00:00:00 2001 From: PonomarevDA Date: Fri, 10 Jan 2025 21:08:42 +0300 Subject: [PATCH] receive multiple frames during spin --- src/dronecan.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/dronecan.c b/src/dronecan.c index 52c5be0..ef978d1 100644 --- a/src/dronecan.c +++ b/src/dronecan.c @@ -314,12 +314,16 @@ static uint8_t uavcanProcessSending() { static bool uavcanProcessReceiving(uint32_t crnt_time_ms) { CanardCANFrame rx_frame; - int16_t res = canDriverReceive(&rx_frame, CAN_DRIVER_FIRST); - if (res) { - uint64_t crnt_time_us = crnt_time_ms * 1000; - canardHandleRxFrame(&g_canard, &rx_frame, crnt_time_us); - return true; + for (size_t idx = 0; idx < 10; idx++) { + int16_t res = canDriverReceive(&rx_frame, CAN_DRIVER_FIRST); + if (res) { + uint64_t crnt_time_us = crnt_time_ms * 1000; + canardHandleRxFrame(&g_canard, &rx_frame, crnt_time_us); + } else { + break; + } } + return false; }