diff --git a/host/hackrf-tools/src/hackrf_sweep.c b/host/hackrf-tools/src/hackrf_sweep.c index d28a6c5a7..fbf4c7757 100644 --- a/host/hackrf-tools/src/hackrf_sweep.c +++ b/host/hackrf-tools/src/hackrf_sweep.c @@ -184,6 +184,7 @@ uint32_t amp_enable; bool antenna = false; uint32_t antenna_enable; +bool timestamp_normalized = false; bool binary_output = false; bool ifft_output = false; bool one_shot = false; @@ -231,8 +232,8 @@ int rx_callback(hackrf_transfer* transfer) return 0; } - // happens only once - if (usb_transfer_time.tv_sec == 0 && usb_transfer_time.tv_usec == 0) { + // happens only once with timestamp_normalized == true + if ((usb_transfer_time.tv_sec == 0 && usb_transfer_time.tv_usec == 0) || timestamp_normalized == false) { // set the timestamp for the first sweep gettimeofday(&usb_transfer_time, NULL); } @@ -273,9 +274,12 @@ int rx_callback(hackrf_transfer* transfer) } sweep_count++; - // set the timestamp of the next sweep - memset(&usb_transfer_time, 0, sizeof (usb_transfer_time)); - gettimeofday(&usb_transfer_time, NULL); + if (timestamp_normalized == true) + { + // set the timestamp of the next sweep + memset(&usb_transfer_time, 0, sizeof (usb_transfer_time)); + gettimeofday(&usb_transfer_time, NULL); + } if (one_shot) { do_exit = true; @@ -397,6 +401,7 @@ static void usage() "\t[-N num_sweeps] # Number of sweeps to perform\n" "\t[-B] # binary output\n" "\t[-I] # binary inverse FFT output\n" + "\t[-n] # keep the same timestamp within a sweep\n" "\t-r filename # output file\n" "\n" "Output fields:\n" @@ -438,7 +443,7 @@ int main(int argc, char** argv) uint32_t freq_max = 6000; uint32_t requested_fft_bin_width; - while ((opt = getopt(argc, argv, "a:f:p:l:g:d:n:N:w:1BIr:h?")) != EOF) { + while ((opt = getopt(argc, argv, "a:f:p:l:g:d:N:w:n1BIr:h?")) != EOF) { result = HACKRF_SUCCESS; switch (opt) { case 'd': @@ -500,6 +505,10 @@ int main(int argc, char** argv) fftSize = DEFAULT_SAMPLE_RATE_HZ / requested_fft_bin_width; break; + case 'n': + timestamp_normalized = true; + break; + case '1': one_shot = true; break;