From 29787cd29147bf37421f3ebd3d41451bdbc36b4c Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Wed, 14 Sep 2022 15:10:13 +0100 Subject: [PATCH] Clarify variables used in TX callback. The power measurement depends on the number of bytes that were valid from the previous use of the transfer buffer. The number of bytes to be read to fill the next transfer, is the full size of the buffer. --- host/hackrf-tools/src/hackrf_transfer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/hackrf-tools/src/hackrf_transfer.c b/host/hackrf-tools/src/hackrf_transfer.c index 41061ff0..999d1fad 100644 --- a/host/hackrf-tools/src/hackrf_transfer.c +++ b/host/hackrf-tools/src/hackrf_transfer.c @@ -486,9 +486,8 @@ int tx_callback(hackrf_transfer* transfer) } /* Accumulate power (magnitude squared). */ - bytes_to_read = transfer->valid_length; uint64_t sum = 0; - for (i = 0; i < bytes_to_read; i++) { + for (i = 0; i < transfer->valid_length; i++) { int8_t value = transfer->buffer[i]; sum += value * value; } @@ -497,6 +496,7 @@ int tx_callback(hackrf_transfer* transfer) byte_count += transfer->valid_length; stream_power += sum; + bytes_to_read = transfer->buffer_length; if (file == NULL) { // transceiver_mode == TRANSCEIVER_MODE_SS /* Transmit continuous wave with specific amplitude */ if (limit_num_samples) {