31 #include <uhd/utils/thread_priority.hpp> 32 #include <uhd/utils/safe_main.hpp> 33 #include <uhd/usrp/multi_usrp.hpp> 34 #include <uhd/usrp/multi_usrp.hpp> 35 #include <uhd/utils/msg.hpp> 36 #include <uhd/types/tune_request.hpp> 37 #include <uhd/types/tune_result.hpp> 38 #include <boost/format.hpp> 41 double min_separation,
45 bool choose_simple = force_simple;
52 if(choose_simple)
return new SimpleTuner(usrp);
53 else return IntNTuner(usrp, min_separation, force_fracN);
63 std::vector<std::string> sensor_names =
usrp->get_rx_sensor_names(0);
64 has_lock_detect = std::find(sensor_names.begin(), sensor_names.end(),
"lo_locked") != sensor_names.end();
69 double target_rx_freq = 100e3 * floor(rx_freq / 100.0e3);
70 while((rx_freq - target_rx_freq) < 100.0e3) {
71 target_rx_freq -= 100.0e3;
74 uhd::tune_request_t rx_trequest(target_rx_freq);
75 rx_trequest.target_freq = target_rx_freq;
76 rx_trequest.rf_freq = target_rx_freq;
77 rx_trequest.rf_freq_policy = uhd::tune_request_t::POLICY_AUTO;
78 rx_trequest.dsp_freq_policy = uhd::tune_request_t::POLICY_AUTO;
80 tune_result =
usrp->set_rx_freq(rx_trequest);
82 debugMsg(boost::format(
"USRPTuner: RX Tune RF_actual %lf DDC = %lf tuned = %lf target = %lf request rf = %lf request ddc = %lf\n")
83 % tune_result.actual_rf_freq
84 % tune_result.actual_dsp_freq
88 % rx_trequest.dsp_freq);
90 return checkLock(rx_trequest,
'r', tune_result);
102 uhd::tune_request_t tx_request(tx_freq);
104 tx_request.rf_freq_policy = uhd::tune_request_t::POLICY_AUTO;
106 debugMsg(boost::format(
"Tuning TX unit to new frequency %f (request = %f (%f %f))\n")
107 % tx_freq % tx_request.target_freq % tx_request.rf_freq % tx_request.dsp_freq);
109 tune_result =
usrp->set_tx_freq(tx_request);
111 debugMsg(boost::format(
"Tuned TX unit to new frequency %g t.rf %g a.rf %g t.dsp %g a.dsp %g\n")
113 % tune_result.target_rf_freq
114 % tune_result.actual_rf_freq
115 % tune_result.target_dsp_freq
116 % tune_result.actual_dsp_freq);
118 return checkLock(tx_request,
't', tune_result);
123 uhd::tune_result_t & cur)
125 int lock_itercount = 0;
126 uhd::tune_result_t ret = cur;
132 uhd::sensor_value_t lo_locked = (sel ==
'r') ?
usrp->get_rx_sensor(
"lo_locked",0) :
usrp->get_tx_sensor(
"lo_locked",0);
133 if(lo_locked.to_bool())
break;
135 if((lock_itercount & 0xfff) == 0) {
136 debugMsg(boost::format(
"Waiting for %c LO lock to freq = %f (%f:%f) count = %d\n")
137 % sel % req.target_freq % req.rf_freq % req.dsp_freq % lock_itercount);
138 if(sel ==
'r') ret =
usrp->set_rx_freq(req);
139 else ret =
usrp->set_tx_freq(req);
The Baseclass for all SoDa objects, and useful commonly used classes.
void debugMsg(const std::string &msg, unsigned int threshold=1)
virtual bool setTXFreq(double tx_freq, double avoid_freq, uhd::tune_result_t &tune_result)
setTXFreq set the TX 1st LO frequency.
virtual bool checkLock(uhd::tune_request_t &req, char sel, uhd::tune_result_t &cur)
is the identified (rx or tx) front-end LO locked? If not, set the tuning frequency to "the right thin...
Class that encapsulates tuning functions for various daughter cards.
bool setRXFreq(double rx_freq, double avoid_freq, uhd::tune_result_t &tune_result)
setRXFreq set the RX 1st LO frequency.
A simple base class to provide debug messaging from any derived class.
SoDa::USRPTuner::USRPTuner * makeTuner(uhd::usrp::multi_usrp::sptr usrp, double min_separation, bool force_fracN, bool force_simple)
uhd::usrp::multi_usrp::sptr usrp
USRPTuner(uhd::usrp::multi_usrp::sptr usrp, double min_separation, std::string unit_name=std::string("USRPTuner"))
Constructor –.