Skip to content

Commit

Permalink
Added a new option (-n) to enable timestamp normalization within a sa…
Browse files Browse the repository at this point in the history
…me sweep
  • Loading branch information
matrix committed Jul 14, 2023
1 parent d90d9d3 commit 90788da
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions host/hackrf-tools/src/hackrf_sweep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 90788da

Please sign in to comment.