update timestamp once per sweep

This commit is contained in:
Michael Ossmann
2017-02-16 17:34:38 -07:00
parent d794ac0e20
commit bc49bdc344

View File

@ -165,6 +165,7 @@ volatile uint32_t byte_count = 0;
struct timeval time_start; struct timeval time_start;
struct timeval t_start; struct timeval t_start;
struct timeval time_stamp;
bool amp = false; bool amp = false;
uint32_t amp_enable; uint32_t amp_enable;
@ -199,7 +200,6 @@ int rx_callback(hackrf_transfer* transfer) {
uint64_t band_edge; uint64_t band_edge;
uint32_t record_length; uint32_t record_length;
int i, j; int i, j;
struct timeval time_stamp;
struct tm *fft_time; struct tm *fft_time;
char time_str[50]; char time_str[50];
@ -207,13 +207,9 @@ int rx_callback(hackrf_transfer* transfer) {
return -1; return -1;
} }
gettimeofday(&time_stamp, NULL);
byte_count += transfer->valid_length; byte_count += transfer->valid_length;
buf = (int8_t*) transfer->buffer; buf = (int8_t*) transfer->buffer;
for(j=0; j<BLOCKS_PER_TRANSFER; j++) { for(j=0; j<BLOCKS_PER_TRANSFER; j++) {
if(do_exit) {
return 0;
}
ubuf = (uint8_t*) buf; ubuf = (uint8_t*) buf;
if(ubuf[0] == 0x7F && ubuf[1] == 0x7F) { if(ubuf[0] == 0x7F && ubuf[1] == 0x7F) {
frequency = ((uint64_t)(ubuf[9]) << 56) | ((uint64_t)(ubuf[8]) << 48) | ((uint64_t)(ubuf[7]) << 40) frequency = ((uint64_t)(ubuf[9]) << 56) | ((uint64_t)(ubuf[8]) << 48) | ((uint64_t)(ubuf[7]) << 40)
@ -223,14 +219,20 @@ int rx_callback(hackrf_transfer* transfer) {
buf += BYTES_PER_BLOCK; buf += BYTES_PER_BLOCK;
continue; continue;
} }
if(!sweep_started) {
if (frequency == (uint64_t)(FREQ_ONE_MHZ*frequencies[0])) { if (frequency == (uint64_t)(FREQ_ONE_MHZ*frequencies[0])) {
if(one_shot && sweep_started) {
do_exit = true;
}
sweep_started = true; sweep_started = true;
} else { gettimeofday(&time_stamp, NULL);
}
if(do_exit) {
return 0;
}
if(!sweep_started) {
buf += BYTES_PER_BLOCK; buf += BYTES_PER_BLOCK;
continue; continue;
} }
}
if((FREQ_MAX_MHZ * FREQ_ONE_MHZ) < frequency) { if((FREQ_MAX_MHZ * FREQ_ONE_MHZ) < frequency) {
buf += BYTES_PER_BLOCK; buf += BYTES_PER_BLOCK;
continue; continue;
@ -289,10 +291,6 @@ int rx_callback(hackrf_transfer* transfer) {
} }
fprintf(fd, "\n"); fprintf(fd, "\n");
} }
if(one_shot && ((uint64_t)(frequency+((DEFAULT_SAMPLE_RATE_HZ*3)/4))
>= (uint64_t)(FREQ_ONE_MHZ*frequencies[num_ranges*2-1]))) {
do_exit = true;
}
} }
return 0; return 0;
} }