GNU Radio 3.4.1 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 GR_UHD_API boost::shared_ptr<uhd_usrp_source> uhd_make_usrp_source( 00032 const uhd::device_addr_t &device_addr, 00033 const uhd::io_type_t &io_type, 00034 size_t num_channels 00035 ); 00036 00037 class GR_UHD_API uhd_usrp_source : virtual public gr_sync_block{ 00038 public: 00039 00040 /*! 00041 * Set the subdevice specification. 00042 * \param spec the subdev spec markup string 00043 * \param mboard the motherboard index 0 to M-1 00044 */ 00045 virtual void set_subdev_spec(const std::string &spec, size_t mboard = 0) = 0; 00046 00047 /*! 00048 * Set the sample rate for the usrp device. 00049 * \param rate a new rate in Sps 00050 */ 00051 virtual void set_samp_rate(double rate) = 0; 00052 00053 /*! 00054 * Get the sample rate for the usrp device. 00055 * This is the actual sample rate and may differ from the rate set. 00056 * \return the actual rate in Sps 00057 */ 00058 virtual double get_samp_rate(void) = 0; 00059 00060 /*! 00061 * Tune the usrp device to the desired center frequency. 00062 * \param tune_request the tune request instructions 00063 * \param chan the channel index 0 to N-1 00064 * \return a tune result with the actual frequencies 00065 */ 00066 virtual uhd::tune_result_t set_center_freq( 00067 const uhd::tune_request_t tune_request, size_t chan = 0 00068 ) = 0; 00069 00070 /*! 00071 * Tune the usrp device to the desired center frequency. 00072 * This is a wrapper around set center freq so that in this case, 00073 * the user can pass a single frequency in the call through swig. 00074 * \param freq the desired frequency in Hz 00075 * \param chan the channel index 0 to N-1 00076 * \return a tune result with the actual frequencies 00077 */ 00078 uhd::tune_result_t set_center_freq(double freq, size_t chan = 0){ 00079 return set_center_freq(uhd::tune_request_t(freq), chan); 00080 } 00081 00082 /*! 00083 * Get the center frequency. 00084 * \param chan the channel index 0 to N-1 00085 * \return the frequency in Hz 00086 */ 00087 virtual double get_center_freq(size_t chan = 0) = 0; 00088 00089 /*! 00090 * Get the tunable frequency range. 00091 * \param chan the channel index 0 to N-1 00092 * \return the frequency range in Hz 00093 */ 00094 virtual uhd::freq_range_t get_freq_range(size_t chan = 0) = 0; 00095 00096 /*! 00097 * Set the gain for the dboard. 00098 * \param gain the gain in dB 00099 * \param chan the channel index 0 to N-1 00100 */ 00101 virtual void set_gain(double gain, size_t chan = 0) = 0; 00102 00103 /*! 00104 * Set the named gain on the dboard. 00105 * \param gain the gain in dB 00106 * \param name the name of the gain stage 00107 * \param chan the channel index 0 to N-1 00108 */ 00109 virtual void set_gain(double gain, const std::string &name, size_t chan = 0) = 0; 00110 00111 /*! 00112 * Get the actual dboard gain setting. 00113 * \param chan the channel index 0 to N-1 00114 * \return the actual gain in dB 00115 */ 00116 virtual double get_gain(size_t chan = 0) = 0; 00117 00118 /*! 00119 * Get the actual dboard gain setting of named stage. 00120 * \param name the name of the gain stage 00121 * \param chan the channel index 0 to N-1 00122 * \return the actual gain in dB 00123 */ 00124 virtual double get_gain(const std::string &name, size_t chan = 0) = 0; 00125 00126 /*! 00127 * Get the actual dboard gain setting of named stage. 00128 * \param chan the channel index 0 to N-1 00129 * \return the actual gain in dB 00130 */ 00131 virtual std::vector<std::string> get_gain_names(size_t chan = 0) = 0; 00132 00133 /*! 00134 * Get the settable gain range. 00135 * \param chan the channel index 0 to N-1 00136 * \return the gain range in dB 00137 */ 00138 virtual uhd::gain_range_t get_gain_range(size_t chan = 0) = 0; 00139 00140 /*! 00141 * Get the settable gain range. 00142 * \param name the name of the gain stage 00143 * \param chan the channel index 0 to N-1 00144 * \return the gain range in dB 00145 */ 00146 virtual uhd::gain_range_t get_gain_range(const std::string &name, size_t chan = 0) = 0; 00147 00148 /*! 00149 * Set the antenna to use. 00150 * \param ant the antenna string 00151 * \param chan the channel index 0 to N-1 00152 */ 00153 virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0; 00154 00155 /*! 00156 * Get the antenna in use. 00157 * \param chan the channel index 0 to N-1 00158 * \return the antenna string 00159 */ 00160 virtual std::string get_antenna(size_t chan = 0) = 0; 00161 00162 /*! 00163 * Get a list of possible antennas. 00164 * \param chan the channel index 0 to N-1 00165 * \return a vector of antenna strings 00166 */ 00167 virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0; 00168 00169 /*! 00170 * Set the subdevice bandpass filter. 00171 * \param bandwidth the filter bandwidth in Hz 00172 * \param chan the channel index 0 to N-1 00173 */ 00174 virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0; 00175 00176 /*! 00177 * Get a daughterboard sensor value. 00178 * \param name the name of the sensor 00179 * \param chan the channel index 0 to N-1 00180 * \return a sensor value object 00181 */ 00182 virtual uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan = 0) = 0; 00183 00184 /*! 00185 * Get a list of possible daughterboard sensor names. 00186 * \param chan the channel index 0 to N-1 00187 * \return a vector of sensor names 00188 */ 00189 virtual std::vector<std::string> get_dboard_sensor_names(size_t chan = 0) = 0; 00190 00191 /*! 00192 * Get a motherboard sensor value. 00193 * \param name the name of the sensor 00194 * \param mboard the motherboard index 0 to M-1 00195 * \return a sensor value object 00196 */ 00197 virtual uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0; 00198 00199 /*! 00200 * Get a list of possible motherboard sensor names. 00201 * \param mboard the motherboard index 0 to M-1 00202 * \return a vector of sensor names 00203 */ 00204 virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0; 00205 00206 /*! 00207 * Set the clock configuration. 00208 * \param clock_config the new configuration 00209 * \param mboard the motherboard index 0 to M-1 00210 */ 00211 virtual void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard = 0) = 0; 00212 00213 /*! 00214 * Get the master clock rate. 00215 * \param mboard the motherboard index 0 to M-1 00216 * \return the clock rate in Hz 00217 */ 00218 virtual double get_clock_rate(size_t mboard = 0) = 0; 00219 00220 /*! 00221 * Set the master clock rate. 00222 * \param rate the new rate in Hz 00223 * \param mboard the motherboard index 0 to M-1 00224 */ 00225 virtual void set_clock_rate(double rate, size_t mboard = 0) = 0; 00226 00227 /*! 00228 * Get the current time registers. 00229 * \param mboard the motherboard index 0 to M-1 00230 * \return the current usrp time 00231 */ 00232 virtual uhd::time_spec_t get_time_now(size_t mboard = 0) = 0; 00233 00234 /*! 00235 * Get the time when the last pps pulse occured. 00236 * \param mboard the motherboard index 0 to M-1 00237 * \return the current usrp time 00238 */ 00239 virtual uhd::time_spec_t get_time_last_pps(size_t mboard = 0) = 0; 00240 00241 /*! 00242 * Sets the time registers immediately. 00243 * \param time_spec the new time 00244 * \param mboard the motherboard index 0 to M-1 00245 */ 00246 virtual void set_time_now(const uhd::time_spec_t &time_spec, size_t mboard = 0) = 0; 00247 00248 /*! 00249 * Set the time registers at the next pps. 00250 * \param time_spec the new time 00251 */ 00252 virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0; 00253 00254 /*! 00255 * Sync the time registers with an unknown pps edge. 00256 * \param time_spec the new time 00257 */ 00258 virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0; 00259 00260 /*! 00261 * Get access to the underlying uhd dboard iface object. 00262 * \return the dboard_iface object 00263 */ 00264 virtual uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 0; 00265 00266 /*! 00267 * Get access to the underlying uhd device object. 00268 * \return the multi usrp device object 00269 */ 00270 virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0; 00271 }; 00272 00273 #endif /* INCLUDED_GR_UHD_USRP_SOURCE_H */