GNU Radio's SDR Package
source.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_SOURCE_H
23 #define INCLUDED_GR_SDR_SOURCE_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 source : virtual public sync_block
33  {
34  public:
35  typedef boost::shared_ptr<source> sptr;
36 
37  /*!
38  * \brief Make a new SDR device source block (usually a radio receiver).
39  *
40  * The SDR device source block receives samples and writes to a stream.
41  * The source block also provides API calls for receiver 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 source 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 subdev spec markup string
57  */
58  virtual void set_frontend_map(const std::string &mapping) = 0;
59 
60  /*!
61  * Get the RX 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, size_t chan = 0) = 0;
140 
141  /*!
142  * Get the actual dboard gain setting of named stage.
143  * \param chan the channel index 0 to N-1
144  * \return the actual gain in dB
145  */
146  virtual std::vector<std::string> get_gain_names(size_t chan = 0) = 0;
147 
148  /*!
149  * Get the settable gain range.
150  * \param chan the channel index 0 to N-1
151  * \return the gain range in dB
152  */
153  virtual gr::sdr::range_t get_gain_range(size_t chan = 0) = 0;
154 
155  /*!
156  * Get the settable gain range.
157  * \param name the name of the gain stage
158  * \param chan the channel index 0 to N-1
159  * \return the gain range in dB
160  */
161  virtual gr::sdr::range_t get_gain_range(const std::string &name, size_t chan = 0) = 0;
162 
163  /*!
164  * Set the antenna to use.
165  * \param ant the antenna string
166  * \param chan the channel index 0 to N-1
167  */
168  virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0;
169 
170  /*!
171  * Get the antenna in use.
172  * \param chan the channel index 0 to N-1
173  * \return the antenna string
174  */
175  virtual std::string get_antenna(size_t chan = 0) = 0;
176 
177  /*!
178  * Get a list of possible antennas.
179  * \param chan the channel index 0 to N-1
180  * \return a vector of antenna strings
181  */
182  virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0;
183 
184  /*!
185  * Set the bandpass filter on the RF frontend.
186  * \param bandwidth the filter bandwidth in Hz
187  * \param chan the channel index 0 to N-1
188  */
189  virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0;
190 
191  /*!
192  * Get the bandpass filter setting on the RF frontend.
193  * \param chan the channel index 0 to N-1
194  * \return bandwidth of the filter in Hz
195  */
196  virtual double get_bandwidth(size_t chan = 0) = 0;
197 
198  /*!
199  * Get the bandpass filter range of the RF frontend.
200  * \param chan the channel index 0 to N-1
201  * \return the range of the filter bandwidth in Hz
202  */
203  virtual std::vector<double> get_bandwidth_range(size_t chan = 0) = 0;
204 
205  /*!
206  * Set a constant DC offset value.
207  * The value is complex to control both I and Q.
208  * Only set this when automatic correction is disabled.
209  * \param offset the dc offset (1.0 is full-scale)
210  * \param chan the channel index 0 to N-1
211  */
212  virtual void set_dc_offset(const std::complex<double> &offset, size_t chan = 0) = 0;
213 
214  /*!
215  * Set the RX frontend IQ imbalance correction.
216  * Use this to adjust the magnitude and phase of I and Q.
217  *
218  * \param correction the complex correction value
219  * \param chan the channel index 0 to N-1
220  */
221  virtual void set_iq_balance(const std::complex<double> &correction, size_t chan = 0) = 0;
222 
223  /*!
224  * Set the time source for the SDR device.
225  * This sets the method of time synchronization,
226  * typically a pulse per second or an encoded time.
227  * Typical options for source: external, MIMO.
228  * \param source a string representing the time source
229  */
230  virtual void set_time_source(const std::string &source) = 0;
231 
232  /*!
233  * Get the currently set time source.
234  * \return the string representing the time source
235  */
236  virtual std::string get_time_source() = 0;
237 
238  /*!
239  * Get a list of possible time sources.
240  * \return a vector of strings for possible settings
241  */
242  virtual std::vector<std::string> get_time_sources() = 0;
243 
244  /*!
245  * Set the clock source for the SDR device.
246  * This sets the source for a 10 Mhz reference clock.
247  * Typical options for source: internal, external, MIMO.
248  * \param source a string representing the clock source
249  */
250  virtual void set_clock_source(const std::string &source) = 0;
251 
252  /*!
253  * Get the currently set clock source.
254  * \return the string representing the clock source
255  */
256  virtual std::string get_clock_source() = 0;
257 
258  /*!
259  * Get a list of possible clock sources.
260  * \return a vector of strings for possible settings
261  */
262  virtual std::vector<std::string> get_clock_sources() = 0;
263 
264  /*!
265  * Get the master clock rate.
266  * \return the clock rate in Hz
267  */
268  virtual double get_clock_rate() = 0;
269 
270  /*!
271  * Set the master clock rate.
272  * \param rate the new rate in Hz
273  */
274  virtual void set_clock_rate(double rate) = 0;
275  };
276 
277  } /* namespace sdr */
278 } /* namespace gr */
279 
280 #endif /* INCLUDED_GR_SDR_SOURCE_H */
boost::shared_ptr< source > sptr
Definition: source.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