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 bool DC_offset_support(int channel) = 0;
84  virtual bool IQ_balance_support(int channel) = 0;
85  virtual bool freq_correction_support(int channel) = 0;
86 
87  virtual std::vector<std::string> listAntennas(int channel) = 0;
88 
89  /*!
90  * Callback to set specific gain value
91  * \param channel an available channel on the device
92  * \param name the gain name to set value
93  * \param gain the gain value
94  */
95  virtual void set_gain(size_t channel, const std::string name, float gain) = 0;
96 
97  /*!
98  * Callback to change the RF frequency of the device
99  * \param channel an available channel of the device
100  * \param freq the frequency to be set in Hz
101  */
102  virtual void set_frequency(size_t channel, double freq) = 0;
103 
104  /*!
105  * Callback to change center frequency of a tunable element
106  * \param channel an available channel of the device
107  * \param name an available element name
108  * \param frequency the frequency to be set in Hz
109  */
110  virtual void set_frequency(size_t channel, const std::string &name,
111  double frequency) = 0;
112 
113  /*!
114  * Callback to set automatic gain mode
115  * \param channel an available channel on the device
116  * \param gain_auto_mode true if automatic gain mode
117  */
118  virtual void set_gain_mode(size_t channel, bool gain_auto_mode) = 0;
119 
120  /*!
121  * Callback to set sample rate
122  * \param channel an available channel of the device
123  * \param sample_rate number of samples in samples per second
124  */
125  virtual void set_sample_rate(size_t channel, double sample_rate) = 0;
126 
127  /*!
128  * Callback to set digital filter bandwidth
129  * \param channel an available channel on the device
130  * \param bandwidth filter width in Hz
131  */
132  virtual void set_bandwidth(size_t channel, double bandwidth) = 0;
133 
134  /*!
135  * Callback to set antenna for RF chain
136  * \param channel an available channel of the device
137  * \param name an available antenna string name
138  */
139  virtual void set_antenna(size_t channel, const std::string &name) = 0;
140 
141  /*!
142  * Callback to set dc offset correction and mode
143  * \param channel an available channel of the device
144  * \param dc_offset complex for dc offset correction
145  * \param dc_offset_auto_mode true if automatic dc offset correction
146  */
147  virtual void set_dc_offset(size_t channel, gr_complexd dc_offset,
148  bool dc_offset_auto_mode) = 0;
149 
150  /*!
151  * Callback to set automatic dc offset mode
152  * \param channel an available channel of the device
153  * \param dc_offset_auto_mode true if automatic dc offset correction
154  */
155  virtual void set_dc_offset_mode(size_t channel, bool dc_offset_auto_mode) = 0;
156 
157  /*!
158  * Callback to set frequency correction
159  * \param channel an available channel of the device
160  * \param freq_correction relative value for frequency correction (1.0 max)
161  */
162  virtual void set_frequency_correction(size_t channel,
163  double freq_correction) = 0;
164 
165  /*!
166  * Callback to set iq balance correction
167  * \param channel an available channel of the device
168  * \param iq_balance complex value for iq balance correction
169  */
170  virtual void set_iq_balance(size_t channel, gr_complexd iq_balance) = 0;
171 
172  /*!
173  * Callback to change master clock rate
174  * \param clock_rate the clock rate in Hz
175  */
176  virtual void set_master_clock_rate(double clock_rate) = 0;
177 
178  /*!
179  * Callback to set the clock source
180  * \param clock_source an available clock source
181  */
182  virtual void set_clock_source(const std::string &clock_source) = 0;
183 };
184 
185 } // namespace soapy
186 } // namespace gr
187 
188 #endif /* INCLUDED_SOAPY_SINK_H */
189 
Definition: sink.h:52
Definition: sink.h:29
boost::shared_ptr< sink > sptr
Definition: sink.h:54
#define SOAPY_API
Definition: api.h:30