From 3fa96ca7e329b7f70abe6fcb8ccdca3d43a9efba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hamal=20Dvo=C5=99=C3=A1k?= Date: Sat, 8 Jun 2024 11:59:14 +0200 Subject: [PATCH] Avoid getting stuck on many commands --- src/main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.c b/src/main.c index 5e87852..9faa2c3 100644 --- a/src/main.c +++ b/src/main.c @@ -613,19 +613,19 @@ static void do_rx(int rx_pin, int bias_pin) /* Flush the queue */; while (true) { - if (0 == check_command()) - break; + int cmd; - for (int i = 0; i < 32; i++) { - if (queue_try_remove(&iq_queue, block)) { - fwrite(block, sizeof block, 1, stdout); - fflush(stdout); - } else { - break; - } + while ((cmd = check_command()) >= 0) + if (0 == cmd) + goto done; + + if (queue_try_remove(&iq_queue, block)) { + fwrite(block, sizeof block, 1, stdout); + fflush(stdout); } } +done: multicore_fifo_push_blocking(0); multicore_fifo_pop_blocking(); sleep_us(10);