From 9775ddc5215b0d5c950757ac6ae1d3226784f670 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 24 Jul 2010 00:02:10 -0700 Subject: usrp: added gain group support usrp2 dboard and to wrapper implementations --- host/lib/usrp/mimo_usrp.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'host/lib/usrp/mimo_usrp.cpp') diff --git a/host/lib/usrp/mimo_usrp.cpp b/host/lib/usrp/mimo_usrp.cpp index ec0f1dcc8..6b9318c39 100644 --- a/host/lib/usrp/mimo_usrp.cpp +++ b/host/lib/usrp/mimo_usrp.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -56,11 +57,13 @@ public: _rx_dboards.push_back(_mboards.back()[MBOARD_PROP_RX_DBOARD]); std::string rx_subdev_in_use = _rx_dboards.back()[DBOARD_PROP_USED_SUBDEVS].as().at(0); _rx_subdevs.push_back(_rx_dboards.back()[named_prop_t(DBOARD_PROP_SUBDEV, rx_subdev_in_use)]); + _rx_gain_groups.push_back(_rx_dboards.back()[named_prop_t(DBOARD_PROP_GAIN_GROUP, rx_subdev_in_use)].as()); //extract tx subdevice _tx_dboards.push_back(_mboards.back()[MBOARD_PROP_TX_DBOARD]); std::string tx_subdev_in_use = _tx_dboards.back()[DBOARD_PROP_USED_SUBDEVS].as().at(0); _tx_subdevs.push_back(_tx_dboards.back()[named_prop_t(DBOARD_PROP_SUBDEV, tx_subdev_in_use)]); + _tx_gain_groups.push_back(_tx_dboards.back()[named_prop_t(DBOARD_PROP_GAIN_GROUP, tx_subdev_in_use)].as()); } //set the clock config across all mboards (TODO set through api) @@ -201,15 +204,15 @@ public: } void set_rx_gain(size_t chan, float gain){ - _rx_subdevs.at(chan)[SUBDEV_PROP_GAIN] = gain; + _rx_gain_groups.at(chan)->set_value(gain); } float get_rx_gain(size_t chan){ - return _rx_subdevs.at(chan)[SUBDEV_PROP_GAIN].as(); + return _rx_gain_groups.at(chan)->get_value(); } gain_range_t get_rx_gain_range(size_t chan){ - return _rx_subdevs.at(chan)[SUBDEV_PROP_GAIN_RANGE].as(); + return _rx_gain_groups.at(chan)->get_range(); } void set_rx_antenna(size_t chan, const std::string &ant){ @@ -268,15 +271,15 @@ public: } void set_tx_gain(size_t chan, float gain){ - _tx_subdevs.at(chan)[SUBDEV_PROP_GAIN] = gain; + _tx_gain_groups.at(chan)->set_value(gain); } float get_tx_gain(size_t chan){ - return _tx_subdevs.at(chan)[SUBDEV_PROP_GAIN].as(); + return _tx_gain_groups.at(chan)->get_value(); } gain_range_t get_tx_gain_range(size_t chan){ - return _tx_subdevs.at(chan)[SUBDEV_PROP_GAIN_RANGE].as(); + return _tx_gain_groups.at(chan)->get_range(); } void set_tx_antenna(size_t chan, const std::string &ant){ @@ -304,6 +307,8 @@ private: std::vector _tx_dboards; std::vector _rx_subdevs; std::vector _tx_subdevs; + std::vector _rx_gain_groups; + std::vector _tx_gain_groups; //shadows double _rx_rate, _tx_rate; -- cgit v1.2.3 From a333a01ac0d1d0cb011d52f04bed2534a708f944 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 5 Aug 2010 16:27:16 -0700 Subject: uhd: implemented subdev spec in mimo and simple usrp wrappers. implemented subdev spec in usrp2 mboard impl removed subdevs used in dboard impl --- host/include/uhd/usrp/dboard_props.hpp | 1 - host/include/uhd/usrp/mboard_props.hpp | 2 + host/include/uhd/usrp/mimo_usrp.hpp | 5 + host/include/uhd/usrp/simple_usrp.hpp | 5 + host/lib/usrp/mimo_usrp.cpp | 169 ++++++++++++++++++--------------- host/lib/usrp/simple_usrp.cpp | 131 +++++++++++++------------ host/lib/usrp/usrp2/dboard_impl.cpp | 32 ------- host/lib/usrp/usrp2/mboard_impl.cpp | 46 +++++++++ host/lib/usrp/usrp2/usrp2_impl.hpp | 4 +- 9 files changed, 223 insertions(+), 172 deletions(-) (limited to 'host/lib/usrp/mimo_usrp.cpp') diff --git a/host/include/uhd/usrp/dboard_props.hpp b/host/include/uhd/usrp/dboard_props.hpp index 4d5c5efbd..8a6ef9129 100644 --- a/host/include/uhd/usrp/dboard_props.hpp +++ b/host/include/uhd/usrp/dboard_props.hpp @@ -29,7 +29,6 @@ namespace uhd{ namespace usrp{ DBOARD_PROP_NAME = 'n', //ro, std::string DBOARD_PROP_SUBDEV = 's', //ro, wax::obj DBOARD_PROP_SUBDEV_NAMES = 'S', //ro, prop_names_t - DBOARD_PROP_USED_SUBDEVS = 'u', //ro, prop_names_t DBOARD_PROP_DBOARD_ID = 'i', //rw, dboard_id_t DBOARD_PROP_DBOARD_IFACE = 'f' //ro, dboard_iface::sptr //DBOARD_PROP_CODEC //ro, wax::obj //----> not sure, dont have to deal with yet diff --git a/host/include/uhd/usrp/mboard_props.hpp b/host/include/uhd/usrp/mboard_props.hpp index a432ce50c..0f250f439 100644 --- a/host/include/uhd/usrp/mboard_props.hpp +++ b/host/include/uhd/usrp/mboard_props.hpp @@ -39,6 +39,8 @@ namespace uhd{ namespace usrp{ MBOARD_PROP_RX_DBOARD_NAMES = 'E', //ro, prop_names_t MBOARD_PROP_TX_DBOARD = 'v', //ro, wax::obj MBOARD_PROP_TX_DBOARD_NAMES = 'V', //ro, prop_names_t + MBOARD_PROP_RX_SUBDEV_SPEC = 'r', //rw, subdev_spec_t + MBOARD_PROP_TX_SUBDEV_SPEC = 'R', //rw, subdev_spec_t MBOARD_PROP_CLOCK_CONFIG = 'C', //rw, clock_config_t MBOARD_PROP_TIME_NOW = 't', //rw, time_spec_t MBOARD_PROP_TIME_NEXT_PPS = 'T', //wo, time_spec_t diff --git a/host/include/uhd/usrp/mimo_usrp.hpp b/host/include/uhd/usrp/mimo_usrp.hpp index fd0f4596f..9856f9d32 100644 --- a/host/include/uhd/usrp/mimo_usrp.hpp +++ b/host/include/uhd/usrp/mimo_usrp.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -119,6 +120,8 @@ public: /******************************************************************* * RX methods ******************************************************************/ + virtual void set_rx_subdev_spec(size_t chan, const uhd::usrp::subdev_spec_t &spec) = 0; + virtual void set_rx_rate_all(double rate) = 0; virtual double get_rx_rate_all(void) = 0; @@ -148,6 +151,8 @@ public: /******************************************************************* * TX methods ******************************************************************/ + virtual void set_tx_subdev_spec(size_t chan, const uhd::usrp::subdev_spec_t &spec) = 0; + virtual void set_tx_rate_all(double rate) = 0; virtual double get_tx_rate_all(void) = 0; diff --git a/host/include/uhd/usrp/simple_usrp.hpp b/host/include/uhd/usrp/simple_usrp.hpp index a100579ce..a6275cfcc 100644 --- a/host/include/uhd/usrp/simple_usrp.hpp +++ b/host/include/uhd/usrp/simple_usrp.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -107,6 +108,8 @@ public: /******************************************************************* * RX methods ******************************************************************/ + virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec) = 0; + virtual void set_rx_rate(double rate) = 0; virtual double get_rx_rate(void) = 0; @@ -135,6 +138,8 @@ public: /******************************************************************* * TX methods ******************************************************************/ + virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec) = 0; + virtual void set_tx_rate(double rate) = 0; virtual double get_tx_rate(void) = 0; diff --git a/host/lib/usrp/mimo_usrp.cpp b/host/lib/usrp/mimo_usrp.cpp index ec0f1dcc8..5fb3571ec 100644 --- a/host/lib/usrp/mimo_usrp.cpp +++ b/host/lib/usrp/mimo_usrp.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -46,29 +47,12 @@ public: mimo_usrp_impl(const device_addr_t &addr){ _dev = device::make(addr); - //extract each mboard and its sub-devices - BOOST_FOREACH(const std::string &name, (*_dev)[DEVICE_PROP_MBOARD_NAMES].as()){ - _mboards.push_back((*_dev)[named_prop_t(DEVICE_PROP_MBOARD, name)]); - _rx_dsps.push_back(_mboards.back()[MBOARD_PROP_RX_DSP]); - _tx_dsps.push_back(_mboards.back()[MBOARD_PROP_TX_DSP]); - - //extract rx subdevice - _rx_dboards.push_back(_mboards.back()[MBOARD_PROP_RX_DBOARD]); - std::string rx_subdev_in_use = _rx_dboards.back()[DBOARD_PROP_USED_SUBDEVS].as().at(0); - _rx_subdevs.push_back(_rx_dboards.back()[named_prop_t(DBOARD_PROP_SUBDEV, rx_subdev_in_use)]); - - //extract tx subdevice - _tx_dboards.push_back(_mboards.back()[MBOARD_PROP_TX_DBOARD]); - std::string tx_subdev_in_use = _tx_dboards.back()[DBOARD_PROP_USED_SUBDEVS].as().at(0); - _tx_subdevs.push_back(_tx_dboards.back()[named_prop_t(DBOARD_PROP_SUBDEV, tx_subdev_in_use)]); - } - //set the clock config across all mboards (TODO set through api) clock_config_t clock_config; clock_config.ref_source = clock_config_t::REF_SMA; clock_config.pps_source = clock_config_t::PPS_SMA; - BOOST_FOREACH(wax::obj mboard, _mboards){ - mboard[MBOARD_PROP_CLOCK_CONFIG] = clock_config; + for (size_t chan = 0; chan < get_num_channels(); chan++){ + _mboard(chan)[MBOARD_PROP_CLOCK_CONFIG] = clock_config; } } @@ -87,7 +71,7 @@ public: ) % (*_dev)[DEVICE_PROP_NAME].as() ); - for (size_t i = 0; i < get_num_channels(); i++){ + for (size_t chan = 0; chan < get_num_channels(); chan++){ buff += str(boost::format( " Channel: %u\n" " Mboard: %s\n" @@ -97,21 +81,21 @@ public: " TX DSP: %s\n" " TX Dboard: %s\n" " TX Subdev: %s\n" - ) % i - % _mboards.at(i)[MBOARD_PROP_NAME].as() - % _rx_dsps.at(i)[DSP_PROP_NAME].as() - % _rx_dboards.at(i)[DBOARD_PROP_NAME].as() - % _rx_subdevs.at(i)[SUBDEV_PROP_NAME].as() - % _tx_dsps.at(i)[DSP_PROP_NAME].as() - % _tx_dboards.at(i)[DBOARD_PROP_NAME].as() - % _tx_subdevs.at(i)[SUBDEV_PROP_NAME].as() + ) % chan + % _mboard(chan)[MBOARD_PROP_NAME].as() + % _rx_dsp(chan)[DSP_PROP_NAME].as() + % _rx_dboard(chan)[DBOARD_PROP_NAME].as() + % _rx_subdev(chan)[SUBDEV_PROP_NAME].as() + % _tx_dsp(chan)[DSP_PROP_NAME].as() + % _tx_dboard(chan)[DBOARD_PROP_NAME].as() + % _tx_subdev(chan)[SUBDEV_PROP_NAME].as() ); } return buff; } size_t get_num_channels(void){ - return _mboards.size(); + return (*_dev)[DEVICE_PROP_MBOARD_NAMES].as().size(); } /******************************************************************* @@ -119,12 +103,12 @@ public: ******************************************************************/ time_spec_t get_time_now(void){ //the time on the first mboard better be the same on all - return _mboards.front()[MBOARD_PROP_TIME_NOW].as(); + return _mboard(0)[MBOARD_PROP_TIME_NOW].as(); } void set_time_next_pps(const time_spec_t &time_spec){ - BOOST_FOREACH(wax::obj mboard, _mboards){ - mboard[MBOARD_PROP_TIME_NEXT_PPS] = time_spec; + for (size_t chan = 0; chan < get_num_channels(); chan++){ + _mboard(chan)[MBOARD_PROP_TIME_NEXT_PPS] = time_spec; } } @@ -146,33 +130,38 @@ public: boost::this_thread::sleep(boost::posix_time::seconds(1)); //verify that the time registers are read to be within a few RTT - for (size_t i = 1; i < get_num_channels(); i++){ - time_spec_t time_0 = _mboards.front()[MBOARD_PROP_TIME_NOW].as(); - time_spec_t time_i = _mboards.at(i)[MBOARD_PROP_TIME_NOW].as(); + for (size_t chan = 1; chan < get_num_channels(); chan++){ + time_spec_t time_0 = _mboard(0)[MBOARD_PROP_TIME_NOW].as(); + time_spec_t time_i = _mboard(chan)[MBOARD_PROP_TIME_NOW].as(); if (time_i < time_0 or (time_i - time_0) > time_spec_t(0.01)){ //10 ms: greater than RTT but not too big - std::cerr << boost::format( - "Error: time deviation between board %d and board 0.\n" - " Board 0 time is %f seconds.\n" - " Board %d time is %f seconds.\n" - ) % i % time_0.get_real_secs() % i % time_i.get_real_secs() << std::endl; + uhd::print_warning(str(boost::format( + "Detected time deviation between board %d and board 0.\n" + "Board 0 time is %f seconds.\n" + "Board %d time is %f seconds.\n" + ) % chan % time_0.get_real_secs() % chan % time_i.get_real_secs())); } } } void issue_stream_cmd(const stream_cmd_t &stream_cmd){ - BOOST_FOREACH(wax::obj mboard, _mboards){ - mboard[MBOARD_PROP_STREAM_CMD] = stream_cmd; + for (size_t chan = 0; chan < get_num_channels(); chan++){ + _mboard(chan)[MBOARD_PROP_STREAM_CMD] = stream_cmd; } } /******************************************************************* * RX methods ******************************************************************/ + void set_rx_subdev_spec(size_t chan, const uhd::usrp::subdev_spec_t &spec){ + UHD_ASSERT_THROW(spec.size() <= 1); + _mboard(chan)[MBOARD_PROP_RX_SUBDEV_SPEC] = spec; + } + void set_rx_rate_all(double rate){ std::vector _actual_rates; - BOOST_FOREACH(wax::obj rx_dsp, _rx_dsps){ - rx_dsp[DSP_PROP_HOST_RATE] = rate; - _actual_rates.push_back(rx_dsp[DSP_PROP_HOST_RATE].as()); + for (size_t chan = 0; chan < get_num_channels(); chan++){ + _rx_dsp(chan)[DSP_PROP_HOST_RATE] = rate; + _actual_rates.push_back(_rx_dsp(chan)[DSP_PROP_HOST_RATE].as()); } _rx_rate = _actual_rates.front(); if (std::count(_actual_rates, _rx_rate) != _actual_rates.size()) throw std::runtime_error( @@ -185,61 +174,66 @@ public: } tune_result_t set_rx_freq(size_t chan, double target_freq){ - return tune_rx_subdev_and_dsp(_rx_subdevs.at(chan), _rx_dsps.at(chan), target_freq); + return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), target_freq); } tune_result_t set_rx_freq(size_t chan, double target_freq, double lo_off){ - return tune_rx_subdev_and_dsp(_rx_subdevs.at(chan), _rx_dsps.at(chan), target_freq, lo_off); + return tune_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan), target_freq, lo_off); } double get_rx_freq(size_t chan){ - return derive_freq_from_rx_subdev_and_dsp(_rx_subdevs.at(chan), _rx_dsps.at(chan)); + return derive_freq_from_rx_subdev_and_dsp(_rx_subdev(chan), _rx_dsp(chan)); } freq_range_t get_rx_freq_range(size_t chan){ - return add_dsp_shift(_rx_subdevs.at(chan)[SUBDEV_PROP_FREQ_RANGE].as(), _rx_dsps.at(chan)); + return add_dsp_shift(_rx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as(), _rx_dsp(chan)); } void set_rx_gain(size_t chan, float gain){ - _rx_subdevs.at(chan)[SUBDEV_PROP_GAIN] = gain; + _rx_subdev(chan)[SUBDEV_PROP_GAIN] = gain; } float get_rx_gain(size_t chan){ - return _rx_subdevs.at(chan)[SUBDEV_PROP_GAIN].as(); + return _rx_subdev(chan)[SUBDEV_PROP_GAIN].as(); } gain_range_t get_rx_gain_range(size_t chan){ - return _rx_subdevs.at(chan)[SUBDEV_PROP_GAIN_RANGE].as(); + return _rx_subdev(chan)[SUBDEV_PROP_GAIN_RANGE].as(); } void set_rx_antenna(size_t chan, const std::string &ant){ - _rx_subdevs.at(chan)[SUBDEV_PROP_ANTENNA] = ant; + _rx_subdev(chan)[SUBDEV_PROP_ANTENNA] = ant; } std::string get_rx_antenna(size_t chan){ - return _rx_subdevs.at(chan)[SUBDEV_PROP_ANTENNA].as(); + return _rx_subdev(chan)[SUBDEV_PROP_ANTENNA].as(); } std::vector get_rx_antennas(size_t chan){ - return _rx_subdevs.at(chan)[SUBDEV_PROP_ANTENNA_NAMES].as(); + return _rx_subdev(chan)[SUBDEV_PROP_ANTENNA_NAMES].as(); } bool get_rx_lo_locked(size_t chan){ - return _rx_subdevs.at(chan)[SUBDEV_PROP_LO_LOCKED].as(); + return _rx_subdev(chan)[SUBDEV_PROP_LO_LOCKED].as(); } float read_rssi(size_t chan){ - return _rx_subdevs.at(chan)[SUBDEV_PROP_RSSI].as(); + return _rx_subdev(chan)[SUBDEV_PROP_RSSI].as(); } /******************************************************************* * TX methods ******************************************************************/ + void set_tx_subdev_spec(size_t chan, const uhd::usrp::subdev_spec_t &spec){ + UHD_ASSERT_THROW(spec.size() <= 1); + _mboard(chan)[MBOARD_PROP_TX_SUBDEV_SPEC] = spec; + } + void set_tx_rate_all(double rate){ std::vector _actual_rates; - BOOST_FOREACH(wax::obj tx_dsp, _tx_dsps){ - tx_dsp[DSP_PROP_HOST_RATE] = rate; - _actual_rates.push_back(tx_dsp[DSP_PROP_HOST_RATE].as()); + for (size_t chan = 0; chan < get_num_channels(); chan++){ + _tx_dsp(chan)[DSP_PROP_HOST_RATE] = rate; + _actual_rates.push_back(_tx_dsp(chan)[DSP_PROP_HOST_RATE].as()); } _tx_rate = _actual_rates.front(); if (std::count(_actual_rates, _tx_rate) != _actual_rates.size()) throw std::runtime_error( @@ -252,58 +246,77 @@ public: } tune_result_t set_tx_freq(size_t chan, double target_freq){ - return tune_tx_subdev_and_dsp(_tx_subdevs.at(chan), _tx_dsps.at(chan), target_freq); + return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), target_freq); } tune_result_t set_tx_freq(size_t chan, double target_freq, double lo_off){ - return tune_tx_subdev_and_dsp(_tx_subdevs.at(chan), _tx_dsps.at(chan), target_freq, lo_off); + return tune_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan), target_freq, lo_off); } double get_tx_freq(size_t chan){ - return derive_freq_from_tx_subdev_and_dsp(_tx_subdevs.at(chan), _tx_dsps.at(chan)); + return derive_freq_from_tx_subdev_and_dsp(_tx_subdev(chan), _tx_dsp(chan)); } freq_range_t get_tx_freq_range(size_t chan){ - return add_dsp_shift(_tx_subdevs.at(chan)[SUBDEV_PROP_FREQ_RANGE].as(), _tx_dsps.at(chan)); + return add_dsp_shift(_tx_subdev(chan)[SUBDEV_PROP_FREQ_RANGE].as(), _tx_dsp(chan)); } void set_tx_gain(size_t chan, float gain){ - _tx_subdevs.at(chan)[SUBDEV_PROP_GAIN] = gain; + _tx_subdev(chan)[SUBDEV_PROP_GAIN] = gain; } float get_tx_gain(size_t chan){ - return _tx_subdevs.at(chan)[SUBDEV_PROP_GAIN].as(); + return _tx_subdev(chan)[SUBDEV_PROP_GAIN].as(); } gain_range_t get_tx_gain_range(size_t chan){ - return _tx_subdevs.at(chan)[SUBDEV_PROP_GAIN_RANGE].as(); + return _tx_subdev(chan)[SUBDEV_PROP_GAIN_RANGE].as(); } void set_tx_antenna(size_t chan, const std::string &ant){ - _tx_subdevs.at(chan)[SUBDEV_PROP_ANTENNA] = ant; + _tx_subdev(chan)[SUBDEV_PROP_ANTENNA] = ant; } std::string get_tx_antenna(size_t chan){ - return _tx_subdevs.at(chan)[SUBDEV_PROP_ANTENNA].as(); + return _tx_subdev(chan)[SUBDEV_PROP_ANTENNA].as(); } std::vector get_tx_antennas(size_t chan){ - return _tx_subdevs.at(chan)[SUBDEV_PROP_ANTENNA_NAMES].as(); + return _tx_subdev(chan)[SUBDEV_PROP_ANTENNA_NAMES].as(); } bool get_tx_lo_locked(size_t chan){ - return _tx_subdevs.at(chan)[SUBDEV_PROP_LO_LOCKED].as(); + return _tx_subdev(chan)[SUBDEV_PROP_LO_LOCKED].as(); } private: device::sptr _dev; - std::vector _mboards; - std::vector _rx_dsps; - std::vector _tx_dsps; - std::vector _rx_dboards; - std::vector _tx_dboards; - std::vector _rx_subdevs; - std::vector _tx_subdevs; + wax::obj _mboard(size_t chan){ + prop_names_t names = (*_dev)[DEVICE_PROP_MBOARD_NAMES].as(); + return (*_dev)[named_prop_t(DEVICE_PROP_MBOARD, names.at(chan))]; + } + wax::obj _rx_dsp(size_t chan){ + return _mboard(chan)[MBOARD_PROP_RX_DSP]; + } + wax::obj _tx_dsp(size_t chan){ + return _mboard(chan)[MBOARD_PROP_TX_DSP]; + } + wax::obj _rx_dboard(size_t chan){ + std::string db_name = _mboard(chan)[MBOARD_PROP_RX_SUBDEV_SPEC].as().front().first; + return _mboard(chan)[named_prop_t(MBOARD_PROP_RX_DBOARD, db_name)]; + } + wax::obj _tx_dboard(size_t chan){ + std::string db_name = _mboard(chan)[MBOARD_PROP_TX_SUBDEV_SPEC].as().front().first; + return _mboard(chan)[named_prop_t(MBOARD_PROP_TX_DBOARD, db_name)]; + } + wax::obj _rx_subdev(size_t chan){ + std::string sd_name = _mboard(chan)[MBOARD_PROP_RX_SUBDEV_SPEC].as().front().first; + return _rx_dboard(chan)[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)]; + } + wax::obj _tx_subdev(size_t chan){ + std::string sd_name = _mboard(chan)[MBOARD_PROP_TX_SUBDEV_SPEC].as().front().first; + return _tx_dboard(chan)[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)]; + } //shadows double _rx_rate, _tx_rate; diff --git a/host/lib/usrp/simple_usrp.cpp b/host/lib/usrp/simple_usrp.cpp index 5cb9511f4..1606ad2e8 100644 --- a/host/lib/usrp/simple_usrp.cpp +++ b/host/lib/usrp/simple_usrp.cpp @@ -42,19 +42,6 @@ class simple_usrp_impl : public simple_usrp{ public: simple_usrp_impl(const device_addr_t &addr){ _dev = device::make(addr); - _mboard = (*_dev)[DEVICE_PROP_MBOARD]; - _rx_dsp = _mboard[MBOARD_PROP_RX_DSP]; - _tx_dsp = _mboard[MBOARD_PROP_TX_DSP]; - - //extract rx subdevice - _rx_dboard = _mboard[MBOARD_PROP_RX_DBOARD]; - std::string rx_subdev_in_use = _rx_dboard[DBOARD_PROP_USED_SUBDEVS].as().at(0); - _rx_subdev = _rx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, rx_subdev_in_use)]; - - //extract tx subdevice - _tx_dboard = _mboard[MBOARD_PROP_TX_DBOARD]; - std::string tx_subdev_in_use = _tx_dboard[DBOARD_PROP_USED_SUBDEVS].as().at(0); - _tx_subdev = _tx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, tx_subdev_in_use)]; } ~simple_usrp_impl(void){ @@ -78,13 +65,13 @@ public: " TX Subdev: %s\n" ) % (*_dev)[DEVICE_PROP_NAME].as() - % _mboard[MBOARD_PROP_NAME].as() - % _rx_dsp[DSP_PROP_NAME].as() - % _rx_dboard[DBOARD_PROP_NAME].as() - % _rx_subdev[SUBDEV_PROP_NAME].as() - % _tx_dsp[DSP_PROP_NAME].as() - % _tx_dboard[DBOARD_PROP_NAME].as() - % _tx_subdev[SUBDEV_PROP_NAME].as() + % _mboard()[MBOARD_PROP_NAME].as() + % _rx_dsp()[DSP_PROP_NAME].as() + % _rx_dboard()[DBOARD_PROP_NAME].as() + % _rx_subdev()[SUBDEV_PROP_NAME].as() + % _tx_dsp()[DSP_PROP_NAME].as() + % _tx_dboard()[DBOARD_PROP_NAME].as() + % _tx_subdev()[SUBDEV_PROP_NAME].as() ); } @@ -92,148 +79,174 @@ public: * Misc ******************************************************************/ time_spec_t get_time_now(void){ - return _mboard[MBOARD_PROP_TIME_NOW].as(); + return _mboard()[MBOARD_PROP_TIME_NOW].as(); } void set_time_now(const time_spec_t &time_spec){ - _mboard[MBOARD_PROP_TIME_NOW] = time_spec; + _mboard()[MBOARD_PROP_TIME_NOW] = time_spec; } void set_time_next_pps(const time_spec_t &time_spec){ - _mboard[MBOARD_PROP_TIME_NEXT_PPS] = time_spec; + _mboard()[MBOARD_PROP_TIME_NEXT_PPS] = time_spec; } void issue_stream_cmd(const stream_cmd_t &stream_cmd){ - _mboard[MBOARD_PROP_STREAM_CMD] = stream_cmd; + _mboard()[MBOARD_PROP_STREAM_CMD] = stream_cmd; } void set_clock_config(const clock_config_t &clock_config){ - _mboard[MBOARD_PROP_CLOCK_CONFIG] = clock_config; + _mboard()[MBOARD_PROP_CLOCK_CONFIG] = clock_config; } /******************************************************************* * RX methods ******************************************************************/ + void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){ + _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC] = spec; + } + void set_rx_rate(double rate){ - _rx_dsp[DSP_PROP_HOST_RATE] = rate; + _rx_dsp()[DSP_PROP_HOST_RATE] = rate; } double get_rx_rate(void){ - return _rx_dsp[DSP_PROP_HOST_RATE].as(); + return _rx_dsp()[DSP_PROP_HOST_RATE].as(); } tune_result_t set_rx_freq(double target_freq){ - return tune_rx_subdev_and_dsp(_rx_subdev, _rx_dsp, target_freq); + return tune_rx_subdev_and_dsp(_rx_subdev(), _rx_dsp(), target_freq); } tune_result_t set_rx_freq(double target_freq, double lo_off){ - return tune_rx_subdev_and_dsp(_rx_subdev, _rx_dsp, target_freq, lo_off); + return tune_rx_subdev_and_dsp(_rx_subdev(), _rx_dsp(), target_freq, lo_off); } double get_rx_freq(void){ - return derive_freq_from_rx_subdev_and_dsp(_rx_subdev, _rx_dsp); + return derive_freq_from_rx_subdev_and_dsp(_rx_subdev(), _rx_dsp()); } freq_range_t get_rx_freq_range(void){ - return add_dsp_shift(_rx_subdev[SUBDEV_PROP_FREQ_RANGE].as(), _rx_dsp); + return add_dsp_shift(_rx_subdev()[SUBDEV_PROP_FREQ_RANGE].as(), _rx_dsp()); } void set_rx_gain(float gain){ - _rx_subdev[SUBDEV_PROP_GAIN] = gain; + _rx_subdev()[SUBDEV_PROP_GAIN] = gain; } float get_rx_gain(void){ - return _rx_subdev[SUBDEV_PROP_GAIN].as(); + return _rx_subdev()[SUBDEV_PROP_GAIN].as(); } gain_range_t get_rx_gain_range(void){ - return _rx_subdev[SUBDEV_PROP_GAIN_RANGE].as(); + return _rx_subdev()[SUBDEV_PROP_GAIN_RANGE].as(); } void set_rx_antenna(const std::string &ant){ - _rx_subdev[SUBDEV_PROP_ANTENNA] = ant; + _rx_subdev()[SUBDEV_PROP_ANTENNA] = ant; } std::string get_rx_antenna(void){ - return _rx_subdev[SUBDEV_PROP_ANTENNA].as(); + return _rx_subdev()[SUBDEV_PROP_ANTENNA].as(); } std::vector get_rx_antennas(void){ - return _rx_subdev[SUBDEV_PROP_ANTENNA_NAMES].as(); + return _rx_subdev()[SUBDEV_PROP_ANTENNA_NAMES].as(); } bool get_rx_lo_locked(void){ - return _rx_subdev[SUBDEV_PROP_LO_LOCKED].as(); + return _rx_subdev()[SUBDEV_PROP_LO_LOCKED].as(); } float read_rssi(void){ - return _rx_subdev[SUBDEV_PROP_RSSI].as(); + return _rx_subdev()[SUBDEV_PROP_RSSI].as(); } /******************************************************************* * TX methods ******************************************************************/ + void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){ + _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC] = spec; + } + void set_tx_rate(double rate){ - _tx_dsp[DSP_PROP_HOST_RATE] = rate; + _tx_dsp()[DSP_PROP_HOST_RATE] = rate; } double get_tx_rate(void){ - return _tx_dsp[DSP_PROP_HOST_RATE].as(); + return _tx_dsp()[DSP_PROP_HOST_RATE].as(); } tune_result_t set_tx_freq(double target_freq){ - return tune_tx_subdev_and_dsp(_tx_subdev, _tx_dsp, target_freq); + return tune_tx_subdev_and_dsp(_tx_subdev(), _tx_dsp(), target_freq); } tune_result_t set_tx_freq(double target_freq, double lo_off){ - return tune_tx_subdev_and_dsp(_tx_subdev, _tx_dsp, target_freq, lo_off); + return tune_tx_subdev_and_dsp(_tx_subdev(), _tx_dsp(), target_freq, lo_off); } double get_tx_freq(void){ - return derive_freq_from_tx_subdev_and_dsp(_tx_subdev, _tx_dsp); + return derive_freq_from_tx_subdev_and_dsp(_tx_subdev(), _tx_dsp()); } freq_range_t get_tx_freq_range(void){ - return add_dsp_shift(_tx_subdev[SUBDEV_PROP_FREQ_RANGE].as(), _tx_dsp); + return add_dsp_shift(_tx_subdev()[SUBDEV_PROP_FREQ_RANGE].as(), _tx_dsp()); } void set_tx_gain(float gain){ - _tx_subdev[SUBDEV_PROP_GAIN] = gain; + _tx_subdev()[SUBDEV_PROP_GAIN] = gain; } float get_tx_gain(void){ - return _tx_subdev[SUBDEV_PROP_GAIN].as(); + return _tx_subdev()[SUBDEV_PROP_GAIN].as(); } gain_range_t get_tx_gain_range(void){ - return _tx_subdev[SUBDEV_PROP_GAIN_RANGE].as(); + return _tx_subdev()[SUBDEV_PROP_GAIN_RANGE].as(); } void set_tx_antenna(const std::string &ant){ - _tx_subdev[SUBDEV_PROP_ANTENNA] = ant; + _tx_subdev()[SUBDEV_PROP_ANTENNA] = ant; } std::string get_tx_antenna(void){ - return _tx_subdev[SUBDEV_PROP_ANTENNA].as(); + return _tx_subdev()[SUBDEV_PROP_ANTENNA].as(); } std::vector get_tx_antennas(void){ - return _tx_subdev[SUBDEV_PROP_ANTENNA_NAMES].as(); + return _tx_subdev()[SUBDEV_PROP_ANTENNA_NAMES].as(); } bool get_tx_lo_locked(void){ - return _tx_subdev[SUBDEV_PROP_LO_LOCKED].as(); + return _tx_subdev()[SUBDEV_PROP_LO_LOCKED].as(); } private: device::sptr _dev; - wax::obj _mboard; - wax::obj _rx_dsp; - wax::obj _tx_dsp; - wax::obj _rx_dboard; - wax::obj _tx_dboard; - wax::obj _rx_subdev; - wax::obj _tx_subdev; + wax::obj _mboard(void){ + return (*_dev)[DEVICE_PROP_MBOARD]; + } + wax::obj _rx_dsp(void){ + return _mboard()[MBOARD_PROP_RX_DSP]; + } + wax::obj _tx_dsp(void){ + return _mboard()[MBOARD_PROP_TX_DSP]; + } + wax::obj _rx_dboard(void){ + std::string db_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as().front().first; + return _mboard()[named_prop_t(MBOARD_PROP_RX_DBOARD, db_name)]; + } + wax::obj _tx_dboard(void){ + std::string db_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as().front().first; + return _mboard()[named_prop_t(MBOARD_PROP_TX_DBOARD, db_name)]; + } + wax::obj _rx_subdev(void){ + std::string sd_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as().front().first; + return _rx_dboard()[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)]; + } + wax::obj _tx_subdev(void){ + std::string sd_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as().front().first; + return _tx_dboard()[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)]; + } }; /*********************************************************************** diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp index 0aeb0ec1a..8f6182fb5 100644 --- a/host/lib/usrp/usrp2/dboard_impl.cpp +++ b/host/lib/usrp/usrp2/dboard_impl.cpp @@ -53,10 +53,6 @@ void usrp2_mboard_impl::dboard_init(void){ boost::bind(&usrp2_mboard_impl::tx_dboard_get, this, _1, _2), boost::bind(&usrp2_mboard_impl::tx_dboard_set, this, _1, _2) ); - - //init the subdevs in use (use the first subdevice) - rx_dboard_set(DBOARD_PROP_USED_SUBDEVS, prop_names_t(1, _dboard_manager->get_rx_subdev_names().at(0))); - tx_dboard_set(DBOARD_PROP_USED_SUBDEVS, prop_names_t(1, _dboard_manager->get_tx_subdev_names().at(0))); } /*********************************************************************** @@ -80,10 +76,6 @@ void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){ val = _dboard_manager->get_rx_subdev_names(); return; - case DBOARD_PROP_USED_SUBDEVS: - val = _rx_subdevs_in_use; - return; - case DBOARD_PROP_DBOARD_ID: val = _rx_db_eeprom.id; return; @@ -98,16 +90,6 @@ void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){ void usrp2_mboard_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){ switch(key.as()){ - case DBOARD_PROP_USED_SUBDEVS:{ - _rx_subdevs_in_use = val.as(); - UHD_ASSERT_THROW(_rx_subdevs_in_use.size() == 1); - wax::obj rx_subdev = _dboard_manager->get_rx_subdev(_rx_subdevs_in_use.at(0)); - std::cout << "Using: " << rx_subdev[SUBDEV_PROP_NAME].as() << std::endl; - _iface->poke32(U2_REG_DSP_RX_MUX, dsp_type1::calc_rx_mux_word( - rx_subdev[SUBDEV_PROP_CONNECTION].as() - )); - } - return; case DBOARD_PROP_DBOARD_ID: _rx_db_eeprom.id = val.as(); @@ -139,10 +121,6 @@ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){ val = _dboard_manager->get_tx_subdev_names(); return; - case DBOARD_PROP_USED_SUBDEVS: - val = _tx_subdevs_in_use; - return; - case DBOARD_PROP_DBOARD_ID: val = _tx_db_eeprom.id; return; @@ -157,16 +135,6 @@ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){ void usrp2_mboard_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val){ switch(key.as()){ - case DBOARD_PROP_USED_SUBDEVS:{ - _tx_subdevs_in_use = val.as(); - UHD_ASSERT_THROW(_tx_subdevs_in_use.size() == 1); - wax::obj tx_subdev = _dboard_manager->get_tx_subdev(_tx_subdevs_in_use.at(0)); - std::cout << "Using: " << tx_subdev[SUBDEV_PROP_NAME].as() << std::endl; - _iface->poke32(U2_REG_DSP_TX_MUX, dsp_type1::calc_tx_mux_word( - tx_subdev[SUBDEV_PROP_CONNECTION].as() - )); - } - return; case DBOARD_PROP_DBOARD_ID: _tx_db_eeprom.id = val.as(); diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 7694a164d..c35171fec 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -99,6 +99,10 @@ usrp2_mboard_impl::usrp2_mboard_impl( //init the tx and rx dboards (do last) dboard_init(); + //set default subdev specs + (*this)[MBOARD_PROP_RX_SUBDEV_SPEC] = subdev_spec_t(); + (*this)[MBOARD_PROP_TX_SUBDEV_SPEC] = subdev_spec_t(); + //Issue a stop streaming command (in case it was left running). //Since this command is issued before the networking is setup, //most if not all junk packets will never make it to the socket. @@ -263,6 +267,14 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ } return; + case MBOARD_PROP_RX_SUBDEV_SPEC: + val = _rx_subdev_spec; + return; + + case MBOARD_PROP_TX_SUBDEV_SPEC: + val = _tx_subdev_spec; + return; + default: UHD_THROW_PROP_GET_ERROR(); } } @@ -307,6 +319,40 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){ issue_ddc_stream_cmd(val.as()); return; + case MBOARD_PROP_RX_SUBDEV_SPEC: + _rx_subdev_spec = val.as(); + //handle automatic + if (_rx_subdev_spec.empty()) _rx_subdev_spec.push_back( + subdev_spec_t::pair_t("", _dboard_manager->get_rx_subdev_names().front()) + ); + std::cout << "RX " << _rx_subdev_spec.to_pp_string() << std::endl; + //sanity check + UHD_ASSERT_THROW(_rx_subdev_spec.size() == 1); + uhd::assert_has((*this)[MBOARD_PROP_RX_DBOARD_NAMES].as(), _rx_subdev_spec.front().first, "rx dboard names"); + uhd::assert_has(_dboard_manager->get_rx_subdev_names(), _rx_subdev_spec.front().second, "rx subdev names"); + //set the mux + _iface->poke32(U2_REG_DSP_RX_MUX, dsp_type1::calc_rx_mux_word( + _dboard_manager->get_rx_subdev(_rx_subdev_spec.front().second)[SUBDEV_PROP_CONNECTION].as() + )); + return; + + case MBOARD_PROP_TX_SUBDEV_SPEC: + _tx_subdev_spec = val.as(); + //handle automatic + if (_tx_subdev_spec.empty()) _tx_subdev_spec.push_back( + subdev_spec_t::pair_t("", _dboard_manager->get_tx_subdev_names().front()) + ); + std::cout << "TX " << _tx_subdev_spec.to_pp_string() << std::endl; + //sanity check + UHD_ASSERT_THROW(_tx_subdev_spec.size() == 1); + uhd::assert_has((*this)[MBOARD_PROP_TX_DBOARD_NAMES].as(), _tx_subdev_spec.front().first, "tx dboard names"); + uhd::assert_has(_dboard_manager->get_tx_subdev_names(), _tx_subdev_spec.front().second, "tx subdev names"); + //set the mux + _iface->poke32(U2_REG_DSP_TX_MUX, dsp_type1::calc_tx_mux_word( + _dboard_manager->get_tx_subdev(_tx_subdev_spec.front().second)[SUBDEV_PROP_CONNECTION].as() + )); + return; + default: UHD_THROW_PROP_SET_ERROR(); } } diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp index 2eaf12350..e7e560469 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.hpp +++ b/host/lib/usrp/usrp2/usrp2_impl.hpp @@ -35,6 +35,7 @@ #include //mtu #include #include +#include /*! * Make a usrp2 dboard interface. @@ -143,6 +144,7 @@ private: //properties for this mboard void get(const wax::obj &, wax::obj &); void set(const wax::obj &, const wax::obj &); + uhd::usrp::subdev_spec_t _rx_subdev_spec, _tx_subdev_spec; //interfaces usrp2_iface::sptr _iface; @@ -165,14 +167,12 @@ private: void rx_dboard_get(const wax::obj &, wax::obj &); void rx_dboard_set(const wax::obj &, const wax::obj &); wax_obj_proxy::sptr _rx_dboard_proxy; - uhd::prop_names_t _rx_subdevs_in_use; uhd::usrp::dboard_eeprom_t _rx_db_eeprom; //properties interface for tx dboard void tx_dboard_get(const wax::obj &, wax::obj &); void tx_dboard_set(const wax::obj &, const wax::obj &); wax_obj_proxy::sptr _tx_dboard_proxy; - uhd::prop_names_t _tx_subdevs_in_use; uhd::usrp::dboard_eeprom_t _tx_db_eeprom; //methods and shadows for the ddc dsp -- cgit v1.2.3 From 5ec42578fa9f69e92ae935c16717957a6ea66324 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 5 Aug 2010 16:41:51 -0700 Subject: uhd: created subdevice pair struct for subdev spec (easier than first/second) --- host/include/uhd/usrp/subdev_spec.hpp | 24 +++++++++++++++++++++--- host/lib/usrp/mimo_usrp.cpp | 8 ++++---- host/lib/usrp/simple_usrp.cpp | 8 ++++---- host/lib/usrp/subdev_spec.cpp | 21 +++++++++++++++------ host/lib/usrp/usrp2/mboard_impl.cpp | 16 ++++++++-------- host/test/subdev_spec_test.cpp | 8 ++++---- 6 files changed, 56 insertions(+), 29 deletions(-) (limited to 'host/lib/usrp/mimo_usrp.cpp') diff --git a/host/include/uhd/usrp/subdev_spec.hpp b/host/include/uhd/usrp/subdev_spec.hpp index d874a9bd9..4d8f03b77 100644 --- a/host/include/uhd/usrp/subdev_spec.hpp +++ b/host/include/uhd/usrp/subdev_spec.hpp @@ -19,12 +19,31 @@ #define INCLUDED_UHD_USRP_SUBDEV_SPEC_HPP #include -#include //std::pair #include #include namespace uhd{ namespace usrp{ + /*! + * A subdevice specification (daughterboard, subdevice) name pairing. + */ + struct UHD_API subdev_spec_pair_t{ + //! The daughterboard name + std::string db_name; + + //! The subdevice name + std::string sd_name; + + /*! + * Create a new subdevice specification pair from dboard and subdev names. + * \param db_name the name of a daughterboard slot + * \param sd_name the name of a subdevice on that daughterboard + */ + subdev_spec_pair_t( + const std::string &db_name, const std::string &sd_name + ); + }; + /*! * A list of (daughterboard name, subdevice name) pairs: * @@ -48,9 +67,8 @@ namespace uhd{ namespace usrp{ * An empty subdevice specification can be used to automatically * select the first subdevice on the first present daughterboard. */ - class UHD_API subdev_spec_t : public std::vector >{ + class UHD_API subdev_spec_t : public std::vector{ public: - typedef std::pair pair_t; /*! * Create a subdev specification from a markup string. diff --git a/host/lib/usrp/mimo_usrp.cpp b/host/lib/usrp/mimo_usrp.cpp index 5fb3571ec..767fc1d48 100644 --- a/host/lib/usrp/mimo_usrp.cpp +++ b/host/lib/usrp/mimo_usrp.cpp @@ -302,19 +302,19 @@ private: return _mboard(chan)[MBOARD_PROP_TX_DSP]; } wax::obj _rx_dboard(size_t chan){ - std::string db_name = _mboard(chan)[MBOARD_PROP_RX_SUBDEV_SPEC].as().front().first; + std::string db_name = _mboard(chan)[MBOARD_PROP_RX_SUBDEV_SPEC].as().front().db_name; return _mboard(chan)[named_prop_t(MBOARD_PROP_RX_DBOARD, db_name)]; } wax::obj _tx_dboard(size_t chan){ - std::string db_name = _mboard(chan)[MBOARD_PROP_TX_SUBDEV_SPEC].as().front().first; + std::string db_name = _mboard(chan)[MBOARD_PROP_TX_SUBDEV_SPEC].as().front().db_name; return _mboard(chan)[named_prop_t(MBOARD_PROP_TX_DBOARD, db_name)]; } wax::obj _rx_subdev(size_t chan){ - std::string sd_name = _mboard(chan)[MBOARD_PROP_RX_SUBDEV_SPEC].as().front().first; + std::string sd_name = _mboard(chan)[MBOARD_PROP_RX_SUBDEV_SPEC].as().front().sd_name; return _rx_dboard(chan)[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)]; } wax::obj _tx_subdev(size_t chan){ - std::string sd_name = _mboard(chan)[MBOARD_PROP_TX_SUBDEV_SPEC].as().front().first; + std::string sd_name = _mboard(chan)[MBOARD_PROP_TX_SUBDEV_SPEC].as().front().sd_name; return _tx_dboard(chan)[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)]; } diff --git a/host/lib/usrp/simple_usrp.cpp b/host/lib/usrp/simple_usrp.cpp index 1606ad2e8..e2a1126ca 100644 --- a/host/lib/usrp/simple_usrp.cpp +++ b/host/lib/usrp/simple_usrp.cpp @@ -232,19 +232,19 @@ private: return _mboard()[MBOARD_PROP_TX_DSP]; } wax::obj _rx_dboard(void){ - std::string db_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as().front().first; + std::string db_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as().front().db_name; return _mboard()[named_prop_t(MBOARD_PROP_RX_DBOARD, db_name)]; } wax::obj _tx_dboard(void){ - std::string db_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as().front().first; + std::string db_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as().front().db_name; return _mboard()[named_prop_t(MBOARD_PROP_TX_DBOARD, db_name)]; } wax::obj _rx_subdev(void){ - std::string sd_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as().front().first; + std::string sd_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as().front().sd_name; return _rx_dboard()[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)]; } wax::obj _tx_subdev(void){ - std::string sd_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as().front().first; + std::string sd_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as().front().sd_name; return _tx_dboard()[named_prop_t(DBOARD_PROP_SUBDEV, sd_name)]; } }; diff --git a/host/lib/usrp/subdev_spec.cpp b/host/lib/usrp/subdev_spec.cpp index 69ab6a339..cca5c36b8 100644 --- a/host/lib/usrp/subdev_spec.cpp +++ b/host/lib/usrp/subdev_spec.cpp @@ -25,6 +25,15 @@ using namespace uhd; using namespace uhd::usrp; +subdev_spec_pair_t::subdev_spec_pair_t( + const std::string &db_name, const std::string &sd_name +): + db_name(db_name), + sd_name(sd_name) +{ + /* NOP */ +} + subdev_spec_t::subdev_spec_t(const std::string &markup){ std::vector pairs; boost::split(pairs, markup, boost::is_any_of("\t ")); @@ -33,8 +42,8 @@ subdev_spec_t::subdev_spec_t(const std::string &markup){ std::vector db_sd; boost::split(db_sd, pair, boost::is_any_of(":")); switch(db_sd.size()){ - case 1: this->push_back(pair_t("", db_sd.front())); break; - case 2: this->push_back(pair_t(db_sd.front(), db_sd.back())); break; + case 1: this->push_back(subdev_spec_pair_t("", db_sd.front())); break; + case 2: this->push_back(subdev_spec_pair_t(db_sd.front(), db_sd.back())); break; default: throw std::runtime_error("invalid subdev-spec markup string: "+markup); } } @@ -46,10 +55,10 @@ std::string subdev_spec_t::to_pp_string(void) const{ std::stringstream ss; size_t count = 0; ss << "Subdevice Specification:" << std::endl; - BOOST_FOREACH(const pair_t &pair, *this){ + BOOST_FOREACH(const subdev_spec_pair_t &pair, *this){ ss << boost::format( " Channel %d: Daughterboard %s, Subdevice %s" - ) % (count++) % pair.first % pair.second << std::endl; + ) % (count++) % pair.db_name % pair.sd_name << std::endl; } return ss.str(); } @@ -57,8 +66,8 @@ std::string subdev_spec_t::to_pp_string(void) const{ std::string subdev_spec_t::to_string(void) const{ std::string markup; size_t count = 0; - BOOST_FOREACH(const pair_t &pair, *this){ - markup += ((count++)? " " : "") + pair.first + ":" + pair.second; + BOOST_FOREACH(const subdev_spec_pair_t &pair, *this){ + markup += ((count++)? " " : "") + pair.db_name + ":" + pair.sd_name; } return markup; } diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index c35171fec..a2a63edf3 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -323,16 +323,16 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){ _rx_subdev_spec = val.as(); //handle automatic if (_rx_subdev_spec.empty()) _rx_subdev_spec.push_back( - subdev_spec_t::pair_t("", _dboard_manager->get_rx_subdev_names().front()) + subdev_spec_pair_t("", _dboard_manager->get_rx_subdev_names().front()) ); std::cout << "RX " << _rx_subdev_spec.to_pp_string() << std::endl; //sanity check UHD_ASSERT_THROW(_rx_subdev_spec.size() == 1); - uhd::assert_has((*this)[MBOARD_PROP_RX_DBOARD_NAMES].as(), _rx_subdev_spec.front().first, "rx dboard names"); - uhd::assert_has(_dboard_manager->get_rx_subdev_names(), _rx_subdev_spec.front().second, "rx subdev names"); + uhd::assert_has((*this)[MBOARD_PROP_RX_DBOARD_NAMES].as(), _rx_subdev_spec.front().db_name, "rx dboard names"); + uhd::assert_has(_dboard_manager->get_rx_subdev_names(), _rx_subdev_spec.front().sd_name, "rx subdev names"); //set the mux _iface->poke32(U2_REG_DSP_RX_MUX, dsp_type1::calc_rx_mux_word( - _dboard_manager->get_rx_subdev(_rx_subdev_spec.front().second)[SUBDEV_PROP_CONNECTION].as() + _dboard_manager->get_rx_subdev(_rx_subdev_spec.front().sd_name)[SUBDEV_PROP_CONNECTION].as() )); return; @@ -340,16 +340,16 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){ _tx_subdev_spec = val.as(); //handle automatic if (_tx_subdev_spec.empty()) _tx_subdev_spec.push_back( - subdev_spec_t::pair_t("", _dboard_manager->get_tx_subdev_names().front()) + subdev_spec_pair_t("", _dboard_manager->get_tx_subdev_names().front()) ); std::cout << "TX " << _tx_subdev_spec.to_pp_string() << std::endl; //sanity check UHD_ASSERT_THROW(_tx_subdev_spec.size() == 1); - uhd::assert_has((*this)[MBOARD_PROP_TX_DBOARD_NAMES].as(), _tx_subdev_spec.front().first, "tx dboard names"); - uhd::assert_has(_dboard_manager->get_tx_subdev_names(), _tx_subdev_spec.front().second, "tx subdev names"); + uhd::assert_has((*this)[MBOARD_PROP_TX_DBOARD_NAMES].as(), _tx_subdev_spec.front().db_name, "tx dboard names"); + uhd::assert_has(_dboard_manager->get_tx_subdev_names(), _tx_subdev_spec.front().sd_name, "tx subdev names"); //set the mux _iface->poke32(U2_REG_DSP_TX_MUX, dsp_type1::calc_tx_mux_word( - _dboard_manager->get_tx_subdev(_tx_subdev_spec.front().second)[SUBDEV_PROP_CONNECTION].as() + _dboard_manager->get_tx_subdev(_tx_subdev_spec.front().sd_name)[SUBDEV_PROP_CONNECTION].as() )); return; diff --git a/host/test/subdev_spec_test.cpp b/host/test/subdev_spec_test.cpp index ca4b4771b..8817d5eee 100644 --- a/host/test/subdev_spec_test.cpp +++ b/host/test/subdev_spec_test.cpp @@ -25,8 +25,8 @@ BOOST_AUTO_TEST_CASE(test_subdevice_spec){ //load the subdev spec with something uhd::usrp::subdev_spec_t sd_spec; - sd_spec.push_back(uhd::usrp::subdev_spec_t::pair_t("A", "AB")); - sd_spec.push_back(uhd::usrp::subdev_spec_t::pair_t("B", "AB")); + sd_spec.push_back(uhd::usrp::subdev_spec_pair_t("A", "AB")); + sd_spec.push_back(uhd::usrp::subdev_spec_pair_t("B", "AB")); //convert to and from args string std::cout << "Pretty Print: " << std::endl << sd_spec.to_pp_string(); @@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE(test_subdevice_spec){ //the contents should match for (size_t i = 0; i < sd_spec.size(); i++){ - BOOST_CHECK_EQUAL(sd_spec.at(i).first, new_sd_spec.at(i).first); - BOOST_CHECK_EQUAL(sd_spec.at(i).second, new_sd_spec.at(i).second); + BOOST_CHECK_EQUAL(sd_spec.at(i).db_name, new_sd_spec.at(i).db_name); + BOOST_CHECK_EQUAL(sd_spec.at(i).sd_name, new_sd_spec.at(i).sd_name); } } -- cgit v1.2.3 From 187fe9d3e7353021d89da38b687ee8729a060ccd Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 5 Aug 2010 17:33:57 -0700 Subject: usrp: tweaks to subdev spec printing --- host/lib/usrp/mimo_usrp.cpp | 4 ++-- host/lib/usrp/simple_usrp.cpp | 7 +++++-- host/lib/usrp/subdev_spec.cpp | 6 +++++- host/lib/usrp/usrp2/mboard_impl.cpp | 2 -- 4 files changed, 12 insertions(+), 7 deletions(-) (limited to 'host/lib/usrp/mimo_usrp.cpp') diff --git a/host/lib/usrp/mimo_usrp.cpp b/host/lib/usrp/mimo_usrp.cpp index 767fc1d48..34dee42b8 100644 --- a/host/lib/usrp/mimo_usrp.cpp +++ b/host/lib/usrp/mimo_usrp.cpp @@ -152,7 +152,7 @@ public: /******************************************************************* * RX methods ******************************************************************/ - void set_rx_subdev_spec(size_t chan, const uhd::usrp::subdev_spec_t &spec){ + void set_rx_subdev_spec(size_t chan, const subdev_spec_t &spec){ UHD_ASSERT_THROW(spec.size() <= 1); _mboard(chan)[MBOARD_PROP_RX_SUBDEV_SPEC] = spec; } @@ -224,7 +224,7 @@ public: /******************************************************************* * TX methods ******************************************************************/ - void set_tx_subdev_spec(size_t chan, const uhd::usrp::subdev_spec_t &spec){ + void set_tx_subdev_spec(size_t chan, const subdev_spec_t &spec){ UHD_ASSERT_THROW(spec.size() <= 1); _mboard(chan)[MBOARD_PROP_TX_SUBDEV_SPEC] = spec; } diff --git a/host/lib/usrp/simple_usrp.cpp b/host/lib/usrp/simple_usrp.cpp index e2a1126ca..ebba5e137 100644 --- a/host/lib/usrp/simple_usrp.cpp +++ b/host/lib/usrp/simple_usrp.cpp @@ -26,6 +26,7 @@ #include #include #include +#include using namespace uhd; using namespace uhd::usrp; @@ -101,8 +102,9 @@ public: /******************************************************************* * RX methods ******************************************************************/ - void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){ + void set_rx_subdev_spec(const subdev_spec_t &spec){ _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC] = spec; + std::cout << "RX " << _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as().to_pp_string() << std::endl; } void set_rx_rate(double rate){ @@ -164,8 +166,9 @@ public: /******************************************************************* * TX methods ******************************************************************/ - void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec){ + void set_tx_subdev_spec(const subdev_spec_t &spec){ _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC] = spec; + std::cout << "TX " << _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as().to_pp_string() << std::endl; } void set_tx_rate(double rate){ diff --git a/host/lib/usrp/subdev_spec.cpp b/host/lib/usrp/subdev_spec.cpp index cca5c36b8..0f00e2f74 100644 --- a/host/lib/usrp/subdev_spec.cpp +++ b/host/lib/usrp/subdev_spec.cpp @@ -56,9 +56,13 @@ std::string subdev_spec_t::to_pp_string(void) const{ size_t count = 0; ss << "Subdevice Specification:" << std::endl; BOOST_FOREACH(const subdev_spec_pair_t &pair, *this){ + std::string db_name = pair.db_name; + if (db_name == "") db_name = "0"; + std::string sd_name = pair.sd_name; + if (sd_name == "") sd_name = "0"; ss << boost::format( " Channel %d: Daughterboard %s, Subdevice %s" - ) % (count++) % pair.db_name % pair.sd_name << std::endl; + ) % (count++) % db_name % sd_name << std::endl; } return ss.str(); } diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index a2a63edf3..92a87150a 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -325,7 +325,6 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){ if (_rx_subdev_spec.empty()) _rx_subdev_spec.push_back( subdev_spec_pair_t("", _dboard_manager->get_rx_subdev_names().front()) ); - std::cout << "RX " << _rx_subdev_spec.to_pp_string() << std::endl; //sanity check UHD_ASSERT_THROW(_rx_subdev_spec.size() == 1); uhd::assert_has((*this)[MBOARD_PROP_RX_DBOARD_NAMES].as(), _rx_subdev_spec.front().db_name, "rx dboard names"); @@ -342,7 +341,6 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){ if (_tx_subdev_spec.empty()) _tx_subdev_spec.push_back( subdev_spec_pair_t("", _dboard_manager->get_tx_subdev_names().front()) ); - std::cout << "TX " << _tx_subdev_spec.to_pp_string() << std::endl; //sanity check UHD_ASSERT_THROW(_tx_subdev_spec.size() == 1); uhd::assert_has((*this)[MBOARD_PROP_TX_DBOARD_NAMES].as(), _tx_subdev_spec.front().db_name, "tx dboard names"); -- cgit v1.2.3 From 55658336cf67810ab8cd7829b9a1fa86c8cd4539 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 9 Aug 2010 15:16:07 -0700 Subject: usrp: added api call to get the subdev spec --- host/include/uhd/usrp/mimo_usrp.hpp | 2 ++ host/include/uhd/usrp/simple_usrp.hpp | 2 ++ host/lib/usrp/mimo_usrp.cpp | 8 ++++++++ host/lib/usrp/simple_usrp.cpp | 8 ++++++++ 4 files changed, 20 insertions(+) (limited to 'host/lib/usrp/mimo_usrp.cpp') diff --git a/host/include/uhd/usrp/mimo_usrp.hpp b/host/include/uhd/usrp/mimo_usrp.hpp index 9856f9d32..10a404059 100644 --- a/host/include/uhd/usrp/mimo_usrp.hpp +++ b/host/include/uhd/usrp/mimo_usrp.hpp @@ -121,6 +121,7 @@ public: * RX methods ******************************************************************/ virtual void set_rx_subdev_spec(size_t chan, const uhd::usrp::subdev_spec_t &spec) = 0; + virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(size_t chan) = 0; virtual void set_rx_rate_all(double rate) = 0; virtual double get_rx_rate_all(void) = 0; @@ -152,6 +153,7 @@ public: * TX methods ******************************************************************/ virtual void set_tx_subdev_spec(size_t chan, const uhd::usrp::subdev_spec_t &spec) = 0; + virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(size_t chan) = 0; virtual void set_tx_rate_all(double rate) = 0; virtual double get_tx_rate_all(void) = 0; diff --git a/host/include/uhd/usrp/simple_usrp.hpp b/host/include/uhd/usrp/simple_usrp.hpp index a6275cfcc..4da63c929 100644 --- a/host/include/uhd/usrp/simple_usrp.hpp +++ b/host/include/uhd/usrp/simple_usrp.hpp @@ -109,6 +109,7 @@ public: * RX methods ******************************************************************/ virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec) = 0; + virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(void) = 0; virtual void set_rx_rate(double rate) = 0; virtual double get_rx_rate(void) = 0; @@ -139,6 +140,7 @@ public: * TX methods ******************************************************************/ virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec) = 0; + virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(void) = 0; virtual void set_tx_rate(double rate) = 0; virtual double get_tx_rate(void) = 0; diff --git a/host/lib/usrp/mimo_usrp.cpp b/host/lib/usrp/mimo_usrp.cpp index 7965e4016..e78d38fc0 100644 --- a/host/lib/usrp/mimo_usrp.cpp +++ b/host/lib/usrp/mimo_usrp.cpp @@ -158,6 +158,10 @@ public: _mboard(chan)[MBOARD_PROP_RX_SUBDEV_SPEC] = spec; } + subdev_spec_t get_rx_subdev_spec(size_t chan){ + return _mboard(chan)[MBOARD_PROP_RX_SUBDEV_SPEC].as(); + } + void set_rx_rate_all(double rate){ std::vector _actual_rates; for (size_t chan = 0; chan < get_num_channels(); chan++){ @@ -230,6 +234,10 @@ public: _mboard(chan)[MBOARD_PROP_TX_SUBDEV_SPEC] = spec; } + subdev_spec_t get_tx_subdev_spec(size_t chan){ + return _mboard(chan)[MBOARD_PROP_TX_SUBDEV_SPEC].as(); + } + void set_tx_rate_all(double rate){ std::vector _actual_rates; for (size_t chan = 0; chan < get_num_channels(); chan++){ diff --git a/host/lib/usrp/simple_usrp.cpp b/host/lib/usrp/simple_usrp.cpp index 40b71d355..60b25a647 100644 --- a/host/lib/usrp/simple_usrp.cpp +++ b/host/lib/usrp/simple_usrp.cpp @@ -108,6 +108,10 @@ public: std::cout << "RX " << _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as().to_pp_string() << std::endl; } + subdev_spec_t get_rx_subdev_spec(void){ + return _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as(); + } + void set_rx_rate(double rate){ _rx_dsp()[DSP_PROP_HOST_RATE] = rate; } @@ -172,6 +176,10 @@ public: std::cout << "TX " << _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as().to_pp_string() << std::endl; } + subdev_spec_t get_tx_subdev_spec(void){ + return _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as(); + } + void set_tx_rate(double rate){ _tx_dsp()[DSP_PROP_HOST_RATE] = rate; } -- cgit v1.2.3