Skip to content

Commit

Permalink
Merge pull request #853 from miek/sweep_loop_timings
Browse files Browse the repository at this point in the history
hackrf_sweep: switch main loop timing back to 1Hz
  • Loading branch information
mossmann authored Mar 18, 2021
2 parents b112d18 + 5361b3a commit 15b2d3a
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions host/hackrf-tools/src/hackrf_sweep.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ int main(int argc, char** argv) {
const char* serial_number = NULL;
int exit_code = EXIT_SUCCESS;
struct timeval time_now;
struct timeval time_prev;
float time_diff;
float sweep_rate;
unsigned int lna_gain=16, vga_gain=20;
Expand Down Expand Up @@ -702,25 +703,28 @@ int main(int argc, char** argv) {
}

gettimeofday(&t_start, NULL);
time_prev = t_start;

fprintf(stderr, "Stop with Ctrl-C\n");
while((hackrf_is_streaming(device) == HACKRF_TRUE) && (do_exit == false)) {
float time_difference;
m_sleep(50);

gettimeofday(&time_now, NULL);

time_difference = TimevalDiff(&time_now, &t_start);
sweep_rate = (float)sweep_count / time_difference;
fprintf(stderr, "%" PRIu64 " total sweeps completed, %.2f sweeps/second\n",
sweep_count, sweep_rate);

if (byte_count == 0) {
exit_code = EXIT_FAILURE;
fprintf(stderr, "\nCouldn't transfer any data for one second.\n");
break;
if (TimevalDiff(&time_now, &time_prev) >= 1.0f) {
time_difference = TimevalDiff(&time_now, &t_start);
sweep_rate = (float)sweep_count / time_difference;
fprintf(stderr, "%" PRIu64 " total sweeps completed, %.2f sweeps/second\n",
sweep_count, sweep_rate);

if (byte_count == 0) {
exit_code = EXIT_FAILURE;
fprintf(stderr, "\nCouldn't transfer any data for one second.\n");
break;
}
byte_count = 0;
time_prev = time_now;
}
byte_count = 0;
}

result = hackrf_is_streaming(device);
Expand Down

0 comments on commit 15b2d3a

Please sign in to comment.