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