SoDaRadio-5.0.3-master:8901fb5
USRPTuner.hxx
Go to the documentation of this file.
1 /*
2 Copyright (c) 2012, Matthew H. Reilly (kb1vc)
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8 
9  Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
37 
38 #ifndef USRPTUNER_HDR
39 #define USRPTUNER_HDR
40 #include "SoDaBase.hxx"
41 #include "Params.hxx"
42 
43 
44 #include <uhd/utils/thread_priority.hpp>
45 #include <uhd/utils/safe_main.hpp>
46 #include <uhd/usrp/multi_usrp.hpp>
47 #include <uhd/usrp/dboard_base.hpp>
48 #include <uhd/types/tune_request.hpp>
49 #include <uhd/types/tune_result.hpp>
50 #include <uhd/utils/msg.hpp>
51 
52 namespace SoDa {
53 
62  class USRPTuner : public Debug {
63  public:
69  USRPTuner(uhd::usrp::multi_usrp::sptr usrp,
70  double min_separation,
71  std::string unit_name = std::string("USRPTuner"));
72 
73 
81  USRPTuner * makeTuner(uhd::usrp::multi_usrp::sptr usrp,
82  double min_separation,
83  bool force_fracN = false,
84  bool force_simple = false);
85 
95  virtual bool setRXFreq(double rx_freq, double avoid_freq, uhd::tune_result_t & tune_result) = 0;
105  virtual bool setTXFreq(double tx_freq, double avoid_freq, uhd::tune_result_t & tune_result) = 0;
106 
107  protected:
114  virtual bool checkLock(uhd::tune_request_t & req,
115  char sel,
116  uhd::tune_result_t & cur);
117 
119  uhd::usrp::multi_usrp::sptr usrp;
121  };
122 
128  class IntNTuner : public USRPTuner {
129  public:
134  IntNTuner(uhd::usrp::multi_usrp::sptr usrp,
135  double min_separation) :
136  USRPTuner(usrp, min_separation, std::string("IntNTuner"))
137  {
138  initTuner();
139  }
140 
150  bool setRXFreq(double rx_freq, double avoid_freq, uhd::tune_result_t & tune_result);
151 
161  virtual bool setTXFreq(double tx_freq, double avoid_freq, uhd::tune_result_t & tune_result);
162 
163  private:
164  void initTuner();
165  };
166 
174  class SimpleTuner : public USRPTuner {
175  public:
178  SimpleTuner(uhd::usrp::multi_usrp::sptr usrp) :
179  USRPTuner(usrp, 0.0, std::string("IntNTuner"))
180  {
181  initTuner();
182  }
183 
193  bool setRXFreq(double rx_freq, double avoid_freq, uhd::tune_result_t & tune_result)
194  {
195  uhd::tune_request_t rx_req(rx_freq);
196  tune_result = usrp->set_rx_freq(rx_req);
197  // no need to check lock.
198  return true;
199  }
200 
210  bool setTXFreq(double tx_freq, double avoid_freq, uhd::tune_result_t & tune_result)
211  {
212  uhd::tune_request_t tx_req(tx_freq);
213  tune_result = usrp->set_tx_freq(tx_req);
214  // no need to check lock.
215  return true;
216  }
217 
218  private:
219  void initTuner() {
220  // do nothing.
221  }
222  };
223 
224 }
225 #endif
The Baseclass for all SoDa objects, and useful commonly used classes.
virtual bool setRXFreq(double rx_freq, double avoid_freq, uhd::tune_result_t &tune_result)=0
setRXFreq set the RX 1st LO frequency.
virtual bool setTXFreq(double tx_freq, double avoid_freq, uhd::tune_result_t &tune_result)=0
setTXFreq set the TX 1st LO frequency.
std::string unit_name
the name of the unit reporting status
Definition: Debug.hxx:98
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...
Definition: USRPTuner.cxx:121
STL namespace.
double min_separation
Definition: USRPTuner.hxx:118
This is a simple front end tuner.
Definition: USRPTuner.hxx:174
A simple base class to provide debug messaging from any derived class.
Definition: Debug.hxx:42
USRPTuner * makeTuner(uhd::usrp::multi_usrp::sptr usrp, double min_separation, bool force_fracN=false, bool force_simple=false)
Factory to build a particular subclass of USRPTuner based on the detected front-end module...
uhd::usrp::multi_usrp::sptr usrp
Definition: USRPTuner.hxx:119
SimpleTuner(uhd::usrp::multi_usrp::sptr usrp)
Constructor –.
Definition: USRPTuner.hxx:178
bool setRXFreq(double rx_freq, double avoid_freq, uhd::tune_result_t &tune_result)
setRXFreq set the RX 1st LO frequency.
Definition: USRPTuner.hxx:193
IntNTuner(uhd::usrp::multi_usrp::sptr usrp, double min_separation)
Constructor –.
Definition: USRPTuner.hxx:134
USRPTuner(uhd::usrp::multi_usrp::sptr usrp, double min_separation, std::string unit_name=std::string("USRPTuner"))
Constructor –.
Definition: USRPTuner.cxx:57
Generic class for TX and RX tuning.
Definition: USRPTuner.hxx:62
bool setTXFreq(double tx_freq, double avoid_freq, uhd::tune_result_t &tune_result)
setTXFreq set the TX 1st LO frequency.
Definition: USRPTuner.hxx:210
This is a tuner for the UBX, WBX, or SBX module that takes advantage of the int_n_step argument in th...
Definition: USRPTuner.hxx:128