hackrf_sweep: eliminate time stamp adjustment
We previously attempted to adjust the output time stamp according to the sample rate and placement of the samples within the USB transfer data, but the end result was a fixed time offset with respect to the time of USB transfer completion. We are using only those samples closest to the end of the transfer, so it makes sense to simply use the time the USB transfer ends and not try to correct that fixed offset. It may be possible in the future to have a more accurate time stamp generated in firmware, but I don't think it is worth complicating the host code with minor time adjustments until and unless firmware-based time stamps become available.
This commit is contained in:
@ -171,7 +171,6 @@ volatile uint64_t sweep_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;
|
||||||
@ -257,14 +256,6 @@ int rx_callback(hackrf_transfer* transfer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sweep_started = true;
|
sweep_started = true;
|
||||||
time_stamp = usb_transfer_time;
|
|
||||||
time_stamp.tv_usec +=
|
|
||||||
(uint64_t)(num_samples + THROWAWAY_BLOCKS * SAMPLES_PER_BLOCK)
|
|
||||||
* j * FREQ_ONE_MHZ / DEFAULT_SAMPLE_RATE_HZ;
|
|
||||||
if(999999 < time_stamp.tv_usec) {
|
|
||||||
time_stamp.tv_sec += time_stamp.tv_usec / 1000000;
|
|
||||||
time_stamp.tv_usec = time_stamp.tv_usec % 1000000;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(do_exit) {
|
if(do_exit) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -320,12 +311,12 @@ int rx_callback(hackrf_transfer* transfer) {
|
|||||||
ifftwIn[ifft_idx + i][1] = fftwOut[i + 1 + (fftSize/8)][1];
|
ifftwIn[ifft_idx + i][1] = fftwOut[i + 1 + (fftSize/8)][1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
time_t time_stamp_seconds = time_stamp.tv_sec;
|
time_t time_stamp_seconds = usb_transfer_time.tv_sec;
|
||||||
fft_time = localtime(&time_stamp_seconds);
|
fft_time = localtime(&time_stamp_seconds);
|
||||||
strftime(time_str, 50, "%Y-%m-%d, %H:%M:%S", fft_time);
|
strftime(time_str, 50, "%Y-%m-%d, %H:%M:%S", fft_time);
|
||||||
fprintf(outfile, "%s.%06ld, %" PRIu64 ", %" PRIu64 ", %.2f, %u",
|
fprintf(outfile, "%s.%06ld, %" PRIu64 ", %" PRIu64 ", %.2f, %u",
|
||||||
time_str,
|
time_str,
|
||||||
(long int)time_stamp.tv_usec,
|
(long int)usb_transfer_time.tv_usec,
|
||||||
(uint64_t)(frequency),
|
(uint64_t)(frequency),
|
||||||
(uint64_t)(frequency+DEFAULT_SAMPLE_RATE_HZ/4),
|
(uint64_t)(frequency+DEFAULT_SAMPLE_RATE_HZ/4),
|
||||||
fft_bin_width,
|
fft_bin_width,
|
||||||
@ -336,7 +327,7 @@ int rx_callback(hackrf_transfer* transfer) {
|
|||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
fprintf(outfile, "%s.%06ld, %" PRIu64 ", %" PRIu64 ", %.2f, %u",
|
fprintf(outfile, "%s.%06ld, %" PRIu64 ", %" PRIu64 ", %.2f, %u",
|
||||||
time_str,
|
time_str,
|
||||||
(long int)time_stamp.tv_usec,
|
(long int)usb_transfer_time.tv_usec,
|
||||||
(uint64_t)(frequency+(DEFAULT_SAMPLE_RATE_HZ/2)),
|
(uint64_t)(frequency+(DEFAULT_SAMPLE_RATE_HZ/2)),
|
||||||
(uint64_t)(frequency+((DEFAULT_SAMPLE_RATE_HZ*3)/4)),
|
(uint64_t)(frequency+((DEFAULT_SAMPLE_RATE_HZ*3)/4)),
|
||||||
fft_bin_width,
|
fft_bin_width,
|
||||||
|
Reference in New Issue
Block a user