GNU Radio's SDR Package
sink.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2014 Free Software Foundation, Inc.
3  *
4  * This file is part of GNU Radio
5  *
6  * GNU Radio is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  *
11  * GNU Radio is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GNU Radio; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef INCLUDED_GR_SDR_SINK_H
23 #define INCLUDED_GR_SDR_SINK_H
24 
25 #include <gnuradio/sdr/api.h>
26 #include <gnuradio/sdr/types.h>
27 #include <gnuradio/sync_block.h>
28 
29 namespace gr {
30  namespace sdr {
31 
32  class GR_SDR_API sink : virtual public sync_block
33  {
34  public:
35  typedef boost::shared_ptr<sink> sptr;
36 
37  /*!
38  * \brief Make a new SDR device sink block (usually a radio transmitter).
39  *
40  * The SDR device sink block reads a stream and transmits the samples.
41  * The sink block also provides API calls for transmitter settings.
42  *
43  * \param addr the address args to identify the hardware
44  * \param format the host sample format markup string
45  * \param channels a list of channels on the device to use
46  * \param args optional special key/value arguments
47  * \return a new SDR device sink block object
48  */
49  static sptr make(const gr::sdr::kwargs_t &addr = gr::sdr::kwargs_t(),
50  const std::string &format = "CF32",
51  const std::vector<size_t> &channels = std::vector<size_t>(),
52  const gr::sdr::kwargs_t &args = gr::sdr::kwargs_t());
53 
54  /*!
55  * Set the frontend mapping.
56  * \param mapping the mapping markup string
57  */
58  virtual void set_frontend_map(const std::string &mapping) = 0;
59 
60  /*!
61  * Get the TX frontend mapping.
62  * \return the frontend mapping in use
63  */
64  virtual std::string get_frontend_map() = 0;
65 
66  /*!
67  * Set the sample rate for the SDR device.
68  * \param rate a new rate in Sps
69  */
70  virtual void set_samp_rate(double rate) = 0;
71 
72  /*!
73  * Get the sample rate for the SDR device.
74  * This is the actual sample rate and may differ from the rate set.
75  * \return the actual rate in Sps
76  */
77  virtual double get_samp_rate(void) = 0;
78 
79  /*!
80  * Get the possible sample rates for the SDR device.
81  * \return a range of rates in Sps
82  */
83  virtual std::vector<double> get_samp_rates(void) = 0;
84 
85  /*!
86  * Tune the SDR device to the desired center frequency.
87  * This is a wrapper around set center freq so that in this case,
88  * the user can pass a single frequency in the call through swig.
89  * \param freq the desired frequency in Hz
90  * \param chan the channel index 0 to N-1
91  * \return a tune result with the actual frequencies
92  */
93  virtual void set_center_freq(double freq, size_t chan = 0) = 0;
94 
95  /*!
96  * Get the center frequency.
97  * \param chan the channel index 0 to N-1
98  * \return the frequency in Hz
99  */
100  virtual double get_center_freq(size_t chan = 0) = 0;
101 
102  /*!
103  * Get the tunable frequency range.
104  * \param chan the channel index 0 to N-1
105  * \return the frequency range in Hz
106  */
107  virtual std::vector<gr::sdr::range_t> get_freq_range(size_t chan = 0) = 0;
108 
109  /*!
110  * Set the gain for the dboard.
111  * \param gain the gain in dB
112  * \param chan the channel index 0 to N-1
113  */
114  virtual void set_gain(double gain, size_t chan = 0) = 0;
115 
116  /*!
117  * Set the named gain on the dboard.
118  * \param gain the gain in dB
119  * \param name the name of the gain stage
120  * \param chan the channel index 0 to N-1
121  */
122  virtual void set_gain(double gain,
123  const std::string &name,
124  size_t chan = 0) = 0;
125 
126  /*!
127  * Get the actual dboard gain setting.
128  * \param chan the channel index 0 to N-1
129  * \return the actual gain in dB
130  */
131  virtual double get_gain(size_t chan = 0) = 0;
132 
133  /*!
134  * Get the actual dboard gain setting of named stage.
135  * \param name the name of the gain stage
136  * \param chan the channel index 0 to N-1
137  * \return the actual gain in dB
138  */
139  virtual double get_gain(const std::string &name,
140  size_t chan = 0) = 0;
141 
142  /*!
143  * Get the actual dboard gain setting of named stage.
144  * \param chan the channel index 0 to N-1
145  * \return the actual gain in dB
146  */
147  virtual std::vector<std::string> get_gain_names(size_t chan = 0) = 0;
148 
149  /*!
150  * Get the settable gain range.
151  * \param chan the channel index 0 to N-1
152  * \return the gain range in dB
153  */
154  virtual gr::sdr::range_t get_gain_range(size_t chan = 0) = 0;
155 
156  /*!
157  * Get the settable gain range.
158  * \param name the name of the gain stage
159  * \param chan the channel index 0 to N-1
160  * \return the gain range in dB
161  */
162  virtual gr::sdr::range_t get_gain_range(const std::string &name,
163  size_t chan = 0) = 0;
164 
165  /*!
166  * Set the antenna to use.
167  * \param ant the antenna string
168  * \param chan the channel index 0 to N-1
169  */
170  virtual void set_antenna(const std::string &ant,
171  size_t chan = 0) = 0;
172 
173  /*!
174  * Get the antenna in use.
175  * \param chan the channel index 0 to N-1
176  * \return the antenna string
177  */
178  virtual std::string get_antenna(size_t chan = 0) = 0;
179 
180  /*!
181  * Get a list of possible antennas.
182  * \param chan the channel index 0 to N-1
183  * \return a vector of antenna strings
184  */
185  virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0;
186 
187  /*!
188  * Set the bandpass filter on the RF frontend.
189  * \param bandwidth the filter bandwidth in Hz
190  * \param chan the channel index 0 to N-1
191  */
192  virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0;
193 
194  /*!
195  * Get the bandpass filter setting on the RF frontend.
196  * \param chan the channel index 0 to N-1
197  * \return bandwidth of the filter in Hz
198  */
199  virtual double get_bandwidth(size_t chan = 0) = 0;
200 
201  /*!
202  * Get the bandpass filter range of the RF frontend.
203  * \param chan the channel index 0 to N-1
204  * \return the range of the filter bandwidth in Hz
205  */
206  virtual std::vector<double> get_bandwidth_range(size_t chan = 0) = 0;
207 
208  /*!
209  * Set a constant DC offset value.
210  * The value is complex to control both I and Q.
211  * \param offset the dc offset (1.0 is full-scale)
212  * \param chan the channel index 0 to N-1
213  */
214  virtual void set_dc_offset(const std::complex<double> &offset,
215  size_t chan = 0) = 0;
216 
217  /*!
218  * Set the RX frontend IQ imbalance correction.
219  * Use this to adjust the magnitude and phase of I and Q.
220  *
221  * \param correction the complex correction (1.0 is full-scale)
222  * \param chan the channel index 0 to N-1
223  */
224  virtual void set_iq_balance(const std::complex<double> &correction,
225  size_t chan = 0) = 0;
226 
227  /*!
228  * Set the time source for the SDR device.
229  * This sets the method of time synchronization,
230  * typically a pulse per second or an encoded time.
231  * Typical options for source: external, MIMO.
232  * \param source a string representing the time source
233  */
234  virtual void set_time_source(const std::string &source) = 0;
235 
236  /*!
237  * Get the currently set time source.
238  * \return the string representing the time source
239  */
240  virtual std::string get_time_source() = 0;
241 
242  /*!
243  * Get a list of possible time sources.
244  * \return a vector of strings for possible settings
245  */
246  virtual std::vector<std::string> get_time_sources() = 0;
247 
248  /*!
249  * Set the clock source for the SDR device.
250  * This sets the source for a 10 Mhz reference clock.
251  * Typical options for source: internal, external, MIMO.
252  * \param source a string representing the clock source
253  */
254  virtual void set_clock_source(const std::string &source) = 0;
255 
256  /*!
257  * Get the currently set clock source.
258  * \return the string representing the clock source
259  */
260  virtual std::string get_clock_source() = 0;
261 
262  /*!
263  * Get a list of possible clock sources.
264  * \return a vector of strings for possible settings
265  */
266  virtual std::vector<std::string> get_clock_sources() = 0;
267 
268  /*!
269  * Get the master clock rate.
270  * \return the clock rate in Hz
271  */
272  virtual double get_clock_rate() = 0;
273 
274  /*!
275  * Set the master clock rate.
276  * \param rate the new rate in Hz
277  */
278  virtual void set_clock_rate(double rate) = 0;
279  };
280 
281  } /* namespace sdr */
282 } /* namespace gr */
283 
284 #endif /* INCLUDED_GR_SDR_SINK_H */
boost::shared_ptr< sink > sptr
Definition: sink.h:35
Definition: types.h:39
#define GR_SDR_API
Definition: api.h:30
std::map< std::string, std::string > kwargs_t
Typedef for a dictionary of key-value string arguments.
Definition: types.h:34
Definition: sink.h:29
Definition: source.h:32
Definition: sink.h:32