hackrf_sweep: switch main loop timing back to 1Hz
fixes #850 fixes #851
This commit is contained in:
@ -393,6 +393,7 @@ int main(int argc, char** argv) {
|
|||||||
const char* serial_number = NULL;
|
const char* serial_number = NULL;
|
||||||
int exit_code = EXIT_SUCCESS;
|
int exit_code = EXIT_SUCCESS;
|
||||||
struct timeval time_now;
|
struct timeval time_now;
|
||||||
|
struct timeval time_prev;
|
||||||
float time_diff;
|
float time_diff;
|
||||||
float sweep_rate;
|
float sweep_rate;
|
||||||
unsigned int lna_gain=16, vga_gain=20;
|
unsigned int lna_gain=16, vga_gain=20;
|
||||||
@ -702,6 +703,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gettimeofday(&t_start, NULL);
|
gettimeofday(&t_start, NULL);
|
||||||
|
time_prev = t_start;
|
||||||
|
|
||||||
fprintf(stderr, "Stop with Ctrl-C\n");
|
fprintf(stderr, "Stop with Ctrl-C\n");
|
||||||
while((hackrf_is_streaming(device) == HACKRF_TRUE) && (do_exit == false)) {
|
while((hackrf_is_streaming(device) == HACKRF_TRUE) && (do_exit == false)) {
|
||||||
@ -709,18 +711,20 @@ int main(int argc, char** argv) {
|
|||||||
m_sleep(50);
|
m_sleep(50);
|
||||||
|
|
||||||
gettimeofday(&time_now, NULL);
|
gettimeofday(&time_now, NULL);
|
||||||
|
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);
|
||||||
|
|
||||||
time_difference = TimevalDiff(&time_now, &t_start);
|
if (byte_count == 0) {
|
||||||
sweep_rate = (float)sweep_count / time_difference;
|
exit_code = EXIT_FAILURE;
|
||||||
fprintf(stderr, "%" PRIu64 " total sweeps completed, %.2f sweeps/second\n",
|
fprintf(stderr, "\nCouldn't transfer any data for one second.\n");
|
||||||
sweep_count, sweep_rate);
|
break;
|
||||||
|
}
|
||||||
if (byte_count == 0) {
|
byte_count = 0;
|
||||||
exit_code = EXIT_FAILURE;
|
time_prev = time_now;
|
||||||
fprintf(stderr, "\nCouldn't transfer any data for one second.\n");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
byte_count = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = hackrf_is_streaming(device);
|
result = hackrf_is_streaming(device);
|
||||||
|
Reference in New Issue
Block a user