/*********************************************************************** * Tune RX and TX routine **********************************************************************/ static double tune_rx_and_tx(uhd::usrp::multi_usrp::sptr usrp, const double tx_lo_freq, const double rx_offset) { //tune the transmitter with no cordic uhd::tune_request_t tx_tune_req(tx_lo_freq); tx_tune_req.dsp_freq_policy = uhd::tune_request_t::POLICY_MANUAL; tx_tune_req.dsp_freq = 0; usrp->set_tx_freq(tx_tune_req); //tune the receiver double rx_freq = usrp->get_tx_freq() - rx_offset; double min_fe_rx_freq = usrp->get_fe_rx_freq_range().start(); double max_fe_rx_freq = usrp->get_fe_rx_freq_range().stop(); uhd::tune_request_t rx_tune_req(rx_freq); rx_tune_req.dsp_freq_policy = uhd::tune_request_t::POLICY_MANUAL; rx_tune_req.dsp_freq = 0; if (rx_freq < min_fe_rx_freq) rx_tune_req.dsp_freq = rx_freq - min_fe_rx_freq; else if (rx_freq > max_fe_rx_freq) rx_tune_req.dsp_freq = rx_freq - max_fe_rx_freq; usrp->set_rx_freq(rx_tune_req); //wait for the LOs to become locked boost::this_thread::sleep(boost::posix_time::milliseconds(50)); boost::system_time start = boost::get_system_time(); while (not usrp->get_tx_sensor("lo_locked").to_bool() or not usrp->get_rx_sensor("lo_locked").to_bool()) { if (boost::get_system_time() > start + boost::posix_time::milliseconds(100)) throw std::runtime_error("timed out waiting for TX and/or RX LO to lock"); } return usrp->get_tx_freq(); }
/*********************************************************************** * Tune RX and TX routine **********************************************************************/ static double tune_rx_and_tx( uhd::usrp::multi_usrp::sptr usrp, const double tx_lo_freq, const double rx_offset) { // tune the transmitter with no cordic uhd::tune_request_t tx_tune_req(tx_lo_freq); tx_tune_req.dsp_freq_policy = uhd::tune_request_t::POLICY_MANUAL; tx_tune_req.dsp_freq = 0; usrp->set_tx_freq(tx_tune_req); // tune the receiver double rx_freq = usrp->get_tx_freq() - rx_offset; double min_fe_rx_freq = usrp->get_fe_rx_freq_range().start(); double max_fe_rx_freq = usrp->get_fe_rx_freq_range().stop(); uhd::tune_request_t rx_tune_req(rx_freq); rx_tune_req.dsp_freq_policy = uhd::tune_request_t::POLICY_MANUAL; rx_tune_req.dsp_freq = 0; if (rx_freq < min_fe_rx_freq) rx_tune_req.dsp_freq = rx_freq - min_fe_rx_freq; else if (rx_freq > max_fe_rx_freq) rx_tune_req.dsp_freq = rx_freq - max_fe_rx_freq; usrp->set_rx_freq(rx_tune_req); wait_for_lo_lock(usrp); return usrp->get_tx_freq(); }
bool uhd_device::setTxFreq(double wFreq) { uhd::tune_result_t tr = usrp_dev->set_tx_freq(wFreq); LOG(INFO) << "\n" << tr.to_pp_string(); tx_freq = usrp_dev->get_tx_freq(); return true; }
int setup_device(uhd::usrp::multi_usrp::sptr usrp, double rx_gain, double tx_gain, double freq, double rate){ //create a usrp device std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl; usrp->set_rx_rate(rate); usrp->set_rx_freq(freq); usrp->set_rx_gain(rx_gain); usrp->set_tx_rate(rate); usrp->set_tx_freq(freq); usrp->set_tx_gain(tx_gain); }
void init_usrp() { cout << "Initial USRP" << endl; usrp = uhd::usrp::multi_usrp::make(usrp_ip); usrp->set_rx_rate(rate); usrp->set_tx_rate(rate); usrp->set_rx_freq(freq); usrp->set_tx_freq(freq); usrp->set_rx_gain(gain); uhd::meta_range_t rx_range = usrp->get_rx_gain_range(); }
Uhd(const std::vector<size_t> channels, const double tx_rate, const double tx_center_freq, const double tx_gain) { uhd::set_thread_priority_safe(); for(const auto ch : channels) { usrp = uhd::usrp::multi_usrp::make(std::string("")); usrp->set_clock_source("internal"); usrp->set_tx_rate(tx_rate, ch); usrp->set_tx_freq(uhd::tune_request_t(tx_center_freq), ch); usrp->set_tx_gain(tx_gain, ch); } usrp->set_time_now(uhd::time_spec_t(0.0)); }