GNU Radio 3.4.0 C++ API
gr_uhd_usrp_sink.h
Go to the documentation of this file.
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_SINK_H
00023 #define INCLUDED_GR_UHD_USRP_SINK_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_sink;
00030 
00031 GR_UHD_API boost::shared_ptr<uhd_usrp_sink> uhd_make_usrp_sink(
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_sink : 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 name the name of the gain stage
00129      * \param chan the channel index 0 to N-1
00130      * \return the actual gain in dB
00131      */
00132     virtual std::vector<std::string> get_gain_names(size_t chan = 0) = 0;
00133 
00134     /*!
00135      * Get the settable gain range.
00136      * \param chan the channel index 0 to N-1
00137      * \return the gain range in dB
00138      */
00139     virtual uhd::gain_range_t get_gain_range(size_t chan = 0) = 0;
00140 
00141     /*!
00142      * Get the settable gain range.
00143      * \param name the name of the gain stage
00144      * \param chan the channel index 0 to N-1
00145      * \return the gain range in dB
00146      */
00147     virtual uhd::gain_range_t get_gain_range(const std::string &name, size_t chan = 0) = 0;
00148 
00149     /*!
00150      * Set the antenna to use.
00151      * \param ant the antenna string
00152      * \param chan the channel index 0 to N-1
00153      */
00154     virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0;
00155 
00156     /*!
00157      * Get the antenna in use.
00158      * \param chan the channel index 0 to N-1
00159      * \return the antenna string
00160      */
00161     virtual std::string get_antenna(size_t chan = 0) = 0;
00162 
00163     /*!
00164      * Get a list of possible antennas.
00165      * \param chan the channel index 0 to N-1
00166      * \return a vector of antenna strings
00167      */
00168     virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0;
00169 
00170     /*!
00171      * Set the subdevice bandpass filter.
00172      * \param chan the channel index 0 to N-1
00173      * \param bandwidth the filter bandwidth in Hz
00174      */
00175     virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0;
00176 
00177     /*!
00178      * Get a daughterboard sensor value.
00179      * \param name the name of the sensor
00180      * \param chan the channel index 0 to N-1
00181      * \return a sensor value object
00182      */
00183     virtual uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan = 0) = 0;
00184 
00185     /*!
00186      * Get a list of possible daughterboard sensor names.
00187      * \param chan the channel index 0 to N-1
00188      * \return a vector of sensor names
00189      */
00190     virtual std::vector<std::string> get_dboard_sensor_names(size_t chan = 0) = 0;
00191 
00192     /*!
00193      * Get a motherboard sensor value.
00194      * \param name the name of the sensor
00195      * \param mboard the motherboard index 0 to M-1
00196      * \return a sensor value object
00197      */
00198     virtual uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
00199 
00200     /*!
00201      * Get a list of possible motherboard sensor names.
00202      * \param mboard the motherboard index 0 to M-1
00203      * \return a vector of sensor names
00204      */
00205     virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
00206 
00207     /*!
00208      * Set the clock configuration.
00209      * \param clock_config the new configuration
00210      * \param mboard the motherboard index 0 to M-1
00211      */
00212     virtual void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard = 0) = 0;
00213 
00214     /*!
00215      * Get the master clock rate.
00216      * \param mboard the motherboard index 0 to M-1
00217      * \return the clock rate in Hz
00218      */
00219     virtual double get_clock_rate(size_t mboard = 0) = 0;
00220 
00221     /*!
00222      * Set the master clock rate.
00223      * \param rate the new rate in Hz
00224      * \param mboard the motherboard index 0 to M-1
00225      */
00226     virtual void set_clock_rate(double rate, size_t mboard = 0) = 0;
00227 
00228     /*!
00229      * Get the current time registers.
00230      * \param mboard the motherboard index 0 to M-1
00231      * \return the current usrp time
00232      */
00233     virtual uhd::time_spec_t get_time_now(size_t mboard = 0) = 0;
00234 
00235     /*!
00236      * Get the time when the last pps pulse occured.
00237      * \param mboard the motherboard index 0 to M-1
00238      * \return the current usrp time
00239      */
00240     virtual uhd::time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
00241 
00242     /*!
00243      * Sets the time registers immediately.
00244      * \param time_spec the new time
00245      * \param mboard the motherboard index 0 to M-1
00246      */
00247     virtual void set_time_now(const uhd::time_spec_t &time_spec, size_t mboard = 0) = 0;
00248 
00249     /*!
00250      * Set the time registers at the next pps.
00251      * \param time_spec the new time
00252      */
00253     virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0;
00254 
00255     /*!
00256      * Sync the time registers with an unknown pps edge.
00257      * \param time_spec the new time
00258      */
00259     virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0;
00260 
00261     /*!
00262      * Get access to the underlying uhd dboard iface object.
00263      * \return the dboard_iface object
00264      */
00265     virtual uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 0;
00266 
00267     /*!
00268      * Get access to the underlying uhd device object.
00269      * \return the multi usrp device object
00270      */
00271     virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0;
00272 };
00273 
00274 #endif /* INCLUDED_GR_UHD_USRP_SINK_H */