From f4202d1163aacd88c26714ea578f42da94fb91ee Mon Sep 17 00:00:00 2001 From: Michael Ossmann Date: Sun, 18 Sep 2022 13:27:51 -0400 Subject: [PATCH] hackrf_transfer: Don't skip preload stats in RX Fixes a bug introduced in 8a9af7a: Statistics skipped for initial buffers not only when preloaded in TX mode but also in RX mode with no preloading. The total bytes transferred may appear inflated in RX mode when receiving a small number of samples with -n, but the stats represent data transferred over USB, some of which may have been discarded by the host. --- host/hackrf-tools/src/hackrf_transfer.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/host/hackrf-tools/src/hackrf_transfer.c b/host/hackrf-tools/src/hackrf_transfer.c index d1e723bb..bc52776a 100644 --- a/host/hackrf-tools/src/hackrf_transfer.c +++ b/host/hackrf-tools/src/hackrf_transfer.c @@ -1249,6 +1249,8 @@ int main(int argc, char** argv) result |= hackrf_set_lna_gain(device, lna_gain); result |= hackrf_start_rx(device, rx_callback, NULL); } else { + preload_bytes = hackrf_get_transfer_queue_depth(device) * + hackrf_get_transfer_buffer_size(device); result = hackrf_set_txvga_gain(device, txvga_gain); result |= hackrf_enable_tx_flush(device, 1); result |= hackrf_start_tx(device, tx_callback, NULL); @@ -1279,9 +1281,6 @@ int main(int argc, char** argv) .it_value = {.tv_sec = 1, .tv_usec = 0}}; setitimer(ITIMER_REAL, &interval_timer, NULL); #endif - preload_bytes = hackrf_get_transfer_queue_depth(device) * - hackrf_get_transfer_buffer_size(device); - while ((hackrf_is_streaming(device) == HACKRF_TRUE) && (do_exit == false)) { uint64_t byte_count_now; struct timeval time_now;