diff options
Diffstat (limited to 'OutputUHD.cpp')
-rw-r--r-- | OutputUHD.cpp | 48 |
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; } |