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 #include <vector>
30 #include <string>
31 
32 namespace gr {
33 
34 
35 namespace soapy {
36 
37 /*!
38  * \addtogroup block
39  * \brief <b>Source</b> block implements SoapySDR functionality for RX.
40  * \ingroup soapy
41  * \section source Soapy Source
42  * The soapy source block receives samples and writes to a stream.
43  * The source block also provides Soapy API calls for receiver settings.
44  * Includes all parameters for full RX implementation.
45  * Device is a string containing the driver and type name of the
46  * device the user wants to use according to the Soapy* module
47  * documentation.
48  * Make parameters are passed through the xml block.
49  * Some of the available parameters can be seen at Figure 2
50  * Antenna and clock source can be left empty and default values
51  * will be used.
52  * This block has a message port, which consumes PMT messages.
53  * For a description of the command syntax , see \ref cmd_handler.
54  * \image html source_params.png "Figure 2"
55  */
56 class SOAPY_API source : virtual public gr::sync_block {
57 public:
58  typedef boost::shared_ptr<source> sptr;
59 
60  /*!
61  * \brief Return a shared_ptr to a new instance of soapy::source.
62  *
63  * To avoid accidental use of raw pointers, soapy::source's
64  * constructor is in a private implementation
65  * class. soapy::source::make is the public interface for
66  * creating new instances.
67  * \param nchan number of channels
68  * \param device the device driver and type
69  * \param dev_args device specific arguments
70  * \param stream_args stream arguments. Same for all enabled channels
71  * \param tune_args list with tuning specific arguments, one entry for every
72  * enabled channel
73  * \param other_settings list with general settings, one entry for every
74  * enabled channel. Supports also specific gain settings.
75  * \param sampling_rate the sampling rate of the device
76  * \param type output stream format
77  *
78  * Driver name can be any of "uhd", "lime", "airspy",
79  * "rtlsdr" or others
80  */
81  static sptr make(size_t nchan,
82  const std::string &device,
83  const std::string &dev_args,
84  const std::string &stream_args,
85  const std::vector<std::string> &tune_args,
86  const std::vector<std::string> &other_settings,
87  double sampling_rate,
88  const std::string &type);
89 
90  /*!
91  * Returns a list with the available antennas for a specific channel
92  * @param channel the channel index
93  * @return the available antenna names
94  */
95  virtual std::vector<std::string> get_antennas(int channel) = 0;
96 
97  /*!
98  * Callback to set overall gain
99  * \param channel an available channel of the device
100  * \param gain the overall gain value
101  */
102  virtual void set_gain(size_t channel, float gain) = 0;
103 
104  /*!
105  * Callback to set specific gain value
106  * \param channel an available channel on the device
107  * \param name the gain name to set value
108  * \param gain the gain value
109  */
110  virtual void set_gain(size_t channel, const std::string name, float gain) = 0;
111 
112  /*!
113  * Callback to change the RF frequency of the device
114  * \param channel an available channel of the device
115  * \param freq the frequency to be set in Hz
116  */
117  virtual void set_frequency(size_t channel, double freq) = 0;
118 
119  /*!
120  * Callback to change center frequency of a tunable element
121  * \param channel an available channel of the device
122  * \param name an available element name
123  * \param frequency the frequency to be set in Hz
124  */
125  virtual void set_frequency(size_t channel, const std::string &name,
126  double frequency) = 0;
127 
128  /*!
129  * Callback to set automatic gain control (AGC)
130  * \param channel an available channel on the device
131  * \param enable true to enable AGC
132  */
133  virtual void set_agc(size_t channel, bool enable) = 0;
134 
135  /*!
136  * Callback to set sample rate
137  * \param channel an available channel of the device
138  * \param sample_rate number of samples in samples per second
139  */
140  virtual void set_sample_rate(size_t channel, double sample_rate) = 0;
141 
142  /*!
143  * Callback to set digital filter bandwidth
144  * \param channel an available channel on the device
145  * \param bandwidth filter width in Hz
146  */
147  virtual void set_bandwidth(size_t channel, double bandwidth) = 0;
148 
149  /*!
150  * Callback to set antenna for RF chain
151  * \param channel an available channel of the device
152  * \param name an available antenna string name
153  */
154  virtual void set_antenna(size_t channel, const std::string &name) = 0;
155 
156  /*!
157  * Callback to set dc offset correction and mode
158  * \param channel an available channel of the device
159  * \param dc_offset complex for dc offset correction
160  */
161  virtual void set_dc_offset(size_t channel, gr_complexd dc_offset) = 0;
162 
163  /*!
164  * Callback to set automatic DC removal
165  * \param channel an available channel of the device
166  * \param automatic true to set the automatic DC removal
167  */
168  virtual void set_dc_removal(size_t channel, bool automatic) = 0;
169 
170  /*!
171  * Callback to set frequency correction
172  * \param channel an available channel of the device
173  * \param freq_correction relative value for frequency correction (1.0 max)
174  */
175  virtual void set_frequency_correction(size_t channel,
176  double freq_correction) = 0;
177 
178  /*!
179  * Callback to set iq balance correction
180  * \param channel an available channel of the device
181  * \param iq_balance complex value for iq balance correction
182  */
183  virtual void set_iq_balance(size_t channel, gr_complexd iq_balance) = 0;
184 
185  /*!
186  * Callback to change master clock rate
187  * \param clock_rate the clock rate in Hz
188  */
189  virtual void set_master_clock_rate(double clock_rate) = 0;
190 
191  /*!
192  * Callback to set the clock source
193  * \param clock_source an available clock source
194  */
195  virtual void set_clock_source(const std::string &clock_source) = 0;
196 
197 };
198 
199 } // namespace soapy
200 } // namespace gr
201 
202 #endif /* INCLUDED_SOAPY_SOURCE_H */
203 
Definition: source.h:56
Definition: sink.h:29
#define SOAPY_API
Definition: api.h:30
boost::shared_ptr< source > sptr
Definition: source.h:58