UHD  003.005.005-0-g3c6a906c
multi_usrp.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2012 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 
99  static const size_t ALL_MBOARDS = size_t(~0);
100 
102  static const size_t ALL_CHANS = size_t(~0);
103 
105  static const std::string ALL_GAINS;
106 
112  static sptr make(const device_addr_t &dev_addr);
113 
119  virtual device::sptr get_device(void) = 0;
120 
123  return this->get_device()->get_rx_stream(args);
124  }
125 
128  return this->get_device()->get_tx_stream(args);
129  }
130 
138  virtual dict<std::string, std::string> get_usrp_rx_info(size_t chan = 0) = 0;
139 
147  virtual dict<std::string, std::string> get_usrp_tx_info(size_t chan = 0) = 0;
148 
149  /*******************************************************************
150  * Mboard methods
151  ******************************************************************/
152 
163  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
164 
170  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
171 
176  virtual std::string get_pp_string(void) = 0;
177 
183  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
184 
190  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
191 
197  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
198 
210  virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
211 
224  virtual void set_time_next_pps(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
225 
241  virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
242 
249  virtual bool get_time_synchronized(void) = 0;
250 
261  virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
262 
268  virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
269 
282  virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
283 
292  virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
293 
302  virtual void set_time_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
303 
309  virtual std::string get_time_source(const size_t mboard) = 0;
310 
316  virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
317 
325  virtual void set_clock_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
326 
332  virtual std::string get_clock_source(const size_t mboard) = 0;
333 
339  virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
340 
344  virtual size_t get_num_mboards(void) = 0;
345 
352  virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
353 
359  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
360 
368  virtual void set_user_register(const boost::uint8_t addr, const boost::uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
369 
370  /*******************************************************************
371  * RX methods
372  ******************************************************************/
381  virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
382 
388  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
389 
395  virtual size_t get_rx_num_channels(void) = 0;
396 
402  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
403 
409  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
410 
416  virtual double get_rx_rate(size_t chan = 0) = 0;
417 
423  virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
424 
431  virtual tune_result_t set_rx_freq(
432  const tune_request_t &tune_request, size_t chan = 0
433  ) = 0;
434 
440  virtual double get_rx_freq(size_t chan = 0) = 0;
441 
451  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
452 
458  virtual freq_range_t get_fe_rx_freq_range(size_t chan = 0) = 0;
459 
467  virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
468 
470  void set_rx_gain(double gain, size_t chan = 0){
471  return this->set_rx_gain(gain, ALL_GAINS, chan);
472  }
473 
481  virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
482 
484  double get_rx_gain(size_t chan = 0){
485  return this->get_rx_gain(ALL_GAINS, chan);
486  }
487 
495  virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
496 
498  gain_range_t get_rx_gain_range(size_t chan = 0){
499  return this->get_rx_gain_range(ALL_GAINS, chan);
500  }
501 
508  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
509 
515  virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
516 
522  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
523 
529  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
530 
536  UHD_DEPRECATED bool get_rx_lo_locked(size_t chan = 0){
537  return this->get_rx_sensor("lo_locked", chan).to_bool();
538  }
539 
545  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
546 
552  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
553 
559  virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
560 
567  UHD_DEPRECATED double read_rssi(size_t chan = 0){
568  return this->get_rx_sensor("rssi", chan).to_real();
569  }
570 
578  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
579 
586  virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
587 
593  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
594 
607  virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
608 
616  virtual void set_rx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
617 
625  virtual void set_rx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
626 
627  /*******************************************************************
628  * TX methods
629  ******************************************************************/
638  virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
639 
645  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
646 
652  virtual size_t get_tx_num_channels(void) = 0;
653 
659  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
660 
666  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
667 
673  virtual double get_tx_rate(size_t chan = 0) = 0;
674 
680  virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
681 
688  virtual tune_result_t set_tx_freq(
689  const tune_request_t &tune_request, size_t chan = 0
690  ) = 0;
691 
697  virtual double get_tx_freq(size_t chan = 0) = 0;
698 
708  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
709 
715  virtual freq_range_t get_fe_tx_freq_range(size_t chan = 0) = 0;
716 
724  virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
725 
727  void set_tx_gain(double gain, size_t chan = 0){
728  return this->set_tx_gain(gain, ALL_GAINS, chan);
729  }
730 
738  virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
739 
741  double get_tx_gain(size_t chan = 0){
742  return this->get_tx_gain(ALL_GAINS, chan);
743  }
744 
752  virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
753 
755  gain_range_t get_tx_gain_range(size_t chan = 0){
756  return this->get_tx_gain_range(ALL_GAINS, chan);
757  }
758 
765  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
766 
772  virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
773 
779  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
780 
786  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
787 
793  UHD_DEPRECATED bool get_tx_lo_locked(size_t chan = 0){
794  return this->get_tx_sensor("lo_locked", chan).to_bool();
795  }
796 
802  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
803 
809  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
810 
816  virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
817 
825  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
826 
833  virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
834 
840  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
841 
848  virtual void set_tx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
849 
857  virtual void set_tx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
858 
859 };
860 
861 }}
862 
863 #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:498
Definition: stream_cmd.hpp:46
UHD_DEPRECATED bool get_tx_lo_locked(size_t chan=0)
Definition: multi_usrp.hpp:793
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:741
#define UHD_DEPRECATED
Definition: config.hpp:68
void set_tx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall TX gain.
Definition: multi_usrp.hpp:727
Definition: time_spec.hpp:39
boost::shared_ptr< device > sptr
Definition: device.hpp:40
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:484
Definition: tune_request.hpp:32
boost::shared_ptr< rx_streamer > sptr
Definition: stream.hpp:125
static const std::string ALL_GAINS
A wildcard gain element name.
Definition: multi_usrp.hpp:105
#define UHD_API
Definition: config.hpp:76
Definition: convert.hpp:28
Definition: sensors.hpp:38
Definition: clock_config.hpp:36
Definition: multi_usrp.hpp:94
rx_streamer::sptr get_rx_stream(const stream_args_t &args)
Convenience method to get a RX streamer.
Definition: multi_usrp.hpp:122
Definition: stream.hpp:39
UHD_DEPRECATED bool get_rx_lo_locked(size_t chan=0)
Definition: multi_usrp.hpp:536
boost::shared_ptr< dboard_iface > sptr
Definition: dboard_iface.hpp:60
void set_rx_gain(double gain, size_t chan=0)
A convenience wrapper for setting overall RX gain.
Definition: multi_usrp.hpp:470
Definition: subdev_spec.hpp:66
UHD_DEPRECATED double read_rssi(size_t chan=0)
Definition: multi_usrp.hpp:567
Definition: ranges.hpp:68
boost::shared_ptr< tx_streamer > sptr
Definition: stream.hpp:182
tx_streamer::sptr get_tx_stream(const stream_args_t &args)
Convenience method to get a TX streamer.
Definition: multi_usrp.hpp:127
gain_range_t get_tx_gain_range(size_t chan=0)
A convenience wrapper for getting overall TX gain range.
Definition: multi_usrp.hpp:755
Definition: device_addr.hpp:47