/*********************************************************************** * Tune RX and TX routine **********************************************************************/ static double tune_rx_and_tx(uhd::usrp::multi_usrp::sptr usrp, const double rx_lo_freq, const double tx_offset) { //tune the receiver with no cordic uhd::tune_request_t rx_tune_req(rx_lo_freq); rx_tune_req.dsp_freq_policy = uhd::tune_request_t::POLICY_MANUAL; rx_tune_req.dsp_freq = 0; usrp->set_rx_freq(rx_tune_req); //tune the transmitter double tx_freq = usrp->get_rx_freq() + tx_offset; double min_fe_tx_freq = usrp->get_fe_tx_freq_range().start(); double max_fe_tx_freq = usrp->get_fe_tx_freq_range().stop(); uhd::tune_request_t tx_tune_req(tx_freq); tx_tune_req.dsp_freq_policy = uhd::tune_request_t::POLICY_MANUAL; tx_tune_req.dsp_freq = 0; if (tx_freq < min_fe_tx_freq) tx_tune_req.dsp_freq = tx_freq - min_fe_tx_freq; else if (tx_freq > max_fe_tx_freq) tx_tune_req.dsp_freq = tx_freq - max_fe_tx_freq; usrp->set_tx_freq(tx_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_rx_freq(); }
std::string coercion_test(uhd::usrp::multi_usrp::sptr usrp, std::string type, int chan, bool test_gain, double freq_step, double gain_step, bool verbose){ //Getting USRP info uhd::dict<std::string, std::string> usrp_info = (type == "TX") ? usrp->get_usrp_tx_info(chan) : usrp->get_usrp_rx_info(chan); std::string subdev_name = (type == "TX") ? usrp_info.get("tx_subdev_name") : usrp_info.get("rx_subdev_name"); std::string subdev_spec = (type == "TX") ? usrp_info.get("tx_subdev_spec") : usrp_info.get("rx_subdev_spec"); //Establish frequency range std::vector<double> freqs; std::vector<double> xcvr_freqs; //XCVR2450 has two ranges uhd::freq_range_t freq_ranges = (type == "TX") ? usrp->get_fe_tx_freq_range(chan) : usrp->get_fe_rx_freq_range(chan); std::cout << boost::format("\nTesting %s coercion...") % type << std::endl; BOOST_FOREACH(const uhd::range_t &range, freq_ranges){ double freq_begin = range.start(); double freq_end = range.stop(); if(subdev_name.find("XCVR2450") == 0){ xcvr_freqs.push_back(freq_begin); xcvr_freqs.push_back(freq_end); } double current_freq = freq_begin; while(current_freq < freq_end){ freqs.push_back(current_freq); current_freq += freq_step; } if(freq_end != *freqs.end()) freqs.push_back(freq_end); }
void get_tx_parameters(uhd::usrp::multi_usrp::sptr usrp, size_t mboard, std::ostream & os) { using namespace std; namespace radio = uhd::usrp; size_t nchan = 0; // CONFIGURATION SUB_DEVICE os << std::endl << "********** TX Sub Device ***********" << std::endl; // Get sub device specification os << std::endl << "-----> Get TX Subdevice" << std::endl; try { os << "TX Subdevice Specification: "; radio::subdev_spec_t tx_subdev = usrp->get_tx_subdev_spec(mboard); os << tx_subdev.to_pp_string() << endl; } catch(uhd::runtime_error &e) { os << " Exception occurred : " << e.code() << endl; } // Number of tx channels os << std::endl << "-----> Get number of TX channels" << std::endl; try { size_t num_tx = usrp->get_tx_num_channels(); os << "Number of TX channels: " ; os << num_tx << endl; } catch (uhd::runtime_error &e) { os << " Exception occurred : " << e.code() << endl; } // TX Device Name os << std::endl << "-----> Get TX Subdevice Name" << std::endl; try { os << "TX Subdevice Name: "; string tx_name = usrp->get_tx_subdev_name(nchan); os << tx_name << endl; } catch (uhd::runtime_error &e) { os << " Exception occurred : " << e.code() << endl; } // TX SAMPLE RATE os << std::endl << "********** TX Sample Rate ***********" << std::endl; // Get Current TX rate os << std::endl << "-----> Get TX Rate" << std::endl; try { os << "TX Rate: " ; double tx_rate = usrp->get_tx_rate(nchan); os << tx_rate << endl; } catch (uhd::runtime_error &e) { os << " Exception occurred : " << e.code() << endl; } // Get list of TX rates os << std::endl << "-----> Get TX Rate List" << std::endl; try { os << "TX Rate List: " ; uhd::meta_range_t tx_rates = usrp->get_tx_rates(nchan); os << "Start: " << tx_rates.start() << " Stop: " << tx_rates.stop() << " Step: " << tx_rates.step() << endl; os << tx_rates.to_pp_string() << endl; } catch (uhd::runtime_error &e) { os << " Exception occurred : " << e.code() << endl; } // TX FREQUENCIES os << std::endl << "********** TX Frequencies ***********" << std::endl; // Current TX frequency os << std::endl << "-----> Get TX Center Frequency" << std::endl; try { os << "TX Freq: "; double tx_freq = usrp->get_tx_freq(nchan); os << tx_freq << endl; } catch (uhd::runtime_error &e) { os << " Exception occurred : " << e.code() << endl; } // TX Frequency Range os << std::endl << "-----> Get TX Center Frequency Range" << std::endl; try { os << "TX Frequency Range: "; uhd::freq_range_t tx_freq_range = usrp->get_tx_freq_range(nchan); os << "Start: " << tx_freq_range.start() << " Stop: " << tx_freq_range.stop() << " Step: " << tx_freq_range.step() << endl; os << tx_freq_range.to_pp_string() << endl; } catch (uhd::runtime_error &e) { os << " Exception occurred : " << e.code() << endl; } // Front end TX frequency range os << std::endl << "-----> Get TX RF Front End Center Frequency Range" << std::endl; try { os << "TX Front End Frequency Range: "; uhd::freq_range_t tx_fe_freq_range = usrp->get_fe_tx_freq_range(nchan); os << "Start: " << tx_fe_freq_range.start() << " Stop: " << tx_fe_freq_range.stop() << " Step: " << tx_fe_freq_range.step() << endl; os << tx_fe_freq_range.to_pp_string() << endl; } catch (uhd::runtime_error &e) { os << " Exception occurred : " << e.code() << endl; } // TX GAIN os << std::endl << "********** TX Gain ***********" << std::endl; // Total combined gain os << endl << "-----> Get TX Total Gain" << endl; os << "TX Total Gain: " ; try { double tx_total_gain = usrp->get_tx_gain(nchan); os << tx_total_gain << endl; } catch(uhd::runtime_error &e) { os << "Exception code: " << e.code() << endl; } // List of all gain elements os << std::endl << "-----> Get TX gain names" << std::endl; std::vector<std::string> tx_gain_names = usrp->get_tx_gain_names(nchan); os << "Tx Gain Names: " << std::endl; for (int index =0; index < tx_gain_names.size(); index++) { // Name os << "\t" << tx_gain_names[index] << endl; } for (int index =0; index < tx_gain_names.size(); index++) { // Name os << "\t" << "Name: " << tx_gain_names[index] << " Value: "; // Value try { double element_gain = usrp->get_tx_gain(tx_gain_names[index], nchan); os << element_gain << endl; } catch(uhd::runtime_error &e) { os << "Exception code while getting value: " << e.code() << endl; } } // Gain ranges for each of the gain elements os << std::endl << "-----> Get TX element gain ranges" << std::endl; for (int index =0; index < tx_gain_names.size(); index++) { // Name os << "\t" << "Name: " << tx_gain_names[index] << " Value: "; // Value try { uhd::gain_range_t element_gain_range = usrp->get_tx_gain_range(tx_gain_names[index], nchan); os << "Start: " << element_gain_range.start() << " End: " << element_gain_range.stop() << " Step: " << element_gain_range.step() << endl; } catch(uhd::runtime_error &e) { os << "Exception code while getting value: " << e.code() << endl; } } // Total Gain range try { os << endl << "-----> Get TX Total Gain Range" << endl; uhd::gain_range_t tx_total_gain_range = usrp->get_tx_gain_range(nchan); os << "TX Total Gain Range: " ; os << "Start: " << tx_total_gain_range.start() << " End: " << tx_total_gain_range.stop() << " Step: " << tx_total_gain_range.step() << endl; } catch(uhd::runtime_error &e) { os << "Exception code: " << e.code() <<endl; } // ANTENNA FUNCTIONS os << std::endl << "********** TX ANTENNA ***********" << std::endl; // Current Tx Antenna os << std::endl << "-----> Get TX Antenna" << std::endl; try { os << "TX Antenna: " ; string tx_antenna = usrp->get_tx_antenna(nchan); os << tx_antenna << endl; } catch(uhd::runtime_error &e) { os << "Exception code: " << e.code() <<endl; } // TX Antenna choices os << std::endl << "-----> Get Tx Antenna List" << std::endl; try { os << "TX Antennas : " << std::endl; std::vector<std::string> tx_antennas = usrp->get_tx_antennas(nchan); for (int index =0; index < tx_antennas.size(); index++) os << "\t" << tx_antennas[index] << std::endl; } catch(uhd::runtime_error &e) { os << "Exception code: " << e.code() <<endl; } // TX BANDWIDTH FUNCTIONS os << std::endl << "********** TX BANDWIDTH ***********" << std::endl; // Current TX Bandwidth os << endl << "-----> Get TX Bandwidth" << endl; try { os << "TX Bandwidth " ; double tx_bandwidth = usrp->get_tx_bandwidth(nchan); os << tx_bandwidth << endl; } catch (uhd::runtime_error &e) { os << "Exception occured " << e.code() << endl; } // TX Bandwidth Range os << endl << "-----> Get TX Bandwidth Range" << endl; try { os << "TX Bandwidth Range: " ; uhd::gain_range_t tx_bandwidth_range = usrp->get_tx_bandwidth_range(nchan); os << "Start: " << tx_bandwidth_range .start() << " End: " << tx_bandwidth_range .stop() << " Step: " << tx_bandwidth_range .step() << endl; } catch(uhd::runtime_error &e) { os << "Exception code: " << e.code() <<endl; } // TX DBOARD INTERFACE OBJECT os << std::endl << "********** TX DBOARD INTERFACE ***********" << std::endl; // TX Dboard Interface os << endl << "-----> Get tx_dboard_iface()" << endl; try { os << "TX Dboard Interface " ; uhd::usrp::dboard_iface::sptr tx_dboard_iface = usrp->get_tx_dboard_iface(nchan); os << tx_dboard_iface << endl; } catch (uhd::runtime_error &e) { os << "Exception occured " << e.code() << endl; } // TX _SENSORS os << std::endl << "********** TX Sensors ***********" << std::endl; // List of all available sensors os << std::endl << "-----> Get TX Sensors Name" << std::endl; std::vector<std::string> tx_sensor_names = usrp->get_tx_sensor_names(nchan); os << "Sensor Names: " << std::endl; for (int index =0; index < tx_sensor_names.size(); index++) { // Name os << "\t" << tx_sensor_names[index] << ": "; // Value try { uhd::sensor_value_t tx_sensor_value = usrp->get_tx_sensor(tx_sensor_names[index], nchan); os << tx_sensor_value.to_pp_string()<< std::endl; } catch(uhd::runtime_error &e) { os << "Exception occured " << e.code() << endl; } } }