aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-11-08 20:50:37 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-11-08 20:50:37 +0100
commit22eb9a40a48c24c2794b07f96729ce49697ef298 (patch)
treed4a22e995e52e2e1b9f8ce7749a1f8b9fbad9296 /main.cpp
parent623bf9af76e7400900561ef8011774524c001f66 (diff)
downloadodr-dpd-22eb9a40a48c24c2794b07f96729ce49697ef298.tar.gz
odr-dpd-22eb9a40a48c24c2794b07f96729ce49697ef298.tar.bz2
odr-dpd-22eb9a40a48c24c2794b07f96729ce49697ef298.zip
Reset receive timestamps on error
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/main.cpp b/main.cpp
index cd3d96c..d2ab5f8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -68,13 +68,20 @@ size_t do_receive(OutputUHD* output_uhd)
MDEBUG("Starting do_receive\n");
while (running) {
- size_t received = output_uhd->Receive(&samps.front(), samps.size(), &first_sample_time);
- aligner.push_rx_samples(&samps.front(), received, first_sample_time);
- total_received += received;
-
- if (first_sample_time - last_print_time > 1) {
- //MDEBUG("Rx %zu samples at t=%f\n", received, first_sample_time);
- last_print_time = first_sample_time;
+ ssize_t received = output_uhd->Receive(&samps.front(), samps.size(), &first_sample_time);
+ if (received > 0) {
+ aligner.push_rx_samples(&samps.front(), received, first_sample_time);
+ total_received += received;
+
+ if (first_sample_time - last_print_time > 1) {
+ //MDEBUG("Rx %zu samples at t=%f\n", received, first_sample_time);
+ last_print_time = first_sample_time;
+ }
+ }
+ else {
+ // A receive error occurred that invalidates the RX timestamp
+ MDEBUG("Reset aligner RX\n");
+ aligner.reset_rx();
}
}
MDEBUG("Leaving do_receive\n");
@@ -126,6 +133,7 @@ void find_peak_correlation()
}
else {
MDEBUG("Waiting for correlation\n");
+ aligner.debug();
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
@@ -236,7 +244,6 @@ int main(int argc, char **argv)
OutputUHD output_uhd(txgain, rxgain, samplerate);
- std::vector<complexf> input_samples(samps_per_buffer);
size_t samps_read = 0;
size_t total_samps_read = samps_read;
@@ -255,6 +262,7 @@ int main(int argc, char **argv)
double first_sample_time = 0;
if (fd) {
+ std::vector<complexf> input_samples(samps_per_buffer);
samps_read = read_samples_from_file(fd, input_samples, samps_per_buffer);
sent = output_uhd.Transmit(&input_samples.front(), samps_read, &first_sample_time);
aligner.push_tx_samples(&input_samples.front(), samps_read, first_sample_time);