GNU Radio C++ API
gr_uhd_usrp_sink.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2011 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_UHD_USRP_SINK_H
23 #define INCLUDED_GR_UHD_USRP_SINK_H
24 
25 #include <gr_uhd_api.h>
26 #include <gr_sync_block.h>
27 #include <uhd/usrp/multi_usrp.hpp>
28 
29 class uhd_usrp_sink;
30 
31 /*!
32  * \brief Make a new USRP sink block.
33  * \ingroup uhd_blk
34  *
35  * The USRP sink block reads a stream and transmits the samples.
36  * The sink block also provides API calls for transmitter settings.
37  *
38  * TX Stream tagging:
39  *
40  * The following tag keys will be consumed by the work function:
41  * - pmt::pmt_string_to_symbol("tx_sob")
42  * - pmt::pmt_string_to_symbol("tx_eob")
43  * - pmt::pmt_string_to_symbol("tx_time")
44  *
45  * The sob and eob (start and end of burst) tag values are pmt booleans.
46  * When present, burst tags should be set to true (pmt::PMT_T).
47  *
48  * The timstamp tag value is a pmt tuple of the following:
49  * (uint64 seconds, and double fractional seconds).
50  *
51  * See the UHD manual for more detailed documentation:
52  * http://code.ettus.com/redmine/ettus/projects/uhd/wiki
53  *
54  * \param device_addr the address to identify the hardware
55  * \param io_type the desired input data type
56  * \param num_channels number of stream from the device
57  * \return a new USRP sink block object
58  */
60  const uhd::device_addr_t &device_addr,
61  const uhd::io_type_t &io_type,
62  size_t num_channels
63 );
64 
65 class GR_UHD_API uhd_usrp_sink : virtual public gr_sync_block{
66 public:
67 
68  /*!
69  * Set the subdevice specification.
70  * \param spec the subdev spec markup string
71  * \param mboard the motherboard index 0 to M-1
72  */
73  virtual void set_subdev_spec(const std::string &spec, size_t mboard = 0) = 0;
74 
75  /*!
76  * Set the sample rate for the usrp device.
77  * \param rate a new rate in Sps
78  */
79  virtual void set_samp_rate(double rate) = 0;
80 
81  /*!
82  * Get the sample rate for the usrp device.
83  * This is the actual sample rate and may differ from the rate set.
84  * \return the actual rate in Sps
85  */
86  virtual double get_samp_rate(void) = 0;
87 
88  /*!
89  * Tune the usrp device to the desired center frequency.
90  * \param tune_request the tune request instructions
91  * \param chan the channel index 0 to N-1
92  * \return a tune result with the actual frequencies
93  */
94  virtual uhd::tune_result_t set_center_freq(
95  const uhd::tune_request_t tune_request, size_t chan = 0
96  ) = 0;
97 
98  /*!
99  * Tune the usrp device to the desired center frequency.
100  * This is a wrapper around set center freq so that in this case,
101  * the user can pass a single frequency in the call through swig.
102  * \param freq the desired frequency in Hz
103  * \param chan the channel index 0 to N-1
104  * \return a tune result with the actual frequencies
105  */
106  uhd::tune_result_t set_center_freq(double freq, size_t chan = 0){
107  return set_center_freq(uhd::tune_request_t(freq), chan);
108  }
109 
110  /*!
111  * Get the center frequency.
112  * \param chan the channel index 0 to N-1
113  * \return the frequency in Hz
114  */
115  virtual double get_center_freq(size_t chan = 0) = 0;
116 
117  /*!
118  * Get the tunable frequency range.
119  * \param chan the channel index 0 to N-1
120  * \return the frequency range in Hz
121  */
122  virtual uhd::freq_range_t get_freq_range(size_t chan = 0) = 0;
123 
124  /*!
125  * Set the gain for the dboard.
126  * \param gain the gain in dB
127  * \param chan the channel index 0 to N-1
128  */
129  virtual void set_gain(double gain, size_t chan = 0) = 0;
130 
131  /*!
132  * Set the named gain on the dboard.
133  * \param gain the gain in dB
134  * \param name the name of the gain stage
135  * \param chan the channel index 0 to N-1
136  */
137  virtual void set_gain(double gain, const std::string &name, size_t chan = 0) = 0;
138 
139  /*!
140  * Get the actual dboard gain setting.
141  * \param chan the channel index 0 to N-1
142  * \return the actual gain in dB
143  */
144  virtual double get_gain(size_t chan = 0) = 0;
145 
146  /*!
147  * Get the actual dboard gain setting of named stage.
148  * \param name the name of the gain stage
149  * \param chan the channel index 0 to N-1
150  * \return the actual gain in dB
151  */
152  virtual double get_gain(const std::string &name, size_t chan = 0) = 0;
153 
154  /*!
155  * Get the actual dboard gain setting of named stage.
156  * \param chan the channel index 0 to N-1
157  * \return the actual gain in dB
158  */
159  virtual std::vector<std::string> get_gain_names(size_t chan = 0) = 0;
160 
161  /*!
162  * Get the settable gain range.
163  * \param chan the channel index 0 to N-1
164  * \return the gain range in dB
165  */
166  virtual uhd::gain_range_t get_gain_range(size_t chan = 0) = 0;
167 
168  /*!
169  * Get the settable gain range.
170  * \param name the name of the gain stage
171  * \param chan the channel index 0 to N-1
172  * \return the gain range in dB
173  */
174  virtual uhd::gain_range_t get_gain_range(const std::string &name, size_t chan = 0) = 0;
175 
176  /*!
177  * Set the antenna to use.
178  * \param ant the antenna string
179  * \param chan the channel index 0 to N-1
180  */
181  virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0;
182 
183  /*!
184  * Get the antenna in use.
185  * \param chan the channel index 0 to N-1
186  * \return the antenna string
187  */
188  virtual std::string get_antenna(size_t chan = 0) = 0;
189 
190  /*!
191  * Get a list of possible antennas.
192  * \param chan the channel index 0 to N-1
193  * \return a vector of antenna strings
194  */
195  virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0;
196 
197  /*!
198  * Set the subdevice bandpass filter.
199  * \param chan the channel index 0 to N-1
200  * \param bandwidth the filter bandwidth in Hz
201  */
202  virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0;
203 
204  /*!
205  * Get a daughterboard sensor value.
206  * \param name the name of the sensor
207  * \param chan the channel index 0 to N-1
208  * \return a sensor value object
209  */
210  virtual uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan = 0) = 0;
211 
212  /*!
213  * Get a list of possible daughterboard sensor names.
214  * \param chan the channel index 0 to N-1
215  * \return a vector of sensor names
216  */
217  virtual std::vector<std::string> get_dboard_sensor_names(size_t chan = 0) = 0;
218 
219  /*!
220  * Get a motherboard sensor value.
221  * \param name the name of the sensor
222  * \param mboard the motherboard index 0 to M-1
223  * \return a sensor value object
224  */
225  virtual uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
226 
227  /*!
228  * Get a list of possible motherboard sensor names.
229  * \param mboard the motherboard index 0 to M-1
230  * \return a vector of sensor names
231  */
232  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
233 
234  /*!
235  * Set the clock configuration.
236  * \param clock_config the new configuration
237  * \param mboard the motherboard index 0 to M-1
238  */
239  virtual void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard = 0) = 0;
240 
241  /*!
242  * Get the master clock rate.
243  * \param mboard the motherboard index 0 to M-1
244  * \return the clock rate in Hz
245  */
246  virtual double get_clock_rate(size_t mboard = 0) = 0;
247 
248  /*!
249  * Set the master clock rate.
250  * \param rate the new rate in Hz
251  * \param mboard the motherboard index 0 to M-1
252  */
253  virtual void set_clock_rate(double rate, size_t mboard = 0) = 0;
254 
255  /*!
256  * Get the current time registers.
257  * \param mboard the motherboard index 0 to M-1
258  * \return the current usrp time
259  */
260  virtual uhd::time_spec_t get_time_now(size_t mboard = 0) = 0;
261 
262  /*!
263  * Get the time when the last pps pulse occured.
264  * \param mboard the motherboard index 0 to M-1
265  * \return the current usrp time
266  */
267  virtual uhd::time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
268 
269  /*!
270  * Sets the time registers immediately.
271  * \param time_spec the new time
272  * \param mboard the motherboard index 0 to M-1
273  */
274  virtual void set_time_now(const uhd::time_spec_t &time_spec, size_t mboard = 0) = 0;
275 
276  /*!
277  * Set the time registers at the next pps.
278  * \param time_spec the new time
279  */
280  virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0;
281 
282  /*!
283  * Sync the time registers with an unknown pps edge.
284  * \param time_spec the new time
285  */
286  virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0;
287 
288  /*!
289  * Get access to the underlying uhd dboard iface object.
290  * \return the dboard_iface object
291  */
292  virtual uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 0;
293 
294  /*!
295  * Get access to the underlying uhd device object.
296  * \return the multi usrp device object
297  */
298  virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0;
299 };
300 
301 #endif /* INCLUDED_GR_UHD_USRP_SINK_H */