diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-05-12 11:23:15 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-05-12 11:23:15 +0200 |
commit | a656cee6c9c230bb921c6bb6be0f0180460a96b4 (patch) | |
tree | d4e0ad440feb27de00a22f8ccccb23d84be014b1 /src | |
parent | 201d2cd2e0431a5ea79fb69561c27555f3a03dc1 (diff) | |
download | dabmod-a656cee6c9c230bb921c6bb6be0f0180460a96b4.tar.gz dabmod-a656cee6c9c230bb921c6bb6be0f0180460a96b4.tar.bz2 dabmod-a656cee6c9c230bb921c6bb6be0f0180460a96b4.zip |
DPD: handle incomplete frames
Diffstat (limited to 'src')
-rw-r--r-- | src/OutputUHD.cpp | 2 | ||||
-rw-r--r-- | src/OutputUHDFeedback.cpp | 25 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index 6edf7df..5e9e17c 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -50,7 +50,7 @@ using namespace std; // Maximum number of frames that can wait in uwd.frames -static const size_t FRAMES_MAX_SIZE = 2; +static const size_t FRAMES_MAX_SIZE = 8; typedef std::complex<float> complexf; diff --git a/src/OutputUHDFeedback.cpp b/src/OutputUHDFeedback.cpp index 09b73ba..3ef5648 100644 --- a/src/OutputUHDFeedback.cpp +++ b/src/OutputUHDFeedback.cpp @@ -138,6 +138,8 @@ void OutputUHDFeedback::ReceiveBurstThread() if (not m_running) break; + etiLog.level(debug) << "Prepare RX stream command for " << burstRequest.num_samples; + uhd::stream_cmd_t cmd( uhd::stream_cmd_t::stream_mode_t::STREAM_MODE_NUM_SAMPS_AND_DONE); cmd.num_samps = burstRequest.num_samples; @@ -146,16 +148,28 @@ void OutputUHDFeedback::ReceiveBurstThread() double pps = burstRequest.rx_pps / 16384000.0; cmd.time_spec = uhd::time_spec_t(burstRequest.rx_second, pps); + const double usrp_time = m_usrp->get_time_now().get_real_secs(); + const double cmd_time = cmd.time_spec.get_real_secs(); + + etiLog.level(debug) << + "RX stream command ts=" << std::fixed << cmd_time << " Delta=" << cmd_time - usrp_time; + rxStream->issue_stream_cmd(cmd); uhd::rx_metadata_t md; burstRequest.rx_samples.resize(burstRequest.num_samples * sizeof(complexf)); - rxStream->recv(&burstRequest.rx_samples[0], burstRequest.num_samples, md); + size_t samples_read = rxStream->recv(&burstRequest.rx_samples[0], burstRequest.num_samples, md); + assert(samples_read <= burstRequest.num_samples); + burstRequest.rx_samples.resize(samples_read * sizeof(complexf)); // The recv might have happened at another time than requested burstRequest.rx_second = md.time_spec.get_full_secs(); burstRequest.rx_pps = md.time_spec.get_frac_secs() * 16384000.0; + etiLog.level(debug) << "Read " << samples_read << " RX feedback samples " + << "at time " << std::fixed << burstRequest.tx_second << "." << + burstRequest.tx_pps / 16384000.0; + burstRequest.state = BurstRequestState::Acquired; lock.unlock(); @@ -258,6 +272,11 @@ void OutputUHDFeedback::ServeFeedbackThread() burstRequest.state = BurstRequestState::None; lock.unlock(); + burstRequest.num_samples = std::min(burstRequest.num_samples, + std::min( + burstRequest.tx_samples.size() / sizeof(complexf), + burstRequest.rx_samples.size() / sizeof(complexf))); + if (send(client_sock, &burstRequest.num_samples, sizeof(burstRequest.num_samples), @@ -287,7 +306,7 @@ void OutputUHDFeedback::ServeFeedbackThread() const size_t frame_bytes = burstRequest.num_samples * sizeof(complexf); - assert(burstRequest.tx_samples.size() == frame_bytes); + assert(burstRequest.tx_samples.size() >= frame_bytes); if (send(client_sock, &burstRequest.tx_samples[0], frame_bytes, @@ -315,7 +334,7 @@ void OutputUHDFeedback::ServeFeedbackThread() break; } - assert(burstRequest.rx_samples.size() == frame_bytes); + assert(burstRequest.rx_samples.size() >= frame_bytes); if (send(client_sock, &burstRequest.rx_samples[0], frame_bytes, |