GNU Radio 3.4.2 C++ API
|
00001 /* 00002 * Copyright 2010-2011 Free Software Foundation, Inc. 00003 * 00004 * This file is part of GNU Radio 00005 * 00006 * GNU Radio is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 3, or (at your option) 00009 * any later version. 00010 * 00011 * GNU Radio is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with GNU Radio; see the file COPYING. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, 00019 * Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef INCLUDED_GR_UHD_USRP_SOURCE_H 00023 #define INCLUDED_GR_UHD_USRP_SOURCE_H 00024 00025 #include <gr_uhd_api.h> 00026 #include <gr_sync_block.h> 00027 #include <uhd/usrp/multi_usrp.hpp> 00028 00029 class uhd_usrp_source; 00030 00031 /*! 00032 * \brief Make a new USRP source block. 00033 * 00034 * The USRP source block receives samples and writes to a stream. 00035 * The source block also provides API calls for receiver settings. 00036 * 00037 * RX Stream tagging: 00038 * 00039 * The following tag keys will be produced by the work function: 00040 * - pmt::pmt_string_to_symbol("rx_time") 00041 * 00042 * The timstamp tag value is a pmt tuple of the following: 00043 * (uint64 seconds, and double fractional seconds). 00044 * A timestamp tag is produced at start() and after overflows. 00045 * 00046 * See the UHD manual for more detailed documentation: 00047 * http://code.ettus.com/redmine/ettus/projects/uhd/wiki 00048 * 00049 * \param device_addr the address to identify the hardware 00050 * \param io_type the desired output data type 00051 * \param num_channels number of stream from the device 00052 * \return a new USRP source block object 00053 */ 00054 GR_UHD_API boost::shared_ptr<uhd_usrp_source> uhd_make_usrp_source( 00055 const uhd::device_addr_t &device_addr, 00056 const uhd::io_type_t &io_type, 00057 size_t num_channels 00058 ); 00059 00060 class GR_UHD_API uhd_usrp_source : virtual public gr_sync_block{ 00061 public: 00062 00063 /*! 00064 * Set the subdevice specification. 00065 * \param spec the subdev spec markup string 00066 * \param mboard the motherboard index 0 to M-1 00067 */ 00068 virtual void set_subdev_spec(const std::string &spec, size_t mboard = 0) = 0; 00069 00070 /*! 00071 * Set the sample rate for the usrp device. 00072 * \param rate a new rate in Sps 00073 */ 00074 virtual void set_samp_rate(double rate) = 0; 00075 00076 /*! 00077 * Get the sample rate for the usrp device. 00078 * This is the actual sample rate and may differ from the rate set. 00079 * \return the actual rate in Sps 00080 */ 00081 virtual double get_samp_rate(void) = 0; 00082 00083 /*! 00084 * Tune the usrp device to the desired center frequency. 00085 * \param tune_request the tune request instructions 00086 * \param chan the channel index 0 to N-1 00087 * \return a tune result with the actual frequencies 00088 */ 00089 virtual uhd::tune_result_t set_center_freq( 00090 const uhd::tune_request_t tune_request, size_t chan = 0 00091 ) = 0; 00092 00093 /*! 00094 * Tune the usrp device to the desired center frequency. 00095 * This is a wrapper around set center freq so that in this case, 00096 * the user can pass a single frequency in the call through swig. 00097 * \param freq the desired frequency in Hz 00098 * \param chan the channel index 0 to N-1 00099 * \return a tune result with the actual frequencies 00100 */ 00101 uhd::tune_result_t set_center_freq(double freq, size_t chan = 0){ 00102 return set_center_freq(uhd::tune_request_t(freq), chan); 00103 } 00104 00105 /*! 00106 * Get the center frequency. 00107 * \param chan the channel index 0 to N-1 00108 * \return the frequency in Hz 00109 */ 00110 virtual double get_center_freq(size_t chan = 0) = 0; 00111 00112 /*! 00113 * Get the tunable frequency range. 00114 * \param chan the channel index 0 to N-1 00115 * \return the frequency range in Hz 00116 */ 00117 virtual uhd::freq_range_t get_freq_range(size_t chan = 0) = 0; 00118 00119 /*! 00120 * Set the gain for the dboard. 00121 * \param gain the gain in dB 00122 * \param chan the channel index 0 to N-1 00123 */ 00124 virtual void set_gain(double gain, size_t chan = 0) = 0; 00125 00126 /*! 00127 * Set the named gain on the dboard. 00128 * \param gain the gain in dB 00129 * \param name the name of the gain stage 00130 * \param chan the channel index 0 to N-1 00131 */ 00132 virtual void set_gain(double gain, const std::string &name, size_t chan = 0) = 0; 00133 00134 /*! 00135 * Get the actual dboard gain setting. 00136 * \param chan the channel index 0 to N-1 00137 * \return the actual gain in dB 00138 */ 00139 virtual double get_gain(size_t chan = 0) = 0; 00140 00141 /*! 00142 * Get the actual dboard gain setting of named stage. 00143 * \param name the name of the gain stage 00144 * \param chan the channel index 0 to N-1 00145 * \return the actual gain in dB 00146 */ 00147 virtual double get_gain(const std::string &name, size_t chan = 0) = 0; 00148 00149 /*! 00150 * Get the actual dboard gain setting of named stage. 00151 * \param chan the channel index 0 to N-1 00152 * \return the actual gain in dB 00153 */ 00154 virtual std::vector<std::string> get_gain_names(size_t chan = 0) = 0; 00155 00156 /*! 00157 * Get the settable gain range. 00158 * \param chan the channel index 0 to N-1 00159 * \return the gain range in dB 00160 */ 00161 virtual uhd::gain_range_t get_gain_range(size_t chan = 0) = 0; 00162 00163 /*! 00164 * Get the settable gain range. 00165 * \param name the name of the gain stage 00166 * \param chan the channel index 0 to N-1 00167 * \return the gain range in dB 00168 */ 00169 virtual uhd::gain_range_t get_gain_range(const std::string &name, size_t chan = 0) = 0; 00170 00171 /*! 00172 * Set the antenna to use. 00173 * \param ant the antenna string 00174 * \param chan the channel index 0 to N-1 00175 */ 00176 virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0; 00177 00178 /*! 00179 * Get the antenna in use. 00180 * \param chan the channel index 0 to N-1 00181 * \return the antenna string 00182 */ 00183 virtual std::string get_antenna(size_t chan = 0) = 0; 00184 00185 /*! 00186 * Get a list of possible antennas. 00187 * \param chan the channel index 0 to N-1 00188 * \return a vector of antenna strings 00189 */ 00190 virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0; 00191 00192 /*! 00193 * Set the subdevice bandpass filter. 00194 * \param bandwidth the filter bandwidth in Hz 00195 * \param chan the channel index 0 to N-1 00196 */ 00197 virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0; 00198 00199 /*! 00200 * Get a daughterboard sensor value. 00201 * \param name the name of the sensor 00202 * \param chan the channel index 0 to N-1 00203 * \return a sensor value object 00204 */ 00205 virtual uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan = 0) = 0; 00206 00207 /*! 00208 * Get a list of possible daughterboard sensor names. 00209 * \param chan the channel index 0 to N-1 00210 * \return a vector of sensor names 00211 */ 00212 virtual std::vector<std::string> get_dboard_sensor_names(size_t chan = 0) = 0; 00213 00214 /*! 00215 * Get a motherboard sensor value. 00216 * \param name the name of the sensor 00217 * \param mboard the motherboard index 0 to M-1 00218 * \return a sensor value object 00219 */ 00220 virtual uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0; 00221 00222 /*! 00223 * Get a list of possible motherboard sensor names. 00224 * \param mboard the motherboard index 0 to M-1 00225 * \return a vector of sensor names 00226 */ 00227 virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0; 00228 00229 /*! 00230 * Set the clock configuration. 00231 * \param clock_config the new configuration 00232 * \param mboard the motherboard index 0 to M-1 00233 */ 00234 virtual void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard = 0) = 0; 00235 00236 /*! 00237 * Get the master clock rate. 00238 * \param mboard the motherboard index 0 to M-1 00239 * \return the clock rate in Hz 00240 */ 00241 virtual double get_clock_rate(size_t mboard = 0) = 0; 00242 00243 /*! 00244 * Set the master clock rate. 00245 * \param rate the new rate in Hz 00246 * \param mboard the motherboard index 0 to M-1 00247 */ 00248 virtual void set_clock_rate(double rate, size_t mboard = 0) = 0; 00249 00250 /*! 00251 * Get the current time registers. 00252 * \param mboard the motherboard index 0 to M-1 00253 * \return the current usrp time 00254 */ 00255 virtual uhd::time_spec_t get_time_now(size_t mboard = 0) = 0; 00256 00257 /*! 00258 * Get the time when the last pps pulse occured. 00259 * \param mboard the motherboard index 0 to M-1 00260 * \return the current usrp time 00261 */ 00262 virtual uhd::time_spec_t get_time_last_pps(size_t mboard = 0) = 0; 00263 00264 /*! 00265 * Sets the time registers immediately. 00266 * \param time_spec the new time 00267 * \param mboard the motherboard index 0 to M-1 00268 */ 00269 virtual void set_time_now(const uhd::time_spec_t &time_spec, size_t mboard = 0) = 0; 00270 00271 /*! 00272 * Set the time registers at the next pps. 00273 * \param time_spec the new time 00274 */ 00275 virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; 00276 00277 /*! 00278 * Sync the time registers with an unknown pps edge. 00279 * \param time_spec the new time 00280 */ 00281 virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0; 00282 00283 /*! 00284 * Get access to the underlying uhd dboard iface object. 00285 * \return the dboard_iface object 00286 */ 00287 virtual uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 0; 00288 00289 /*! 00290 * Get access to the underlying uhd device object. 00291 * \return the multi usrp device object 00292 */ 00293 virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0; 00294 }; 00295 00296 #endif /* INCLUDED_GR_UHD_USRP_SOURCE_H */