hackrf_transfer: report on only actual transfers
The statistics reported to the user now reflect only completed USB transfers and do not include information about the empty buffers that are preloaded with data at the start of a TX operation.
This commit is contained in:
@ -683,6 +683,7 @@ int main(int argc, char** argv)
|
|||||||
unsigned int lna_gain = 8, vga_gain = 20, txvga_gain = 0;
|
unsigned int lna_gain = 8, vga_gain = 20, txvga_gain = 0;
|
||||||
hackrf_m0_state state;
|
hackrf_m0_state state;
|
||||||
stats_t stats = {0, 0};
|
stats_t stats = {0, 0};
|
||||||
|
static int32_t preload_bytes = 0;
|
||||||
|
|
||||||
while ((opt =
|
while ((opt =
|
||||||
getopt(argc,
|
getopt(argc,
|
||||||
@ -1272,6 +1273,8 @@ int main(int argc, char** argv)
|
|||||||
.it_value = {.tv_sec = 1, .tv_usec = 0}};
|
.it_value = {.tv_sec = 1, .tv_usec = 0}};
|
||||||
setitimer(ITIMER_REAL, &interval_timer, NULL);
|
setitimer(ITIMER_REAL, &interval_timer, NULL);
|
||||||
#endif
|
#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)) {
|
while ((hackrf_is_streaming(device) == HACKRF_TRUE) && (do_exit == false)) {
|
||||||
uint64_t byte_count_now;
|
uint64_t byte_count_now;
|
||||||
@ -1324,6 +1327,23 @@ int main(int argc, char** argv)
|
|||||||
byte_count = 0;
|
byte_count = 0;
|
||||||
stream_power = 0;
|
stream_power = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The TX callback is called to preload the USB
|
||||||
|
* transfer buffers at the start of TX. This results in
|
||||||
|
* invalid statistics collected about the empty buffers
|
||||||
|
* before any USB transfer is completed. We skip these
|
||||||
|
* statistics and do not report them to the user.
|
||||||
|
*/
|
||||||
|
if (preload_bytes > 0) {
|
||||||
|
if (preload_bytes > byte_count_now) {
|
||||||
|
preload_bytes -= byte_count_now;
|
||||||
|
byte_count_now = 0;
|
||||||
|
} else {
|
||||||
|
byte_count_now -= preload_bytes;
|
||||||
|
preload_bytes = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
time_difference = TimevalDiff(&time_now, &time_start);
|
time_difference = TimevalDiff(&time_now, &time_start);
|
||||||
rate = (float) byte_count_now / time_difference;
|
rate = (float) byte_count_now / time_difference;
|
||||||
if (byte_count_now == 0 && hw_sync == true &&
|
if (byte_count_now == 0 && hw_sync == true &&
|
||||||
|
Reference in New Issue
Block a user