SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
USRPTuner.hxx
Go to the documentation of this file.
1/*
2Copyright (c) 2012, Matthew H. Reilly (kb1vc)
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are
7met:
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
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26OF 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.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
52namespace 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.
std::string unit_name
the name of the unit reporting status
Definition Debug.hxx:94
Debug(std::string _unit_name=std::string("UNKNOWN"))
Definition Debug.hxx:41
IntNTuner(uhd::usrp::multi_usrp::sptr usrp, double min_separation)
Constructor –.
virtual bool setTXFreq(double tx_freq, double avoid_freq, uhd::tune_result_t &tune_result)
setTXFreq set the TX 1st LO frequency.
bool setRXFreq(double rx_freq, double avoid_freq, uhd::tune_result_t &tune_result)
setRXFreq set the RX 1st LO frequency.
bool setRXFreq(double rx_freq, double avoid_freq, uhd::tune_result_t &tune_result)
setRXFreq set the RX 1st LO frequency.
SimpleTuner(uhd::usrp::multi_usrp::sptr usrp)
Constructor –.
bool setTXFreq(double tx_freq, double avoid_freq, uhd::tune_result_t &tune_result)
setTXFreq set the TX 1st LO frequency.
uhd::usrp::multi_usrp::sptr usrp
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.
double min_separation
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.
USRPTuner(uhd::usrp::multi_usrp::sptr usrp, double min_separation, std::string unit_name=std::string("USRPTuner"))
Constructor –.
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?