aboutsummaryrefslogtreecommitdiffstats
path: root/OutputUHD.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-11-08 18:32:48 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-11-08 18:32:48 +0100
commitf02555f2f6631b03663cb02da6659e926db07db8 (patch)
tree3ac43a8a4ee75d2bd61ca1ed108e4fa9590452ec /OutputUHD.cpp
parent823043497a9fd59ac86e9596c56df8e692340974 (diff)
downloadodr-dpd-f02555f2f6631b03663cb02da6659e926db07db8.tar.gz
odr-dpd-f02555f2f6631b03663cb02da6659e926db07db8.tar.bz2
odr-dpd-f02555f2f6631b03663cb02da6659e926db07db8.zip
Replace manual correlation by FFT
Diffstat (limited to 'OutputUHD.cpp')
-rw-r--r--OutputUHD.cpp48
1 files changed, 20 insertions, 28 deletions
diff --git a/OutputUHD.cpp b/OutputUHD.cpp
index fff3e15..6800daf 100644
--- a/OutputUHD.cpp
+++ b/OutputUHD.cpp
@@ -52,8 +52,12 @@ OutputUHD::OutputUHD(double txgain, double rxgain, double samplerate) :
m_usrp->set_rx_rate(m_samplerate);
m_usrp->set_tx_freq(234.208e6);
- double set_frequency = m_usrp->get_tx_freq();
- MDEBUG("OutputUHD:Actual frequency: %f\n", set_frequency);
+ double set_tx_frequency = m_usrp->get_tx_freq();
+ MDEBUG("OutputUHD:Actual TX frequency: %f\n", set_tx_frequency);
+
+ m_usrp->set_rx_freq(234.208e6);
+ double set_rx_frequency = m_usrp->get_rx_freq();
+ MDEBUG("OutputUHD:Actual RX frequency: %f\n", set_rx_frequency);
MDEBUG("OutputUHD:Setting TX Gain: %f ...\n", m_txgain);
m_usrp->set_tx_gain(m_txgain);
@@ -76,10 +80,8 @@ OutputUHD::OutputUHD(double txgain, double rxgain, double samplerate) :
myTxStream = m_usrp->get_tx_stream(stream_args);
myRxStream = m_usrp->get_rx_stream(stream_args);
- uhd::stream_cmd_t stream_cmd(true ?
- uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS:
- uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE
- );
+ uhd::stream_cmd_t stream_cmd(
+ uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
stream_cmd.num_samps = 0;
stream_cmd.stream_now = true;
stream_cmd.time_spec = uhd::time_spec_t();
@@ -115,33 +117,23 @@ size_t OutputUHD::Transmit(const complexf *samples, size_t sizeIn, double *first
size_t OutputUHD::Receive(complexf *samples, size_t sizeIn, double *first_sample_time)
{
const double rx_timeout = 20.0;
+ const size_t usrp_max_num_samps = myRxStream->get_max_num_samps();
+ const size_t samps_to_rx = std::min(sizeIn, usrp_max_num_samps);
uhd::rx_metadata_t md;
- size_t usrp_max_num_samps = myRxStream->get_max_num_samps();
-
- *first_sample_time = md.time_spec.get_real_secs();
+ size_t num_rx_samps = myRxStream->recv(samples, samps_to_rx, md, rx_timeout);
- size_t num_acc_samps = 0; //number of accumulated samples
- while (num_acc_samps < sizeIn) {
- size_t samps_to_send = std::min(sizeIn - num_acc_samps, usrp_max_num_samps);
+ if (md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE){
+ MDEBUG("RX Error %s\n", md.strerror().c_str());
+ }
- //send a single packet
- size_t num_rx_samps = myRxStream->recv(
- &samples[num_acc_samps],
- samps_to_send, md, rx_timeout);
-
- if (num_acc_samps == 0) {
- if (md.has_time_spec) {
- *first_sample_time = md.time_spec.get_real_secs();
- }
- else {
- MDEBUG("samp %zu no time spec!\n", num_acc_samps);
- }
- }
-
- num_acc_samps += num_rx_samps;
+ if (md.has_time_spec) {
+ *first_sample_time = md.time_spec.get_real_secs();
+ }
+ else {
+ *first_sample_time = 0;
}
- return num_acc_samps;
+ return num_rx_samps;
}