USRP Hardware Driver and USRP Manual  Version: 003.008.003-0-g87dfdc3c
UHD and USRP Manual
multi_usrp.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2012,2014 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef INCLUDED_UHD_USRP_MULTI_USRP_HPP
19 #define INCLUDED_UHD_USRP_MULTI_USRP_HPP
20 
21 //define API capabilities for compile time detection of new features
22 #define UHD_USRP_MULTI_USRP_REF_SOURCES_API
23 #define UHD_USRP_MULTI_USRP_GET_RATES_API
24 #define UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
25 #define UHD_USRP_MULTI_USRP_COMMAND_TIME_API
26 #define UHD_USRP_MULTI_USRP_BW_RANGE_API
27 #define UHD_USRP_MULTI_USRP_USER_REGS_API
28 #define UHD_USRP_MULTI_USRP_GET_USRP_INFO_API
29 
30 #include <uhd/config.hpp>
31 #include <uhd/device.hpp>
32 #include <uhd/deprecated.hpp>
33 #include <uhd/types/ranges.hpp>
34 #include <uhd/types/stream_cmd.hpp>
37 #include <uhd/types/sensors.hpp>
38 #include <uhd/usrp/subdev_spec.hpp>
40 #include <boost/shared_ptr.hpp>
41 #include <boost/utility.hpp>
42 #include <complex>
43 #include <string>
44 #include <vector>
45 
46 namespace uhd{ namespace usrp{
47 
94 class UHD_API multi_usrp : boost::noncopyable{
95 public:
96  typedef boost::shared_ptr<multi_usrp> sptr;
97 
98  virtual ~multi_usrp(void) = 0;
99 
101  static const size_t ALL_MBOARDS = size_t(~0);
102 
104  static const size_t ALL_CHANS = size_t(~0);
105 
107  static const std::string ALL_GAINS;
108 
114  static sptr make(const device_addr_t &dev_addr);
115 
121  virtual device::sptr get_device(void) = 0;
122 
124  virtual rx_streamer::sptr get_rx_stream(const stream_args_t &args) = 0;
125 
127  virtual tx_streamer::sptr get_tx_stream(const stream_args_t &args) = 0;
128 
136  virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
137 
145  virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
146 
147  /*******************************************************************
148  * Mboard methods
149  ******************************************************************/
150 
161  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
162 
168  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
169 
174  virtual std::string get_pp_string(void) = 0;
175 
181  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
182 
188  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
189 
195  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
196 
208  virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
209 
222  virtual void set_time_next_pps(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
223 
239  virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
240 
247  virtual bool get_time_synchronized(void) = 0;
248 
259  virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
260 
266  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
267 
280  virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
281 
290  virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
291 
300  virtual void set_time_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
301 
307  virtual std::string get_time_source(const size_t mboard) = 0;
308 
314  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
315 
323  virtual void set_clock_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
324 
330  virtual std::string get_clock_source(const size_t mboard) = 0;
331 
337  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
338 
347  virtual void set_clock_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
348 
357  virtual void set_time_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
358 
362  virtual size_t get_num_mboards(void) = 0;
363 
370  virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
371 
377  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
378 
386  virtual void set_user_register(const boost::uint8_t addr, const boost::uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
387 
388  /*******************************************************************
389  * RX methods
390  ******************************************************************/
399  virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
400 
406  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
407 
413  virtual size_t get_rx_num_channels(void) = 0;
414 
420  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
421 
427  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
428 
434  virtual double get_rx_rate(size_t chan = 0) = 0;
435 
441  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
442 
449  virtual tune_result_t set_rx_freq(
450  const tune_request_t &tune_request, size_t chan = 0
451  ) = 0;
452 
458  virtual double get_rx_freq(size_t chan = 0) = 0;
459 
469  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
470 
476  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
477 
485  virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
486 
488  void set_rx_gain(double gain, size_t chan = 0){
489  return this->set_rx_gain(gain, ALL_GAINS, chan);
490  }
491 
499  virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
500 
502  double get_rx_gain(size_t chan = 0){
503  return this->get_rx_gain(ALL_GAINS, chan);
504  }
505 
513  virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
514 
516  gain_range_t get_rx_gain_range(size_t chan = 0){
517  return this->get_rx_gain_range(ALL_GAINS, chan);
518  }
519 
526  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
527 
533  virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
534 
540  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
541 
547  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
548 
554  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
555 
561  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
562 
568  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
569 
577  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
578 
585  virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
586 
592  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
593 
606  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
607 
615  virtual void set_rx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
616 
624  virtual void set_rx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
625 
626  /*******************************************************************
627  * TX methods
628  ******************************************************************/
637  virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
638 
644  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
645 
651  virtual size_t get_tx_num_channels(void) = 0;
652 
658  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
659 
665  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
666 
672  virtual double get_tx_rate(size_t chan = 0) = 0;
673 
679  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
680 
687  virtual tune_result_t set_tx_freq(
688  const tune_request_t &tune_request, size_t chan = 0
689  ) = 0;
690 
696  virtual double get_tx_freq(size_t chan = 0) = 0;
697 
707  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
708 
714  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
715 
723  virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
724 
726  void set_tx_gain(double gain, size_t chan = 0){
727  return this->set_tx_gain(gain, ALL_GAINS, chan);
728  }
729 
737  virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
738 
740  double get_tx_gain(size_t chan = 0){
741  return this->get_tx_gain(ALL_GAINS, chan);
742  }
743 
751  virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
752 
754  gain_range_t get_tx_gain_range(size_t chan = 0){
755  return this->get_tx_gain_range(ALL_GAINS, chan);
756  }
757 
764  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
765 
771  virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
772 
778  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
779 
785  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
786 
792  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
793 
799  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
800 
806  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
807 
815  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
816 
823  virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
824 
830  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
831 
838  virtual void set_tx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
839 
847  virtual void set_tx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
848 
849  /*******************************************************************
850  * GPIO methods
851  ******************************************************************/
852 
858  virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
859 
876  virtual void set_gpio_attr(const std::string &bank, const std::string &attr, const boost::uint32_t value, const boost::uint32_t mask = 0xffffffff, const size_t mboard = 0) = 0;
877 
894  virtual boost::uint32_t get_gpio_attr(const std::string &bank, const std::string &attr, const size_t mboard = 0) = 0;
895 
896 };
897 
898 }}
899 
900 #endif /* INCLUDED_UHD_USRP_MULTI_USRP_HPP */
gain_range_t get_rx_gain_range(size_t chan=0)
A convenience wrapper for getting overall RX gain range.
Definition: multi_usrp.hpp:516
Definition: stream_cmd.hpp:46
Definition: tune_result.hpp:29
double get_tx_gain(size_t chan=0)
A convenience wrapper for getting overall TX gain.
Definition: multi_usrp.hpp:740
void set_tx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall TX gain.
Definition: multi_usrp.hpp:726
Definition: time_spec.hpp:39
boost::shared_ptr< device > sptr
Definition: device.hpp:41
boost::shared_ptr< multi_usrp > sptr
Definition: multi_usrp.hpp:96
double get_rx_gain(size_t chan=0)
A convenience wrapper for getting overall RX gain.
Definition: multi_usrp.hpp:502
Definition: tune_request.hpp:33
boost::shared_ptr< rx_streamer > sptr
Definition: stream.hpp:184
static const std::string ALL_GAINS
A wildcard gain element name.
Definition: multi_usrp.hpp:107
#define UHD_API
Definition: config.hpp:79
Definition: convert.hpp:28
Definition: sensors.hpp:38
Definition: clock_config.hpp:36
Definition: multi_usrp.hpp:94
Definition: stream.hpp:57
boost::shared_ptr< dboard_iface > sptr
Definition: dboard_iface.hpp:61
void set_rx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall RX gain.
Definition: multi_usrp.hpp:488
Definition: subdev_spec.hpp:66
Definition: ranges.hpp:68
boost::shared_ptr< tx_streamer > sptr
Definition: stream.hpp:256
gain_range_t get_tx_gain_range(size_t chan=0)
A convenience wrapper for getting overall TX gain range.
Definition: multi_usrp.hpp:754
Definition: device_addr.hpp:47