GNU Radio's TEST Package
sink_iface.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2012 Dimitri Stolnikov <horiz0n@gmx.net>
4 *
5 * GNU Radio is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3, or (at your option)
8 * any later version.
9 *
10 * GNU Radio is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Radio; see the file COPYING. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifndef OSMOSDR_SINK_IFACE_H
22#define OSMOSDR_SINK_IFACE_H
23
24#include <osmosdr/ranges.h>
25#include <osmosdr/time_spec.h>
26#include <gnuradio/basic_block.h>
27
28/*!
29 * TODO: document
30 *
31 */
33{
34public:
35 /*!
36 * Get the number of channels the underlying radio hardware offers.
37 * \return the number of available channels
38 */
39 virtual size_t get_num_channels( void ) = 0;
40
41 /*!
42 * Get the possible sample rates for the underlying radio hardware.
43 * \return a range of rates in Sps
44 */
46
47 /*!
48 * Set the sample rate for the underlying radio hardware.
49 * This also will select the appropriate IF bandpass, if applicable.
50 * \param rate a new rate in Sps
51 */
52 virtual double set_sample_rate( double rate ) = 0;
53
54 /*!
55 * Get the sample rate for the underlying radio hardware.
56 * This is the actual sample rate and may differ from the rate set.
57 * \return the actual rate in Sps
58 */
59 virtual double get_sample_rate( void ) = 0;
60
61 /*!
62 * Get the tunable frequency range for the underlying radio hardware.
63 * \param chan the channel index 0 to N-1
64 * \return the frequency range in Hz
65 */
66 virtual osmosdr::freq_range_t get_freq_range( size_t chan = 0 ) = 0;
67
68 /*!
69 * Tune the underlying radio hardware to the desired center frequency.
70 * This also will select the appropriate RF bandpass.
71 * \param freq the desired frequency in Hz
72 * \param chan the channel index 0 to N-1
73 * \return the actual frequency in Hz
74 */
75 virtual double set_center_freq( double freq, size_t chan = 0 ) = 0;
76
77 /*!
78 * Get the center frequency the underlying radio hardware is tuned to.
79 * This is the actual frequency and may differ from the frequency set.
80 * \param chan the channel index 0 to N-1
81 * \return the frequency in Hz
82 */
83 virtual double get_center_freq( size_t chan = 0 ) = 0;
84
85 /*!
86 * Set the frequency correction value in parts per million.
87 * \param ppm the desired correction value in parts per million
88 * \param chan the channel index 0 to N-1
89 * \return correction value in parts per million
90 */
91 virtual double set_freq_corr( double ppm, size_t chan = 0 ) = 0;
92
93 /*!
94 * Get the frequency correction value.
95 * \param chan the channel index 0 to N-1
96 * \return correction value in parts per million
97 */
98 virtual double get_freq_corr( size_t chan = 0 ) = 0;
99
100 /*!
101 * Get the gain stage names of the underlying radio hardware.
102 * \param chan the channel index 0 to N-1
103 * \return a vector of strings containing the names of gain stages
104 */
105 virtual std::vector<std::string> get_gain_names( size_t chan = 0 ) = 0;
106
107 /*!
108 * Get the settable overall gain range for the underlying radio hardware.
109 * \param chan the channel index 0 to N-1
110 * \return the gain range in dB
111 */
112 virtual osmosdr::gain_range_t get_gain_range( size_t chan = 0 ) = 0;
113
114 /*!
115 * Get the settable gain range for a specific gain stage.
116 * \param name the name of the gain stage
117 * \param chan the channel index 0 to N-1
118 * \return the gain range in dB
119 */
120 virtual osmosdr::gain_range_t get_gain_range( const std::string & name,
121 size_t chan = 0 ) = 0;
122
123 /*!
124 * Set the gain mode for the underlying radio hardware.
125 * This might be supported only for certain hardware types.
126 * \param automatic the gain mode (true means automatic gain mode)
127 * \param chan the channel index 0 to N-1
128 * \return the actual gain mode
129 */
130 virtual bool set_gain_mode( bool automatic, size_t chan = 0 ) { return false; }
131
132 /*!
133 * Get the gain mode selected for the underlying radio hardware.
134 * \param chan the channel index 0 to N-1
135 * \return the actual gain mode (true means automatic gain mode)
136 */
137 virtual bool get_gain_mode( size_t chan = 0 ) { return false; }
138
139 /*!
140 * Set the gain for the underlying radio hardware.
141 * This function will automatically distribute the desired gain value over
142 * available gain stages in an appropriate way and return the actual value.
143 * \param gain the gain in dB
144 * \param chan the channel index 0 to N-1
145 * \return the actual gain in dB
146 */
147 virtual double set_gain( double gain, size_t chan = 0 ) = 0;
148
149 /*!
150 * Set the named gain on the underlying radio hardware.
151 * \param gain the gain in dB
152 * \param name the name of the gain stage
153 * \param chan the channel index 0 to N-1
154 * \return the actual gain in dB
155 */
156 virtual double set_gain( double gain,
157 const std::string & name,
158 size_t chan = 0 ) = 0;
159
160 /*!
161 * Get the actual gain setting of the underlying radio hardware.
162 * \param chan the channel index 0 to N-1
163 * \return the actual gain in dB
164 */
165 virtual double get_gain( size_t chan = 0 ) = 0;
166
167 /*!
168 * Get the actual gain setting of a named stage.
169 * \param name the name of the gain stage
170 * \param chan the channel index 0 to N-1
171 * \return the actual gain in dB
172 */
173 virtual double get_gain( const std::string & name, size_t chan = 0 ) = 0;
174
175 /*!
176 * Set the IF gain for the underlying radio hardware.
177 * This function will automatically distribute the desired gain value over
178 * available IF gain stages in an appropriate way and return the actual value.
179 * \param gain the gain in dB
180 * \param chan the channel index 0 to N-1
181 * \return the actual gain in dB
182 */
183 virtual double set_if_gain( double gain, size_t chan = 0 ) { return 0; }
184
185 /*!
186 * Set the BB gain for the underlying radio hardware.
187 * This function will automatically distribute the desired gain value over
188 * available BB gain stages in an appropriate way and return the actual value.
189 * \param gain the gain in dB
190 * \param chan the channel index 0 to N-1
191 * \return the actual gain in dB
192 */
193 virtual double set_bb_gain( double gain, size_t chan = 0 ) { return 0; }
194
195 /*!
196 * Get the available antennas of the underlying radio hardware.
197 * \param chan the channel index 0 to N-1
198 * \return a vector of strings containing the names of available antennas
199 */
200 virtual std::vector< std::string > get_antennas( size_t chan = 0 ) = 0;
201
202 /*!
203 * Select the active antenna of the underlying radio hardware.
204 * \param antenna the antenna name
205 * \param chan the channel index 0 to N-1
206 * \return the actual antenna's name
207 */
208 virtual std::string set_antenna( const std::string & antenna,
209 size_t chan = 0 ) = 0;
210
211 /*!
212 * Get the actual underlying radio hardware antenna setting.
213 * \param chan the channel index 0 to N-1
214 * \return the actual antenna's name
215 */
216 virtual std::string get_antenna( size_t chan = 0 ) = 0;
217
218 /*!
219 * Set the TX frontend DC offset value.
220 * The value is complex to control both I and Q.
221 *
222 * \param offset the dc offset (1.0 is full-scale)
223 * \param chan the channel index 0 to N-1
224 */
225 virtual void set_dc_offset( const std::complex<double> &offset, size_t chan = 0 ) { }
226
227 /*!
228 * Set the TX frontend IQ balance correction.
229 * Use this to adjust the magnitude and phase of I and Q.
230 *
231 * \param balance the complex correction value
232 * \param chan the channel index 0 to N-1
233 */
234 virtual void set_iq_balance( const std::complex<double> &balance, size_t chan = 0 ) { }
235
236 /*!
237 * Set the bandpass filter on the radio frontend.
238 * \param bandwidth the filter bandwidth in Hz, set to 0 for automatic selection
239 * \param chan the channel index 0 to N-1
240 * \return the actual filter bandwidth in Hz
241 */
242 virtual double set_bandwidth( double bandwidth, size_t chan = 0 ) { return 0; }
243
244 /*!
245 * Get the actual bandpass filter setting on the radio frontend.
246 * \param chan the channel index 0 to N-1
247 * \return the actual filter bandwidth in Hz
248 */
249 virtual double get_bandwidth( size_t chan = 0 ) { return 0; }
250
251 /*!
252 * Get the possible bandpass filter settings on the radio frontend.
253 * \param chan the channel index 0 to N-1
254 * \return a range of bandwidths in Hz
255 */
257 { return osmosdr::freq_range_t(); }
258
259 /*!
260 * Set the time source for the device.
261 * This sets the method of time synchronization,
262 * typically a pulse per second or an encoded time.
263 * Typical options for source: external, MIMO.
264 * \param source a string representing the time source
265 * \param mboard which motherboard to set the config
266 */
267 virtual void set_time_source(const std::string &source,
268 const size_t mboard = 0) { }
269
270 /*!
271 * Get the currently set time source.
272 * \param mboard which motherboard to get the config
273 * \return the string representing the time source
274 */
275 virtual std::string get_time_source(const size_t mboard) { return ""; }
276
277 /*!
278 * Get a list of possible time sources.
279 * \param mboard which motherboard to get the list
280 * \return a vector of strings for possible settings
281 */
282 virtual std::vector<std::string> get_time_sources(const size_t mboard)
283 {
284 return std::vector<std::string>();
285 }
286
287 /*!
288 * Set the clock source for the device.
289 * This sets the source for a 10 Mhz reference clock.
290 * Typical options for source: internal, external, MIMO.
291 * \param source a string representing the clock source
292 * \param mboard which motherboard to set the config
293 */
294 virtual void set_clock_source(const std::string &source,
295 const size_t mboard = 0) { }
296
297 /*!
298 * Get the currently set clock source.
299 * \param mboard which motherboard to get the config
300 * \return the string representing the clock source
301 */
302 virtual std::string get_clock_source(const size_t mboard) { return ""; }
303
304 /*!
305 * Get a list of possible clock sources.
306 * \param mboard which motherboard to get the list
307 * \return a vector of strings for possible settings
308 */
309 virtual std::vector<std::string> get_clock_sources(const size_t mboard)
310 {
311 return std::vector<std::string>();
312 }
313
314 /*!
315 * Get the master clock rate.
316 * \param mboard the motherboard index 0 to M-1
317 * \return the clock rate in Hz
318 */
319 virtual double get_clock_rate(size_t mboard = 0) { return 0; }
320
321 /*!
322 * Set the master clock rate.
323 * \param rate the new rate in Hz
324 * \param mboard the motherboard index 0 to M-1
325 */
326 virtual void set_clock_rate(double rate, size_t mboard = 0) { }
327
328 /*!
329 * Get the current time registers.
330 * \param mboard the motherboard index 0 to M-1
331 * \return the current device time
332 */
333 virtual ::osmosdr::time_spec_t get_time_now(size_t mboard = 0)
334 {
335 return ::osmosdr::time_spec_t::get_system_time();
336 }
337
338 /*!
339 * Get the time when the last pps pulse occured.
340 * \param mboard the motherboard index 0 to M-1
341 * \return the current device time
342 */
343 virtual ::osmosdr::time_spec_t get_time_last_pps(size_t mboard = 0)
344 {
345 return ::osmosdr::time_spec_t::get_system_time();
346 }
347
348 /*!
349 * Sets the time registers immediately.
350 * \param time_spec the new time
351 * \param mboard the motherboard index 0 to M-1
352 */
353 virtual void set_time_now(const ::osmosdr::time_spec_t &time_spec,
354 size_t mboard = 0) { }
355
356 /*!
357 * Set the time registers at the next pps.
358 * \param time_spec the new time
359 */
360 virtual void set_time_next_pps(const ::osmosdr::time_spec_t &time_spec) { }
361
362 /*!
363 * Sync the time registers with an unknown pps edge.
364 * \param time_spec the new time
365 */
366 virtual void set_time_unknown_pps(const ::osmosdr::time_spec_t &time_spec) { }
367};
368
369#endif // OSMOSDR_SINK_IFACE_H
Definition: sink_iface.h:33
virtual osmosdr::gain_range_t get_gain_range(const std::string &name, size_t chan=0)=0
virtual double set_gain(double gain, const std::string &name, size_t chan=0)=0
virtual double get_freq_corr(size_t chan=0)=0
virtual void set_clock_source(const std::string &source, const size_t mboard=0)
Definition: sink_iface.h:294
virtual bool get_gain_mode(size_t chan=0)
Definition: sink_iface.h:137
virtual double get_clock_rate(size_t mboard=0)
Definition: sink_iface.h:319
virtual double set_freq_corr(double ppm, size_t chan=0)=0
virtual osmosdr::meta_range_t get_sample_rates(void)=0
virtual double set_gain(double gain, size_t chan=0)=0
virtual double get_gain(size_t chan=0)=0
virtual void set_dc_offset(const std::complex< double > &offset, size_t chan=0)
Definition: sink_iface.h:225
virtual std::string set_antenna(const std::string &antenna, size_t chan=0)=0
virtual ::osmosdr::time_spec_t get_time_last_pps(size_t mboard=0)
Definition: sink_iface.h:343
virtual std::string get_time_source(const size_t mboard)
Definition: sink_iface.h:275
virtual ::osmosdr::time_spec_t get_time_now(size_t mboard=0)
Definition: sink_iface.h:333
virtual void set_time_now(const ::osmosdr::time_spec_t &time_spec, size_t mboard=0)
Definition: sink_iface.h:353
virtual void set_time_unknown_pps(const ::osmosdr::time_spec_t &time_spec)
Definition: sink_iface.h:366
virtual void set_time_source(const std::string &source, const size_t mboard=0)
Definition: sink_iface.h:267
virtual std::vector< std::string > get_gain_names(size_t chan=0)=0
virtual void set_iq_balance(const std::complex< double > &balance, size_t chan=0)
Definition: sink_iface.h:234
virtual double set_center_freq(double freq, size_t chan=0)=0
virtual double set_bandwidth(double bandwidth, size_t chan=0)
Definition: sink_iface.h:242
virtual osmosdr::freq_range_t get_freq_range(size_t chan=0)=0
virtual std::vector< std::string > get_time_sources(const size_t mboard)
Definition: sink_iface.h:282
virtual void set_clock_rate(double rate, size_t mboard=0)
Definition: sink_iface.h:326
virtual double get_center_freq(size_t chan=0)=0
virtual bool set_gain_mode(bool automatic, size_t chan=0)
Definition: sink_iface.h:130
virtual double set_if_gain(double gain, size_t chan=0)
Definition: sink_iface.h:183
virtual size_t get_num_channels(void)=0
virtual void set_time_next_pps(const ::osmosdr::time_spec_t &time_spec)
Definition: sink_iface.h:360
virtual double set_bb_gain(double gain, size_t chan=0)
Definition: sink_iface.h:193
virtual std::string get_clock_source(const size_t mboard)
Definition: sink_iface.h:302
virtual double get_gain(const std::string &name, size_t chan=0)=0
virtual std::vector< std::string > get_clock_sources(const size_t mboard)
Definition: sink_iface.h:309
virtual osmosdr::freq_range_t get_bandwidth_range(size_t chan=0)
Definition: sink_iface.h:256
virtual double set_sample_rate(double rate)=0
virtual std::string get_antenna(size_t chan=0)=0
virtual std::vector< std::string > get_antennas(size_t chan=0)=0
virtual double get_sample_rate(void)=0
virtual double get_bandwidth(size_t chan=0)
Definition: sink_iface.h:249
virtual osmosdr::gain_range_t get_gain_range(size_t chan=0)=0
meta_range_t freq_range_t
Definition: ranges.h:125
Definition: ranges.h:75