GNU Radio 3.7.1 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2010-2013 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_GR_UHD_USRP_SINK_H 00024 #define INCLUDED_GR_UHD_USRP_SINK_H 00025 00026 #include <gnuradio/uhd/api.h> 00027 #include <gnuradio/sync_block.h> 00028 #include <uhd/usrp/multi_usrp.hpp> 00029 00030 #ifndef INCLUDED_UHD_STREAM_HPP 00031 namespace uhd { 00032 struct GR_UHD_API stream_args_t 00033 { 00034 stream_args_t(const std::string &cpu = "", 00035 const std::string &otw = "") 00036 { 00037 cpu_format = cpu; 00038 otw_format = otw; 00039 } 00040 std::string cpu_format; 00041 std::string otw_format; 00042 device_addr_t args; 00043 std::vector<size_t> channels; 00044 }; 00045 } 00046 # define INCLUDED_UHD_STREAM_HPP 00047 #else 00048 # define GR_UHD_USE_STREAM_API 00049 #endif 00050 00051 namespace gr { 00052 namespace uhd { 00053 00054 class uhd_usrp_sink; 00055 00056 class GR_UHD_API usrp_sink : virtual public sync_block 00057 { 00058 public: 00059 // gr::uhd::usrp_sink::sptr 00060 typedef boost::shared_ptr<usrp_sink> sptr; 00061 00062 /*! 00063 * \brief Make a new USRP sink block. 00064 * \ingroup uhd_blk 00065 * 00066 * The USRP sink block reads a stream and transmits the samples. 00067 * The sink block also provides API calls for transmitter settings. 00068 * 00069 * TX Stream tagging: 00070 * 00071 * The following tag keys will be consumed by the work function: 00072 * - pmt::string_to_symbol("tx_sob") 00073 * - pmt::string_to_symbol("tx_eob") 00074 * - pmt::string_to_symbol("tx_time") 00075 * 00076 * The sob and eob (start and end of burst) tag values are pmt booleans. 00077 * When present, burst tags should be set to true (pmt::PMT_T). 00078 * 00079 * The timstamp tag value is a pmt tuple of the following: 00080 * (uint64 seconds, and double fractional seconds). 00081 * 00082 * See the UHD manual for more detailed documentation: 00083 * http://code.ettus.com/redmine/ettus/projects/uhd/wiki 00084 * 00085 * \param device_addr the address to identify the hardware 00086 * \param io_type the desired input data type 00087 * \param num_channels number of stream from the device 00088 * \return a new USRP sink block object 00089 */ 00090 static sptr make(const ::uhd::device_addr_t &device_addr, 00091 const ::uhd::io_type_t &io_type, 00092 size_t num_channels); 00093 00094 /*! 00095 * \brief Make a new USRP sink block. 00096 * 00097 * The USRP sink block reads a stream and transmits the samples. 00098 * The sink block also provides API calls for transmitter settings. 00099 * 00100 * TX Stream tagging: 00101 * 00102 * The following tag keys will be consumed by the work function: 00103 * - pmt::string_to_symbol("tx_sob") 00104 * - pmt::string_to_symbol("tx_eob") 00105 * - pmt::string_to_symbol("tx_time") 00106 * 00107 * The sob and eob (start and end of burst) tag values are pmt booleans. 00108 * When present, burst tags should be set to true (pmt::PMT_T). 00109 * 00110 * The timstamp tag value is a pmt tuple of the following: 00111 * (uint64 seconds, and double fractional seconds). 00112 * 00113 * See the UHD manual for more detailed documentation: 00114 * http://code.ettus.com/redmine/ettus/projects/uhd/wiki 00115 * 00116 * \param device_addr the address to identify the hardware 00117 * \param stream_args the IO format and channel specification 00118 * \return a new USRP sink block object 00119 */ 00120 static sptr make(const ::uhd::device_addr_t &device_addr, 00121 const ::uhd::stream_args_t &stream_args); 00122 00123 /*! 00124 * Set the start time for outgoing samples. 00125 * To control when samples are transmitted, 00126 * set this value before starting the flow graph. 00127 * The value is cleared after each run. 00128 * When not specified, the start time will be: 00129 * - Immediately for the one channel case 00130 * - in the near future for multi-channel 00131 * 00132 * \param time the absolute time for transmission to begin 00133 */ 00134 virtual void set_start_time(const ::uhd::time_spec_t &time) = 0; 00135 00136 /*! 00137 * Returns identifying information about this USRP's configuration. 00138 * Returns motherboard ID, name, and serial. 00139 * Returns daughterboard TX ID, subdev name and spec, serial, and antenna. 00140 * \param chan channel index 0 to N-1 00141 * \return TX info 00142 */ 00143 virtual ::uhd::dict<std::string, std::string> get_usrp_info(size_t chan = 0) = 0; 00144 00145 /*! 00146 * Set the frontend specification. 00147 * \param spec the subdev spec markup string 00148 * \param mboard the motherboard index 0 to M-1 00149 */ 00150 virtual void set_subdev_spec(const std::string &spec, size_t mboard = 0) = 0; 00151 00152 /*! 00153 * Get the TX frontend specification. 00154 * \param mboard the motherboard index 0 to M-1 00155 * \return the frontend specification in use 00156 */ 00157 virtual std::string get_subdev_spec (size_t mboard = 0) = 0; 00158 00159 /*! 00160 * Set the sample rate for the usrp device. 00161 * \param rate a new rate in Sps 00162 */ 00163 virtual void set_samp_rate(double rate) = 0; 00164 00165 /*! 00166 * Get the sample rate for the usrp device. 00167 * This is the actual sample rate and may differ from the rate set. 00168 * \return the actual rate in Sps 00169 */ 00170 virtual double get_samp_rate(void) = 0; 00171 00172 /*! 00173 * Get the possible sample rates for the usrp device. 00174 * \return a range of rates in Sps 00175 */ 00176 virtual ::uhd::meta_range_t get_samp_rates(void) = 0; 00177 00178 /*! 00179 * Tune the usrp device to the desired center frequency. 00180 * \param tune_request the tune request instructions 00181 * \param chan the channel index 0 to N-1 00182 * \return a tune result with the actual frequencies 00183 */ 00184 virtual ::uhd::tune_result_t set_center_freq 00185 (const ::uhd::tune_request_t tune_request, size_t chan = 0) = 0; 00186 00187 /*! 00188 * Tune the usrp device to the desired center frequency. 00189 * This is a wrapper around set center freq so that in this case, 00190 * the user can pass a single frequency in the call through swig. 00191 * \param freq the desired frequency in Hz 00192 * \param chan the channel index 0 to N-1 00193 * \return a tune result with the actual frequencies 00194 */ 00195 ::uhd::tune_result_t set_center_freq(double freq, size_t chan = 0) 00196 { 00197 return set_center_freq(::uhd::tune_request_t(freq), chan); 00198 } 00199 00200 /*! 00201 * Get the center frequency. 00202 * \param chan the channel index 0 to N-1 00203 * \return the frequency in Hz 00204 */ 00205 virtual double get_center_freq(size_t chan = 0) = 0; 00206 00207 /*! 00208 * Get the tunable frequency range. 00209 * \param chan the channel index 0 to N-1 00210 * \return the frequency range in Hz 00211 */ 00212 virtual ::uhd::freq_range_t get_freq_range(size_t chan = 0) = 0; 00213 00214 /*! 00215 * Set the gain for the dboard. 00216 * \param gain the gain in dB 00217 * \param chan the channel index 0 to N-1 00218 */ 00219 virtual void set_gain(double gain, size_t chan = 0) = 0; 00220 00221 /*! 00222 * Set the named gain on the dboard. 00223 * \param gain the gain in dB 00224 * \param name the name of the gain stage 00225 * \param chan the channel index 0 to N-1 00226 */ 00227 virtual void set_gain(double gain, 00228 const std::string &name, 00229 size_t chan = 0) = 0; 00230 00231 /*! 00232 * Get the actual dboard gain setting. 00233 * \param chan the channel index 0 to N-1 00234 * \return the actual gain in dB 00235 */ 00236 virtual double get_gain(size_t chan = 0) = 0; 00237 00238 /*! 00239 * Get the actual dboard gain setting of named stage. 00240 * \param name the name of the gain stage 00241 * \param chan the channel index 0 to N-1 00242 * \return the actual gain in dB 00243 */ 00244 virtual double get_gain(const std::string &name, 00245 size_t chan = 0) = 0; 00246 00247 /*! 00248 * Get the actual dboard gain setting of named stage. 00249 * \param chan the channel index 0 to N-1 00250 * \return the actual gain in dB 00251 */ 00252 virtual std::vector<std::string> get_gain_names(size_t chan = 0) = 0; 00253 00254 /*! 00255 * Get the settable gain range. 00256 * \param chan the channel index 0 to N-1 00257 * \return the gain range in dB 00258 */ 00259 virtual ::uhd::gain_range_t get_gain_range(size_t chan = 0) = 0; 00260 00261 /*! 00262 * Get the settable gain range. 00263 * \param name the name of the gain stage 00264 * \param chan the channel index 0 to N-1 00265 * \return the gain range in dB 00266 */ 00267 virtual ::uhd::gain_range_t get_gain_range(const std::string &name, 00268 size_t chan = 0) = 0; 00269 00270 /*! 00271 * Set the antenna to use. 00272 * \param ant the antenna string 00273 * \param chan the channel index 0 to N-1 00274 */ 00275 virtual void set_antenna(const std::string &ant, 00276 size_t chan = 0) = 0; 00277 00278 /*! 00279 * Get the antenna in use. 00280 * \param chan the channel index 0 to N-1 00281 * \return the antenna string 00282 */ 00283 virtual std::string get_antenna(size_t chan = 0) = 0; 00284 00285 /*! 00286 * Get a list of possible antennas. 00287 * \param chan the channel index 0 to N-1 00288 * \return a vector of antenna strings 00289 */ 00290 virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0; 00291 00292 /*! 00293 * Set the bandpass filter on the RF frontend. 00294 * \param chan the channel index 0 to N-1 00295 * \param bandwidth the filter bandwidth in Hz 00296 */ 00297 virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0; 00298 00299 /*! 00300 * Get the bandpass filter setting on the RF frontend. 00301 * \param chan the channel index 0 to N-1 00302 * \return bandwidth of the filter in Hz 00303 */ 00304 virtual double get_bandwidth(size_t chan = 0) = 0; 00305 00306 /*! 00307 * Get the bandpass filter range of the RF frontend. 00308 * \param chan the channel index 0 to N-1 00309 * \return the range of the filter bandwidth in Hz 00310 */ 00311 virtual ::uhd::freq_range_t get_bandwidth_range(size_t chan = 0) = 0; 00312 00313 /*! 00314 * Set a constant DC offset value. 00315 * The value is complex to control both I and Q. 00316 * \param offset the dc offset (1.0 is full-scale) 00317 * \param chan the channel index 0 to N-1 00318 */ 00319 virtual void set_dc_offset(const std::complex<double> &offset, 00320 size_t chan = 0) = 0; 00321 00322 /*! 00323 * Set the RX frontend IQ imbalance correction. 00324 * Use this to adjust the magnitude and phase of I and Q. 00325 * 00326 * \param correction the complex correction (1.0 is full-scale) 00327 * \param chan the channel index 0 to N-1 00328 */ 00329 virtual void set_iq_balance(const std::complex<double> &correction, 00330 size_t chan = 0) = 0; 00331 00332 /*! 00333 * Get an RF frontend sensor value. 00334 * \param name the name of the sensor 00335 * \param chan the channel index 0 to N-1 00336 * \return a sensor value object 00337 */ 00338 virtual ::uhd::sensor_value_t get_sensor(const std::string &name, 00339 size_t chan = 0) = 0; 00340 00341 /*! 00342 * Get a list of possible RF frontend sensor names. 00343 * \param chan the channel index 0 to N-1 00344 * \return a vector of sensor names 00345 */ 00346 virtual std::vector<std::string> get_sensor_names(size_t chan = 0) = 0; 00347 00348 //! DEPRECATED use get_sensor 00349 ::uhd::sensor_value_t get_dboard_sensor(const std::string &name, 00350 size_t chan = 0) 00351 { 00352 return this->get_sensor(name, chan); 00353 } 00354 00355 //! DEPRECATED use get_sensor_names 00356 std::vector<std::string> get_dboard_sensor_names(size_t chan = 0) 00357 { 00358 return this->get_sensor_names(chan); 00359 } 00360 00361 /*! 00362 * Get a motherboard sensor value. 00363 * \param name the name of the sensor 00364 * \param mboard the motherboard index 0 to M-1 00365 * \return a sensor value object 00366 */ 00367 virtual ::uhd::sensor_value_t get_mboard_sensor(const std::string &name, 00368 size_t mboard = 0) = 0; 00369 00370 /*! 00371 * Get a list of possible motherboard sensor names. 00372 * \param mboard the motherboard index 0 to M-1 00373 * \return a vector of sensor names 00374 */ 00375 virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0; 00376 00377 /*! 00378 * Set the clock configuration. 00379 * DEPRECATED for set_time/clock_source. 00380 * \param clock_config the new configuration 00381 * \param mboard the motherboard index 0 to M-1 00382 */ 00383 virtual void set_clock_config(const ::uhd::clock_config_t &clock_config, 00384 size_t mboard = 0) = 0; 00385 00386 /*! 00387 * Set the time source for the usrp device. 00388 * This sets the method of time synchronization, 00389 * typically a pulse per second or an encoded time. 00390 * Typical options for source: external, MIMO. 00391 * \param source a string representing the time source 00392 * \param mboard which motherboard to set the config 00393 */ 00394 virtual void set_time_source(const std::string &source, 00395 const size_t mboard = 0) = 0; 00396 00397 /*! 00398 * Get the currently set time source. 00399 * \param mboard which motherboard to get the config 00400 * \return the string representing the time source 00401 */ 00402 virtual std::string get_time_source(const size_t mboard) = 0; 00403 00404 /*! 00405 * Get a list of possible time sources. 00406 * \param mboard which motherboard to get the list 00407 * \return a vector of strings for possible settings 00408 */ 00409 virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0; 00410 00411 /*! 00412 * Set the clock source for the usrp device. 00413 * This sets the source for a 10 Mhz reference clock. 00414 * Typical options for source: internal, external, MIMO. 00415 * \param source a string representing the clock source 00416 * \param mboard which motherboard to set the config 00417 */ 00418 virtual void set_clock_source(const std::string &source, 00419 const size_t mboard = 0) = 0; 00420 00421 /*! 00422 * Get the currently set clock source. 00423 * \param mboard which motherboard to get the config 00424 * \return the string representing the clock source 00425 */ 00426 virtual std::string get_clock_source(const size_t mboard) = 0; 00427 00428 /*! 00429 * Get a list of possible clock sources. 00430 * \param mboard which motherboard to get the list 00431 * \return a vector of strings for possible settings 00432 */ 00433 virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0; 00434 00435 /*! 00436 * Get the master clock rate. 00437 * \param mboard the motherboard index 0 to M-1 00438 * \return the clock rate in Hz 00439 */ 00440 virtual double get_clock_rate(size_t mboard = 0) = 0; 00441 00442 /*! 00443 * Set the master clock rate. 00444 * \param rate the new rate in Hz 00445 * \param mboard the motherboard index 0 to M-1 00446 */ 00447 virtual void set_clock_rate(double rate, size_t mboard = 0) = 0; 00448 00449 /*! 00450 * Get the current time registers. 00451 * \param mboard the motherboard index 0 to M-1 00452 * \return the current usrp time 00453 */ 00454 virtual ::uhd::time_spec_t get_time_now(size_t mboard = 0) = 0; 00455 00456 /*! 00457 * Get the time when the last pps pulse occured. 00458 * \param mboard the motherboard index 0 to M-1 00459 * \return the current usrp time 00460 */ 00461 virtual ::uhd::time_spec_t get_time_last_pps(size_t mboard = 0) = 0; 00462 00463 /*! 00464 * Sets the time registers immediately. 00465 * \param time_spec the new time 00466 * \param mboard the motherboard index 0 to M-1 00467 */ 00468 virtual void set_time_now(const ::uhd::time_spec_t &time_spec, size_t mboard = 0) = 0; 00469 00470 /*! 00471 * Set the time registers at the next pps. 00472 * \param time_spec the new time 00473 */ 00474 virtual void set_time_next_pps(const ::uhd::time_spec_t &time_spec) = 0; 00475 00476 /*! 00477 * Sync the time registers with an unknown pps edge. 00478 * \param time_spec the new time 00479 */ 00480 virtual void set_time_unknown_pps(const ::uhd::time_spec_t &time_spec) = 0; 00481 00482 /*! 00483 * Set the time at which the control commands will take effect. 00484 * 00485 * A timed command will back-pressure all subsequent timed commands, 00486 * assuming that the subsequent commands occur within the time-window. 00487 * If the time spec is late, the command will be activated upon arrival. 00488 * 00489 * \param time_spec the time at which the next command will activate 00490 * \param mboard which motherboard to set the config 00491 */ 00492 virtual void set_command_time(const ::uhd::time_spec_t &time_spec, 00493 size_t mboard = 0) = 0; 00494 00495 /*! 00496 * Clear the command time so future commands are sent ASAP. 00497 * 00498 * \param mboard which motherboard to set the config 00499 */ 00500 virtual void clear_command_time(size_t mboard = 0) = 0; 00501 00502 /*! 00503 * Get access to the underlying uhd dboard iface object. 00504 * \return the dboard_iface object 00505 */ 00506 virtual ::uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 0; 00507 00508 /*! 00509 * Get access to the underlying uhd device object. 00510 * \return the multi usrp device object 00511 */ 00512 virtual ::uhd::usrp::multi_usrp::sptr get_device(void) = 0; 00513 00514 /*! 00515 * Perform write on the user configuration register bus. These 00516 * only exist if the user has implemented custom setting 00517 * registers in the device FPGA. 00518 * \param addr 8-bit register address 00519 * \param data 32-bit register value 00520 * \param mboard which motherboard to set the user register 00521 */ 00522 virtual void set_user_register(const uint8_t addr, 00523 const uint32_t data, 00524 size_t mboard = 0) = 0; 00525 }; 00526 00527 } /* namespace uhd */ 00528 } /* namespace gr */ 00529 00530 #endif /* INCLUDED_GR_UHD_USRP_SINK_H */