diff --git a/host/hackrf-tools/src/hackrf_sweep.c b/host/hackrf-tools/src/hackrf_sweep.c index dfc66954..40bdb6eb 100644 --- a/host/hackrf-tools/src/hackrf_sweep.c +++ b/host/hackrf-tools/src/hackrf_sweep.c @@ -1,6 +1,7 @@ /* * Copyright 2016 Dominic Spill * Copyright 2016 Mike Walters + * Copyright 2017 Michael Ossmann * * This file is part of HackRF. * @@ -193,84 +194,79 @@ float logPower(fftwf_complex in, float scale) } int rx_callback(hackrf_transfer* transfer) { - /* This is where we need to do interesting things with the samples - * FFT - * Throw away unused bins - * write output to pipe - */ int8_t* buf; uint8_t* ubuf; uint64_t frequency; /* in Hz */ float float_freq; int i, j; - if( fd != NULL ) { - byte_count += transfer->valid_length; - buf = (int8_t*) transfer->buffer; - for(j=0; j i; i++) { - printf(", %.2f", pwr[i]); - } - printf("\n"); - printf("%s, %" PRIu64 ", %" PRIu64 ", %.2f, %u", - time_str, - (uint64_t)(frequency+(DEFAULT_SAMPLE_RATE_HZ/2)), - (uint64_t)(frequency+((DEFAULT_SAMPLE_RATE_HZ*3)/4)), - (float)fft_bin_width, - fftSize); - for(i=1+fftSize/8; (1+(fftSize*3)/8) > i; i++) { - printf(", %.2f", pwr[i]); - } - printf("\n"); - } - } - return 0; - } else { + if(NULL == fd) { return -1; } + + byte_count += transfer->valid_length; + buf = (int8_t*) transfer->buffer; + for(j=0; j i; i++) { + printf(", %.2f", pwr[i]); + } + printf("\n"); + printf("%s, %" PRIu64 ", %" PRIu64 ", %.2f, %u", + time_str, + (uint64_t)(frequency+(DEFAULT_SAMPLE_RATE_HZ/2)), + (uint64_t)(frequency+((DEFAULT_SAMPLE_RATE_HZ*3)/4)), + (float)fft_bin_width, + fftSize); + for(i=1+fftSize/8; (1+(fftSize*3)/8) > i; i++) { + printf(", %.2f", pwr[i]); + } + printf("\n"); + } + } + return 0; } static void usage() {