GNU Radio's SOAPY Package
source.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * gr-soapy: Soapy SDR Radio Out-Of-Tree Module
4  *
5  * Copyright (C) 2018
6  * Libre Space Foundation <http://librespacefoundation.org/>
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 
23 #ifndef INCLUDED_SOAPY_SOURCE_H
24 #define INCLUDED_SOAPY_SOURCE_H
25 
26 #include <soapy/api.h>
27 #include <gnuradio/sync_block.h>
28 #include <cstdint>
29 
30 namespace gr {
31 
32 
33 namespace soapy {
34 
35 /*!
36  * \addtogroup block
37  * \brief <b>Source</b> block implements SoapySDR functionality for RX.
38  * \ingroup soapy
39  * \section source Soapy Source
40  * The soapy source block receives samples and writes to a stream.
41  * The source block also provides Soapy API calls for receiver settings.
42  * Includes all parameters for full RX implementation.
43  * Device is a string containing the driver and type name of the
44  * device the user wants to use according to the Soapy* module
45  * documentation.
46  * Make parameters are passed through the xml block.
47  * Some of the available parameters can be seen at Figure 2
48  * Antenna and clock source can be left empty and default values
49  * will be used.
50  * This block has a message port, which consumes PMT messages.
51  * For a description of the command syntax , see \ref cmd_handler.
52  * \image html source_params.png "Figure 2"
53  */
54 class SOAPY_API source : virtual public gr::sync_block {
55 public:
56  typedef boost::shared_ptr<source> sptr;
57 
58  /*!
59  * \brief Return a shared_ptr to a new instance of soapy::source.
60  *
61  * To avoid accidental use of raw pointers, soapy::source's
62  * constructor is in a private implementation
63  * class. soapy::source::make is the public interface for
64  * creating new instances.
65  * \param nchan number of channels
66  * \param device the device driver and type
67  * \param args the arguments passed to the device
68  * \param sampling_rate the sampling rate of the device
69  * \param type output stream format
70  *
71  * Driver name can be any of "uhd", "lime", "airspy",
72  * "rtlsdr" or others
73  */
74  static sptr make(size_t nchan, const std::string device,
75  const std::string args,
76  double sampling_rate, const std::string type);
77 
78  virtual void set_overall_gain(size_t channel, float gain, bool manual_mode) = 0;
79 
80  virtual bool hasDCOffset(int channel) = 0;
81  virtual bool hasIQBalance(int channel) = 0;
82  virtual bool hasFrequencyCorrection(int channel) = 0;
83 
84  virtual std::vector<std::string> listAntennas(int channel) = 0;
85 
86  /*!
87  * Callback to set overall gain
88  * \param channel an available channel of the device
89  * \param gain the overall gain value
90  */
91  virtual void set_gain(size_t channel, float gain) = 0;
92 
93  /*!
94  * Callback to set specific gain value
95  * \param channel an available channel on the device
96  * \param name the gain name to set value
97  * \param gain the gain value
98  */
99  virtual void set_gain(size_t channel, const std::string name, float gain,
100  bool manual_mode) = 0;
101 
102  /*!
103  * Callback to change the RF frequency of the device
104  * \param channel an available channel of the device
105  * \param freq the frequency to be set in Hz
106  */
107  virtual void set_frequency(size_t channel, double freq) = 0;
108 
109  /*!
110  * Callback to change center frequency of a tunable element
111  * \param channel an available channel of the device
112  * \param name an available element name
113  * \param frequency the frequency to be set in Hz
114  */
115  virtual void set_frequency(size_t channel, const std::string &name,
116  double frequency) = 0;
117 
118  /*!
119  * Callback to set automatic gain mode
120  * \param channel an available channel on the device
121  * \param gain_auto_mode true if automatic gain mode
122  */
123  virtual void set_gain_mode(size_t channel, bool gain_auto_mode) = 0;
124 
125  /*!
126  * Callback to set sample rate
127  * \param channel an available channel of the device
128  * \param sample_rate number of samples in samples per second
129  */
130  virtual void set_sample_rate(size_t channel, double sample_rate) = 0;
131 
132  /*!
133  * Callback to set digital filter bandwidth
134  * \param channel an available channel on the device
135  * \param bandwidth filter width in Hz
136  */
137  virtual void set_bandwidth(size_t channel, double bandwidth) = 0;
138 
139  /*!
140  * Callback to set antenna for RF chain
141  * \param channel an available channel of the device
142  * \param name an available antenna string name
143  */
144  virtual void set_antenna(size_t channel, const std::string &name) = 0;
145 
146  /*!
147  * Callback to set dc offset correction and mode
148  * \param channel an available channel of the device
149  * \param dc_offset complex for dc offset correction
150  * \param dc_offset_auto_mode true if automatic dc offset correction
151  */
152  virtual void set_dc_offset(size_t channel, gr_complexd dc_offset,
153  bool dc_offset_auto_mode) = 0;
154 
155  /*!
156  * Callback to set automatic dc offset mode
157  * \param channel an available channel of the device
158  * \param dc_offset_auto_mode true if automatic dc offset correction
159  */
160  virtual void set_dc_offset_mode(size_t channel,
161  bool dc_offset_auto_mode) = 0;
162 
163  /*!
164  * Callback to set frequency correction
165  * \param channel an available channel of the device
166  * \param freq_correction relative value for frequency correction (1.0 max)
167  */
168  virtual void set_frequency_correction(size_t channel,
169  double freq_correction) = 0;
170 
171  /*!
172  * Callback to set iq balance correction
173  * \param channel an available channel of the device
174  * \param iq_balance complex value for iq balance correction
175  */
176  virtual void set_iq_balance(size_t channel, gr_complexd iq_balance) = 0;
177 
178  /*!
179  * Callback to change master clock rate
180  * \param clock_rate the clock rate in Hz
181  */
182  virtual void set_master_clock_rate(double clock_rate) = 0;
183 
184  /*!
185  * Callback to set the clock source
186  * \param clock_source an available clock source
187  */
188  virtual void set_clock_source(const std::string &clock_source) = 0;
189 
190 };
191 
192 } // namespace soapy
193 } // namespace gr
194 
195 #endif /* INCLUDED_SOAPY_SOURCE_H */
196 
gr::soapy::source::sptr
boost::shared_ptr< source > sptr
Definition: source.h:56
SOAPY_API
#define SOAPY_API
Definition: api.h:30
gr::soapy::source
Definition: source.h:54
gr
Definition: sink.h:29
api.h