UHD  003.001.002
multi_usrp.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2011 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 #include <uhd/config.hpp>
22 #include <uhd/device.hpp>
23 #include <uhd/types/ranges.hpp>
24 #include <uhd/types/stream_cmd.hpp>
28 #include <uhd/types/sensors.hpp>
29 #include <uhd/usrp/subdev_spec.hpp>
32 #include <boost/shared_ptr.hpp>
33 #include <boost/utility.hpp>
34 #include <vector>
35 
36 namespace uhd{ namespace usrp{
37 
84 class UHD_API multi_usrp : boost::noncopyable{
85 public:
86  typedef boost::shared_ptr<multi_usrp> sptr;
87 
89  static const size_t ALL_MBOARDS = size_t(~0);
90 
92  static const size_t ALL_CHANS = size_t(~0);
93 
95  static const std::string ALL_GAINS;
96 
102  static sptr make(const device_addr_t &dev_addr);
103 
109  virtual device::sptr get_device(void) = 0;
110 
111  /*******************************************************************
112  * Mboard methods
113  ******************************************************************/
114 
125  virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
126 
132  virtual double get_master_clock_rate(size_t mboard = 0) = 0;
133 
138  virtual std::string get_pp_string(void) = 0;
139 
145  virtual std::string get_mboard_name(size_t mboard = 0) = 0;
146 
152  virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
153 
159  virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
160 
172  virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
173 
185  virtual void set_time_next_pps(const time_spec_t &time_spec) = 0;
186 
202  virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
203 
210  virtual bool get_time_synchronized(void) = 0;
211 
224  virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
225 
233  virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
234 
238  virtual size_t get_num_mboards(void) = 0;
239 
246  virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
247 
253  virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
254 
259  virtual mboard_iface::sptr get_mboard_iface(size_t mboard) = 0;
260 
261  /*******************************************************************
262  * RX methods
263  ******************************************************************/
272  virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
273 
279  virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
280 
286  virtual size_t get_rx_num_channels(void) = 0;
287 
293  virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
294 
300  virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
301 
307  virtual double get_rx_rate(size_t chan = 0) = 0;
308 
315  virtual tune_result_t set_rx_freq(
316  const tune_request_t &tune_request, size_t chan = 0
317  ) = 0;
318 
324  virtual double get_rx_freq(size_t chan = 0) = 0;
325 
331  virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
332 
340  virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
341 
343  void set_rx_gain(double gain, size_t chan = 0){
344  return this->set_rx_gain(gain, ALL_GAINS, chan);
345  }
346 
354  virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
355 
357  double get_rx_gain(size_t chan = 0){
358  return this->get_rx_gain(ALL_GAINS, chan);
359  }
360 
368  virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
369 
371  gain_range_t get_rx_gain_range(size_t chan = 0){
372  return this->get_rx_gain_range(ALL_GAINS, chan);
373  }
374 
381  virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
382 
388  virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
389 
395  virtual std::string get_rx_antenna(size_t chan = 0) = 0;
396 
402  virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
403 
409  UHD_DEPRECATED bool get_rx_lo_locked(size_t chan = 0){
410  return this->get_rx_sensor("lo_locked", chan).to_bool();
411  }
412 
418  virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
419 
425  virtual double get_rx_bandwidth(size_t chan = 0) = 0;
426 
433  UHD_DEPRECATED double read_rssi(size_t chan = 0){
434  return this->get_rx_sensor("rssi", chan).to_real();
435  }
436 
444  virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
445 
452  virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
453 
459  virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
460 
461  /*******************************************************************
462  * TX methods
463  ******************************************************************/
472  virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
473 
479  virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
480 
486  virtual size_t get_tx_num_channels(void) = 0;
487 
493  virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
494 
500  virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
501 
507  virtual double get_tx_rate(size_t chan = 0) = 0;
508 
515  virtual tune_result_t set_tx_freq(
516  const tune_request_t &tune_request, size_t chan = 0
517  ) = 0;
518 
524  virtual double get_tx_freq(size_t chan = 0) = 0;
525 
531  virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
532 
540  virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
541 
543  void set_tx_gain(double gain, size_t chan = 0){
544  return this->set_tx_gain(gain, ALL_GAINS, chan);
545  }
546 
554  virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
555 
557  double get_tx_gain(size_t chan = 0){
558  return this->get_tx_gain(ALL_GAINS, chan);
559  }
560 
568  virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
569 
571  gain_range_t get_tx_gain_range(size_t chan = 0){
572  return this->get_tx_gain_range(ALL_GAINS, chan);
573  }
574 
581  virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
582 
588  virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
589 
595  virtual std::string get_tx_antenna(size_t chan = 0) = 0;
596 
602  virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
603 
609  UHD_DEPRECATED bool get_tx_lo_locked(size_t chan = 0){
610  return this->get_tx_sensor("lo_locked", chan).to_bool();
611  }
612 
618  virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
619 
625  virtual double get_tx_bandwidth(size_t chan = 0) = 0;
626 
634  virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
635 
642  virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
643 
649  virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
650 };
651 
652 }}
653 
654 #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:371
Definition: stream_cmd.hpp:46
UHD_DEPRECATED bool get_tx_lo_locked(size_t chan=0)
Definition: multi_usrp.hpp:609
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:557
#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:543
Definition: time_spec.hpp:39
boost::shared_ptr< device > sptr
Definition: device.hpp:40
boost::shared_ptr< multi_usrp > sptr
Definition: multi_usrp.hpp:86
double get_rx_gain(size_t chan=0)
A convenience wrapper for getting overall RX gain.
Definition: multi_usrp.hpp:357
Definition: tune_request.hpp:32
static const std::string ALL_GAINS
A wildcard gain element name.
Definition: multi_usrp.hpp:95
#define UHD_API
Definition: config.hpp:76
Definition: convert.hpp:28
Definition: sensors.hpp:38
Definition: clock_config.hpp:33
Definition: multi_usrp.hpp:84
boost::shared_ptr< mboard_iface > sptr
Definition: mboard_iface.hpp:38
UHD_DEPRECATED bool get_rx_lo_locked(size_t chan=0)
Definition: multi_usrp.hpp:409
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:343
Definition: subdev_spec.hpp:71
UHD_DEPRECATED double read_rssi(size_t chan=0)
Definition: multi_usrp.hpp:433
Definition: ranges.hpp:69
gain_range_t get_tx_gain_range(size_t chan=0)
A convenience wrapper for getting overall TX gain range.
Definition: multi_usrp.hpp:571
Definition: device_addr.hpp:47