USRP Hardware Driver and USRP Manual  Version: 003.009.001-0-gf7a15853
UHD and USRP Manual
multi_usrp.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2012,2014-2015 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_FRONTEND_IQ_AUTO_API
26 #define UHD_USRP_MULTI_USRP_COMMAND_TIME_API
27 #define UHD_USRP_MULTI_USRP_BW_RANGE_API
28 #define UHD_USRP_MULTI_USRP_USER_REGS_API
29 #define UHD_USRP_MULTI_USRP_GET_USRP_INFO_API
30 #define UHD_USRP_MULTI_USRP_NORMALIZED_GAIN
31 #define UHD_USRP_MULTI_USRP_GPIO_API
32 #define UHD_USRP_MULTI_USRP_REGISTER_API
33 #define UHD_USRP_MULTI_USRP_FILTER_API
34 
35 #include <uhd/config.hpp>
36 #include <uhd/device.hpp>
37 #include <uhd/deprecated.hpp>
38 #include <uhd/types/ranges.hpp>
39 #include <uhd/types/stream_cmd.hpp>
42 #include <uhd/types/sensors.hpp>
43 #include <uhd/types/filters.hpp>
44 #include <uhd/usrp/subdev_spec.hpp>
46 #include <boost/shared_ptr.hpp>
47 #include <boost/utility.hpp>
48 #include <complex>
49 #include <string>
50 #include <vector>
51 
52 namespace uhd{ namespace usrp{
53 
100 class UHD_API multi_usrp : boost::noncopyable{
101 public:
102  typedef boost::shared_ptr<multi_usrp> sptr;
103 
104  virtual ~multi_usrp(void) = 0;
105 
107  static const size_t ALL_MBOARDS = size_t(~0);
108 
110  static const size_t ALL_CHANS = size_t(~0);
111 
113  static const std::string ALL_GAINS;
114 
120  static sptr make(const device_addr_t &dev_addr);
121 
127  virtual device::sptr get_device(void) = 0;
128 
130  virtual rx_streamer::sptr get_rx_stream(const stream_args_t &args) = 0;
131 
133  virtual tx_streamer::sptr get_tx_stream(const stream_args_t &args) = 0;
134 
142  virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
143 
151  virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
152 
153  /*******************************************************************
154  * Mboard methods
155  ******************************************************************/
156 
172  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
173 
179  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
180 
185  virtual std::string get_pp_string(void) = 0;
186 
192  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
193 
199  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
200 
206  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
207 
219  virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
220 
233  virtual void set_time_next_pps(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
234 
250  virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
251 
258  virtual bool get_time_synchronized(void) = 0;
259 
270  virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
271 
277  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
278 
291  virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
292 
301  virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
302 
311  virtual void set_time_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
312 
318  virtual std::string get_time_source(const size_t mboard) = 0;
319 
325  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
326 
334  virtual void set_clock_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
335 
341  virtual std::string get_clock_source(const size_t mboard) = 0;
342 
348  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
349 
358  virtual void set_clock_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
359 
368  virtual void set_time_source_out(const bool enb, const size_t mboard = ALL_MBOARDS) = 0;
369 
373  virtual size_t get_num_mboards(void) = 0;
374 
381  virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
382 
388  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
389 
397  virtual void set_user_register(const boost::uint8_t addr, const boost::uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
398 
399  /*******************************************************************
400  * RX methods
401  ******************************************************************/
410  virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
411 
417  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
418 
424  virtual size_t get_rx_num_channels(void) = 0;
425 
431  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
432 
438  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
439 
445  virtual double get_rx_rate(size_t chan = 0) = 0;
446 
452  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
453 
460  virtual tune_result_t set_rx_freq(
461  const tune_request_t &tune_request, size_t chan = 0
462  ) = 0;
463 
469  virtual double get_rx_freq(size_t chan = 0) = 0;
470 
480  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
481 
487  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
488 
496  virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
497 
499  void set_rx_gain(double gain, size_t chan = 0){
500  return this->set_rx_gain(gain, ALL_GAINS, chan);
501  }
502 
519  virtual void set_normalized_rx_gain(double gain, size_t chan = 0) = 0;
520 
529  virtual void set_rx_agc(bool enable, size_t chan = 0) = 0;
530 
538  virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
539 
541  double get_rx_gain(size_t chan = 0){
542  return this->get_rx_gain(ALL_GAINS, chan);
543  }
544 
555  virtual double get_normalized_rx_gain(size_t chan = 0) = 0;
556 
564  virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
565 
567  gain_range_t get_rx_gain_range(size_t chan = 0){
568  return this->get_rx_gain_range(ALL_GAINS, chan);
569  }
570 
577  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
578 
584  virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
585 
591  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
592 
598  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
599 
605  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
606 
612  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
613 
619  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
620 
628  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
629 
636  virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
637 
643  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
644 
657  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
658 
666  virtual void set_rx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
667 
674  virtual void set_rx_iq_balance(const bool enb, size_t chan) = 0;
675 
683  virtual void set_rx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
684 
685  /*******************************************************************
686  * TX methods
687  ******************************************************************/
696  virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
697 
703  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
704 
710  virtual size_t get_tx_num_channels(void) = 0;
711 
717  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
718 
724  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
725 
731  virtual double get_tx_rate(size_t chan = 0) = 0;
732 
738  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
739 
746  virtual tune_result_t set_tx_freq(
747  const tune_request_t &tune_request, size_t chan = 0
748  ) = 0;
749 
755  virtual double get_tx_freq(size_t chan = 0) = 0;
756 
766  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
767 
773  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
774 
782  virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
783 
785  void set_tx_gain(double gain, size_t chan = 0){
786  return this->set_tx_gain(gain, ALL_GAINS, chan);
787  }
788 
799  virtual void set_normalized_tx_gain(double gain, size_t chan = 0) = 0;
800 
808  virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
809 
811  double get_tx_gain(size_t chan = 0){
812  return this->get_tx_gain(ALL_GAINS, chan);
813  }
814 
825  virtual double get_normalized_tx_gain(size_t chan = 0) = 0;
826 
834  virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
835 
837  gain_range_t get_tx_gain_range(size_t chan = 0){
838  return this->get_tx_gain_range(ALL_GAINS, chan);
839  }
840 
847  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
848 
854  virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
855 
861  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
862 
868  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
869 
875  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
876 
882  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
883 
889  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
890 
898  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
899 
906  virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
907 
913  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
914 
921  virtual void set_tx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
922 
930  virtual void set_tx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
931 
932  /*******************************************************************
933  * GPIO methods
934  ******************************************************************/
935 
941  virtual std::vector<std::string> get_gpio_banks(const size_t mboard) = 0;
942 
959  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;
960 
977  virtual boost::uint32_t get_gpio_attr(const std::string &bank, const std::string &attr, const size_t mboard = 0) = 0;
978 
979  /*******************************************************************
980  * Register IO methods
981  ******************************************************************/
983  size_t bitwidth;
984  bool readable;
985  bool writable;
986  };
987 
993  virtual std::vector<std::string> enumerate_registers(const size_t mboard = 0) = 0;
994 
1001  virtual register_info_t get_register_info(const std::string &path, const size_t mboard = 0) = 0;
1002 
1010  virtual void write_register(const std::string &path, const boost::uint32_t field, const boost::uint64_t value, const size_t mboard = 0) = 0;
1011 
1019  virtual boost::uint64_t read_register(const std::string &path, const boost::uint32_t field, const size_t mboard = 0) = 0;
1020 
1021  /*******************************************************************
1022  * Filter API methods
1023  ******************************************************************/
1024 
1035  virtual std::vector<std::string> get_filter_names(const std::string &search_mask = "") = 0;
1036 
1042  virtual filter_info_base::sptr get_filter(const std::string &path) = 0;
1043 
1051  virtual void set_filter(const std::string &path, filter_info_base::sptr filter) = 0;
1052 
1053 };
1054 
1055 }}
1056 
1057 #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:567
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:811
size_t mask(const soft_reg_field_t field)
Definition: soft_register.hpp:98
void set_tx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall TX gain.
Definition: multi_usrp.hpp:785
Definition: time_spec.hpp:39
bool readable
Definition: multi_usrp.hpp:984
boost::shared_ptr< device > sptr
Definition: device.hpp:41
boost::shared_ptr< multi_usrp > sptr
Definition: multi_usrp.hpp:102
Definition: multi_usrp.hpp:982
double get_rx_gain(size_t chan=0)
A convenience wrapper for getting overall RX gain.
Definition: multi_usrp.hpp:541
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:113
Definition: convert.hpp:28
Definition: sensors.hpp:38
boost::shared_ptr< filter_info_base > sptr
Definition: filters.hpp:38
Definition: clock_config.hpp:36
Definition: multi_usrp.hpp:100
Definition: stream.hpp:57
#define UHD_API
Definition: config.h:66
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:499
Definition: subdev_spec.hpp:66
bool writable
Definition: multi_usrp.hpp:985
Definition: ranges.hpp:68
size_t bitwidth
Definition: multi_usrp.hpp:983
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:837
Definition: device_addr.hpp:47