UHD 003.004.003-0-unknown

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 //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
29 #include <uhd/config.hpp>
30 #include <uhd/device.hpp>
31 #include <uhd/deprecated.hpp>
32 #include <uhd/types/ranges.hpp>
33 #include <uhd/types/stream_cmd.hpp>
34 #include <uhd/types/tune_request.hpp>
35 #include <uhd/types/tune_result.hpp>
36 #include <uhd/types/sensors.hpp>
37 #include <uhd/usrp/subdev_spec.hpp>
38 #include <uhd/usrp/dboard_iface.hpp>
39 #include <boost/shared_ptr.hpp>
40 #include <boost/utility.hpp>
41 #include <complex>
42 #include <string>
43 #include <vector>
44
45 namespace uhd{ namespace usrp{
46
93 class UHD_API multi_usrp : boost::noncopyable{
94 public:
95 typedef boost::shared_ptr<multi_usrp> sptr;
96
98 static const size_t ALL_MBOARDS = size_t(~0);
99
101 static const size_t ALL_CHANS = size_t(~0);
102
104 static const std::string ALL_GAINS;
105
111 static sptr make(const device_addr_t &dev_addr);
112
118 virtual device::sptr get_device(void) = 0;
119
121 rx_streamer::sptr get_rx_stream(const stream_args_t &args){
122 return this->get_device()->get_rx_stream(args);
123 }
124
126 tx_streamer::sptr get_tx_stream(const stream_args_t &args){
127 return this->get_device()->get_tx_stream(args);
128 }
129
130 /*******************************************************************
131 * Mboard methods
132 ******************************************************************/
133
144 virtual void set_master_clock_rate(double rate, size_t mboard = ALL_MBOARDS) = 0;
145
151 virtual double get_master_clock_rate(size_t mboard = 0) = 0;
152
157 virtual std::string get_pp_string(void) = 0;
158
164 virtual std::string get_mboard_name(size_t mboard = 0) = 0;
165
171 virtual time_spec_t get_time_now(size_t mboard = 0) = 0;
172
178 virtual time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
179
191 virtual void set_time_now(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
192
205 virtual void set_time_next_pps(const time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
206
222 virtual void set_time_unknown_pps(const time_spec_t &time_spec) = 0;
223
230 virtual bool get_time_synchronized(void) = 0;
231
242 virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = ALL_MBOARDS) = 0;
243
249 virtual void clear_command_time(size_t mboard = ALL_MBOARDS) = 0;
250
263 virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd, size_t chan = ALL_CHANS) = 0;
264
273 virtual void set_clock_config(const clock_config_t &clock_config, size_t mboard = ALL_MBOARDS) = 0;
274
283 virtual void set_time_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
284
290 virtual std::string get_time_source(const size_t mboard) = 0;
291
297 virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
298
306 virtual void set_clock_source(const std::string &source, const size_t mboard = ALL_MBOARDS) = 0;
307
313 virtual std::string get_clock_source(const size_t mboard) = 0;
314
320 virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
321
325 virtual size_t get_num_mboards(void) = 0;
326
333 virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
334
340 virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
341
349 virtual void set_user_register(const boost::uint8_t addr, const boost::uint32_t data, size_t mboard = ALL_MBOARDS) = 0;
350
351 /*******************************************************************
352 * RX methods
353 ******************************************************************/
362 virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
363
369 virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t mboard = 0) = 0;
370
376 virtual size_t get_rx_num_channels(void) = 0;
377
383 virtual std::string get_rx_subdev_name(size_t chan = 0) = 0;
384
390 virtual void set_rx_rate(double rate, size_t chan = ALL_CHANS) = 0;
391
397 virtual double get_rx_rate(size_t chan = 0) = 0;
398
404 virtual meta_range_t get_rx_rates(size_t chan = 0) = 0;
405
412 virtual tune_result_t set_rx_freq(
413 const tune_request_t &tune_request, size_t chan = 0
414 ) = 0;
415
421 virtual double get_rx_freq(size_t chan = 0) = 0;
422
428 virtual freq_range_t get_rx_freq_range(size_t chan = 0) = 0;
429
437 virtual void set_rx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
438
440 void set_rx_gain(double gain, size_t chan = 0){
441 return this->set_rx_gain(gain, ALL_GAINS, chan);
442 }
443
451 virtual double get_rx_gain(const std::string &name, size_t chan = 0) = 0;
452
454 double get_rx_gain(size_t chan = 0){
455 return this->get_rx_gain(ALL_GAINS, chan);
456 }
457
465 virtual gain_range_t get_rx_gain_range(const std::string &name, size_t chan = 0) = 0;
466
468 gain_range_t get_rx_gain_range(size_t chan = 0){
469 return this->get_rx_gain_range(ALL_GAINS, chan);
470 }
471
478 virtual std::vector<std::string> get_rx_gain_names(size_t chan = 0) = 0;
479
485 virtual void set_rx_antenna(const std::string &ant, size_t chan = 0) = 0;
486
492 virtual std::string get_rx_antenna(size_t chan = 0) = 0;
493
499 virtual std::vector<std::string> get_rx_antennas(size_t chan = 0) = 0;
500
506 UHD_DEPRECATED bool get_rx_lo_locked(size_t chan = 0){
507 return this->get_rx_sensor("lo_locked", chan).to_bool();
508 }
509
515 virtual void set_rx_bandwidth(double bandwidth, size_t chan = 0) = 0;
516
522 virtual double get_rx_bandwidth(size_t chan = 0) = 0;
523
529 virtual meta_range_t get_rx_bandwidth_range(size_t chan = 0) = 0;
530
537 UHD_DEPRECATED double read_rssi(size_t chan = 0){
538 return this->get_rx_sensor("rssi", chan).to_real();
539 }
540
548 virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0;
549
556 virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0;
557
563 virtual std::vector<std::string> get_rx_sensor_names(size_t chan = 0) = 0;
564
577 virtual void set_rx_dc_offset(const bool enb, size_t chan = ALL_CHANS) = 0;
578
586 virtual void set_rx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
587
595 virtual void set_rx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
596
597 /*******************************************************************
598 * TX methods
599 ******************************************************************/
608 virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec, size_t mboard = ALL_MBOARDS) = 0;
609
615 virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t mboard = 0) = 0;
616
622 virtual size_t get_tx_num_channels(void) = 0;
623
629 virtual std::string get_tx_subdev_name(size_t chan = 0) = 0;
630
636 virtual void set_tx_rate(double rate, size_t chan = ALL_CHANS) = 0;
637
643 virtual double get_tx_rate(size_t chan = 0) = 0;
644
650 virtual meta_range_t get_tx_rates(size_t chan = 0) = 0;
651
658 virtual tune_result_t set_tx_freq(
659 const tune_request_t &tune_request, size_t chan = 0
660 ) = 0;
661
667 virtual double get_tx_freq(size_t chan = 0) = 0;
668
674 virtual freq_range_t get_tx_freq_range(size_t chan = 0) = 0;
675
683 virtual void set_tx_gain(double gain, const std::string &name, size_t chan = 0) = 0;
684
686 void set_tx_gain(double gain, size_t chan = 0){
687 return this->set_tx_gain(gain, ALL_GAINS, chan);
688 }
689
697 virtual double get_tx_gain(const std::string &name, size_t chan = 0) = 0;
698
700 double get_tx_gain(size_t chan = 0){
701 return this->get_tx_gain(ALL_GAINS, chan);
702 }
703
711 virtual gain_range_t get_tx_gain_range(const std::string &name, size_t chan = 0) = 0;
712
714 gain_range_t get_tx_gain_range(size_t chan = 0){
715 return this->get_tx_gain_range(ALL_GAINS, chan);
716 }
717
724 virtual std::vector<std::string> get_tx_gain_names(size_t chan = 0) = 0;
725
731 virtual void set_tx_antenna(const std::string &ant, size_t chan = 0) = 0;
732
738 virtual std::string get_tx_antenna(size_t chan = 0) = 0;
739
745 virtual std::vector<std::string> get_tx_antennas(size_t chan = 0) = 0;
746
752 UHD_DEPRECATED bool get_tx_lo_locked(size_t chan = 0){
753 return this->get_tx_sensor("lo_locked", chan).to_bool();
754 }
755
761 virtual void set_tx_bandwidth(double bandwidth, size_t chan = 0) = 0;
762
768 virtual double get_tx_bandwidth(size_t chan = 0) = 0;
769
775 virtual meta_range_t get_tx_bandwidth_range(size_t chan = 0) = 0;
776
784 virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0;
785
792 virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0;
793
799 virtual std::vector<std::string> get_tx_sensor_names(size_t chan = 0) = 0;
800
807 virtual void set_tx_dc_offset(const std::complex<double> &offset, size_t chan = ALL_CHANS) = 0;
808
816 virtual void set_tx_iq_balance(const std::complex<double> &correction, size_t chan = ALL_CHANS) = 0;
817
818 };
819
820 }}
821
822 #endif /* INCLUDED_UHD_USRP_MULTI_USRP_HPP */