GNU Radio Manual and C++ API Reference  3.8.0.0
The Free & Open Software Radio Ecosystem
usrp_sink.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2010-2016 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_GR_UHD_USRP_SINK_H
24 #define INCLUDED_GR_UHD_USRP_SINK_H
25 
27 
28 namespace gr {
29 namespace uhd {
30 
31 class uhd_usrp_sink;
32 
33 /*! USRP Sink -- Radio Transmitter
34  * \ingroup uhd_blk
35  *
36  *
37  * The USRP sink block reads a stream and transmits the samples.
38  * The sink block also provides API calls for transmitter settings.
39  * See also gr::uhd::usrp_block for more public API calls.
40  *
41  * \section uhd_tx_tagging TX Stream tagging
42  *
43  * The following tag keys will be consumed by the work function:
44  * - pmt::string_to_symbol("tx_sob")
45  * - pmt::string_to_symbol("tx_eob")
46  * - pmt::string_to_symbol("tx_time")
47  * - pmt::string_to_symbol("tx_freq")
48  * - pmt::string_to_symbol("tx_command")
49  * - pmt::string_to_symbol(tsb_tag_name)
50  *
51  * Any other tag will be ignored.
52  *
53  * \section uhd_tx_burstys Bursty Transmission
54  *
55  * There are multiple ways to do bursty transmission without triggering
56  * underruns:
57  * - Using SOB/EOB tags
58  * - Using tagged streams (See \ref page_tagged_stream_blocks)
59  *
60  * The sob and eob (start and end of burst) tag values are pmt booleans.
61  * When present, burst tags should be set to true (pmt::PMT_T).
62  *
63  * If `tsb_tag_name` is not an empty string, all "tx_sob" and "tx_eob"
64  * tags will be ignored, and the input is assumed to a tagged stream.
65  *
66  * If sob/eob tags or length tags are used, this block understands that
67  * the data is bursty, and will configure the USRP to make sure there's
68  * no underruns after transmitting the final sample of a burst.
69  *
70  * \section uhd_tx_time Timestamps
71  *
72  * The timestamp tag value is a PMT tuple of the following:
73  * (uint64 seconds, double fractional seconds).
74  *
75  * The tx_freq tag has to be a double or a pair of form (channel, frequency),
76  * with frequency being a double and channel being an integer.
77  * This tag will trigger a tune command to the USRP
78  * to the given frequency, if possible. Note that oscillators need some time
79  * to stabilize after this! Don't expect clean data to be sent immediately after this
80  * command. If channel is omitted, and only a double is given, it will set this frequency
81  * to all channels.
82  *
83  * The command tag can carry a PMT command. See the following section.
84  *
85  * \section uhd_tx_commands Command interface
86  *
87  * There are two ways of passing commands to this block:
88  * 1. tx_command tag. The command is attached to a sample, and will executed
89  * before the sample is transmitted, and after the previous sample.
90  * 2. The 'command' message port. The command is executed asynchronously,
91  * as soon as possible.
92  *
93  * In both cases, the payload of the command is a PMT command, as described
94  * in Section \ref uhd_command_syntax.
95  *
96  * For a more general description of the gr-uhd components, see \ref page_uhd.
97  */
98 class GR_UHD_API usrp_sink : virtual public usrp_block
99 {
100 public:
101  // gr::uhd::usrp_sink::sptr
102  typedef boost::shared_ptr<usrp_sink> sptr;
103 
104  /*!
105  * \param device_addr the address to identify the hardware
106  * \param stream_args the IO format and channel specification
107  * \param tsb_tag_name the name of the tag identifying tagged stream length
108  * \return a new USRP sink block object
109  */
110  static sptr make(const ::uhd::device_addr_t& device_addr,
111  const ::uhd::stream_args_t& stream_args,
112  const std::string& tsb_tag_name = "");
113 
114  /*!
115  * Set the start time for outgoing samples.
116  * To control when samples are transmitted,
117  * set this value before starting the flow graph.
118  * The value is cleared after each run.
119  * When not specified, the start time will be:
120  * - Immediately for the one channel case
121  * - in the near future for multi-channel
122  *
123  * \param time the absolute time for transmission to begin
124  */
125  virtual void set_start_time(const ::uhd::time_spec_t& time) = 0;
126 
127  /*!
128  * Returns identifying information about this USRP's configuration.
129  * Returns motherboard ID, name, and serial.
130  * Returns daughterboard TX ID, subdev name and spec, serial, and antenna.
131  * \param chan channel index 0 to N-1
132  * \return TX info
133  */
134  virtual ::uhd::dict<std::string, std::string> get_usrp_info(size_t chan = 0) = 0;
135 
136  /*!
137  * Get a list of possible LO stage names
138  * \param chan the channel index 0 to N-1
139  * \return a vector of strings for possible LO names
140  */
141  virtual std::vector<std::string> get_lo_names(size_t chan = 0) = 0;
142 
143  /*!
144  * Set the LO source for the usrp device.
145  * For usrps that support selectable LOs, this function
146  * allows switching between them.
147  * Typical options for source: internal, external.
148  * \param src a string representing the LO source
149  * \param name the name of the LO stage to update
150  * \param chan the channel index 0 to N-1
151  */
152  virtual void
153  set_lo_source(const std::string& src, const std::string& name, size_t chan = 0) = 0;
154 
155  /*!
156  * Get the currently set LO source.
157  * \param name the name of the LO stage to query
158  * \param chan the channel index 0 to N-1
159  * \return the configured LO source
160  */
161  virtual const std::string get_lo_source(const std::string& name, size_t chan = 0) = 0;
162 
163  /*!
164  * Get a list of possible LO sources.
165  * \param name the name of the LO stage to query
166  * \param chan the channel index 0 to N-1
167  * \return a vector of strings for possible settings
168  */
169  virtual std::vector<std::string> get_lo_sources(const std::string& name,
170  size_t chan = 0) = 0;
171 
172  /*!
173  * Set whether the LO used by the usrp device is exported
174  * For usrps that support exportable LOs, this function
175  * configures if the LO used by chan is exported or not.
176  * \param enabled if true then export the LO
177  * \param name the name of the LO stage to update
178  * \param chan the channel index 0 to N-1 for the source channel
179  */
180  virtual void
181  set_lo_export_enabled(bool enabled, const std::string& name, size_t chan = 0) = 0;
182 
183  /*!
184  * Returns true if the currently selected LO is being exported.
185  * \param name the name of the LO stage to query
186  * \param chan the channel index 0 to N-1
187  */
188  virtual bool get_lo_export_enabled(const std::string& name, size_t chan = 0) = 0;
189 
190  /*!
191  * Set the RX LO frequency (Advanced).
192  * \param freq the frequency to set the LO to
193  * \param name the name of the LO stage to update
194  * \param chan the channel index 0 to N-1
195  * \return a coerced LO frequency
196  */
197  virtual double set_lo_freq(double freq, const std::string& name, size_t chan = 0) = 0;
198 
199  /*!
200  * Get the current RX LO frequency (Advanced).
201  * \param name the name of the LO stage to query
202  * \param chan the channel index 0 to N-1
203  * \return the configured LO frequency
204  */
205  virtual double get_lo_freq(const std::string& name, size_t chan = 0) = 0;
206 
207  /*!
208  * Get the LO frequency range of the RX LO.
209  * \param name the name of the LO stage to query
210  * \param chan the channel index 0 to N-1
211  * \return a frequency range object
212  */
213  virtual ::uhd::freq_range_t get_lo_freq_range(const std::string& name,
214  size_t chan = 0) = 0;
215 
216  /*!
217  * Set a constant DC offset value.
218  * The value is complex to control both I and Q.
219  * \param offset the dc offset (1.0 is full-scale)
220  * \param chan the channel index 0 to N-1
221  */
222  virtual void set_dc_offset(const std::complex<double>& offset, size_t chan = 0) = 0;
223 
224  /*!
225  * Set the RX frontend IQ imbalance correction.
226  * Use this to adjust the magnitude and phase of I and Q.
227  *
228  * \param correction the complex correction (1.0 is full-scale)
229  * \param chan the channel index 0 to N-1
230  */
231  virtual void set_iq_balance(const std::complex<double>& correction,
232  size_t chan = 0) = 0;
233 };
234 
235 } /* namespace uhd */
236 } /* namespace gr */
237 
238 #endif /* INCLUDED_GR_UHD_USRP_SINK_H */
Definition: usrp_block.h:59
Definition: usrp_sink.h:98
boost::shared_ptr< usrp_sink > sptr
Definition: usrp_sink.h:102
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:45
#define GR_UHD_API
Definition: gr-uhd/include/gnuradio/uhd/api.h:30