From 805d4a0cff00fb4e0071bb300436bb7eefb8fb16 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 12 Aug 2010 10:08:17 -0700 Subject: uhd: made split string utility function --- host/include/uhd/utils/algorithm.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'host/include') diff --git a/host/include/uhd/utils/algorithm.hpp b/host/include/uhd/utils/algorithm.hpp index 1b5eacfa9..53c571e4e 100644 --- a/host/include/uhd/utils/algorithm.hpp +++ b/host/include/uhd/utils/algorithm.hpp @@ -22,6 +22,9 @@ #include #include #include +#include +#include +#include /*! \file algorithm.hpp * Useful templated functions and classes that I like to pretend are part of stl. @@ -29,6 +32,24 @@ */ namespace std{ + /*! + * Split a string at the separation characters. + * \param string the string to split + * \param sep the separator characters + * \return a range of strings + */ + inline std::vector split_string( + const std::string &string, const std::string &sep = "\t " + ){ + std::vector strings; + if (not string.empty()) boost::split( + // do not split an empty string: + // let me tell you about the time when boost::split segfaulted... + strings, string, boost::is_any_of(sep) + ); + return strings; + } + /*! * A wrapper around std::copy that takes ranges instead of iterators. * -- cgit v1.2.3 From f0960e79489c6702d3bd79c40f9e24f2b9e5b42d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 14 Aug 2010 14:45:59 -0700 Subject: usrp: replaced mboard name with special props for dboard iface --- host/include/uhd/usrp/dboard_iface.hpp | 29 ++++++++++++++++++++++++++--- host/lib/usrp/dboard/db_dbsrx.cpp | 31 ++++++++++++++----------------- host/lib/usrp/usrp2/dboard_iface.cpp | 7 ++++++- 3 files changed, 46 insertions(+), 21 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/usrp/dboard_iface.hpp b/host/include/uhd/usrp/dboard_iface.hpp index fc7ea3052..e776ecc42 100644 --- a/host/include/uhd/usrp/dboard_iface.hpp +++ b/host/include/uhd/usrp/dboard_iface.hpp @@ -65,11 +65,34 @@ public: AUX_ADC_B = 'b' }; + //! Special properties that differentiate this daughterboard slot + struct special_props_t{ + /*! + * Soft clock divider: + * When a motherboard cannot provided a divided dboard clock, + * it may provided a "soft" divided clock over an FPGA GPIO. + * The implementation must know the type of clock provided. + */ + bool soft_clock_divider; + + /*! + * Mangle i2c addresses: + * When i2c is shared across multiple daugterboard slots, + * the i2c addresses will be mangled on the secondary slot + * to avoid conflicts between slots in the i2c address space. + * The mangling is daguhterboard specific so the implementation + * needs to know whether it should use mangled addresses or not. + */ + bool mangle_i2c_addrs; + }; + /*! - * Get the motherboard name of the form: usrp1, usrp2... - * \return string representing the motherboard name + * Get special properties information for this dboard slot. + * This call helps the dboard code to handle implementation + * differences between different motherboards and dboard slots. + * \return the special properties struct */ - virtual std::string get_mboard_name(void) = 0; + virtual special_props_t get_special_props(void) = 0; /*! * Write to an aux dac. diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp index 03e6b6255..072497dcc 100644 --- a/host/lib/usrp/dboard/db_dbsrx.cpp +++ b/host/lib/usrp/dboard/db_dbsrx.cpp @@ -61,7 +61,7 @@ static const uhd::dict dbsrx_gain_ranges = map_list_o **********************************************************************/ class dbsrx : public rx_dboard_base{ public: - dbsrx(ctor_args_t args, boost::uint8_t max2118_addr); + dbsrx(ctor_args_t args); ~dbsrx(void); void rx_get(const wax::obj &key, wax::obj &val); @@ -73,7 +73,9 @@ private: uhd::dict _gains; max2118_write_regs_t _max2118_write_regs; max2118_read_regs_t _max2118_read_regs; - boost::uint8_t _max2118_addr; //0x67 or 0x65 depending on which side + boost::uint8_t _max2118_addr(void){ + return (this->get_iface()->get_special_props().mangle_i2c_addrs)? 0x65 : 0x67; + }; void set_lo_freq(double target_freq); void set_gain(float gain, const std::string &name); @@ -102,7 +104,7 @@ private: //send the data this->get_iface()->write_i2c( - _max2118_addr, regs_vector + _max2118_addr(), regs_vector ); } } @@ -120,7 +122,7 @@ private: //read from i2c regs_vector = this->get_iface()->read_i2c( - _max2118_addr, num_bytes + _max2118_addr(), num_bytes ); for(boost::uint8_t i=0; i < num_bytes; i++){ @@ -156,10 +158,8 @@ private: /*********************************************************************** * Register the DBSRX dboard **********************************************************************/ -// FIXME 0x67 is the default i2c address on USRP2 -// need to handle which side for USRP1 with different address static dboard_base::sptr make_dbsrx(dboard_base::ctor_args_t args){ - return dboard_base::sptr(new dbsrx(args, 0x67)); + return dboard_base::sptr(new dbsrx(args)); } //dbid for USRP2 version @@ -177,27 +177,27 @@ UHD_STATIC_BLOCK(reg_dbsrx_on_usrp1_dboard){ /*********************************************************************** * Structors **********************************************************************/ -dbsrx::dbsrx(ctor_args_t args, boost::uint8_t max2118_addr) : rx_dboard_base(args){ +dbsrx::dbsrx(ctor_args_t args) : rx_dboard_base(args){ //warn user about incorrect DBID on USRP1, requires R193 populated - if (this->get_iface()->get_mboard_name() == "usrp1" and this->get_rx_id() == 0x000D) + if (this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x000D) uhd::print_warning( str(boost::format( "DBSRX: incorrect dbid\n" - "%s expects dbid 0x0002 and R193\n" + "Expected dbid 0x0002 and R193\n" "found dbid == %d\n" "Please see the daughterboard app notes" - ) % (this->get_iface()->get_mboard_name()) % (this->get_rx_id().to_pp_string())) + ) % this->get_rx_id().to_pp_string()) ); //warn user about incorrect DBID on non-USRP1, requires R194 populated - if (this->get_iface()->get_mboard_name() != "usrp1" and this->get_rx_id() == 0x0002) + if (not this->get_iface()->get_special_props().soft_clock_divider and this->get_rx_id() == 0x0002) uhd::print_warning( str(boost::format( "DBSRX: incorrect dbid\n" - "%s expects dbid 0x000D and R194\n" + "Expected dbid 0x000D and R194\n" "found dbid == %d\n" "Please see the daughterboard app notes" - ) % (this->get_iface()->get_mboard_name()) % (this->get_rx_id().to_pp_string())) + ) % this->get_rx_id().to_pp_string()) ); //enable only the clocks we need @@ -207,9 +207,6 @@ dbsrx::dbsrx(ctor_args_t args, boost::uint8_t max2118_addr) : rx_dboard_base(arg this->get_iface()->set_pin_ctrl(dboard_iface::UNIT_RX, 0x0); // All unused in atr this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_RX, 0x0); // All Inputs - //set the i2c address for the max2118 - _max2118_addr = max2118_addr; - //send initial register settings this->send_reg(0x0, 0x5); diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp index 1b9a4bb97..8bded1ea3 100644 --- a/host/lib/usrp/usrp2/dboard_iface.cpp +++ b/host/lib/usrp/usrp2/dboard_iface.cpp @@ -37,7 +37,12 @@ public: usrp2_dboard_iface(usrp2_iface::sptr iface, usrp2_clock_ctrl::sptr clock_ctrl); ~usrp2_dboard_iface(void); - std::string get_mboard_name(void){return "usrp2";} + special_props_t get_special_props(void){ + special_props_t props; + props.soft_clock_divider = false; + props.mangle_i2c_addrs = false; + return props; + } void write_aux_dac(unit_t, aux_dac_t, float); float read_aux_adc(unit_t, aux_adc_t); -- cgit v1.2.3 From 6c3d37caa3a47ca534c5e3a110adad0137d5d06d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 15 Aug 2010 01:41:35 -0700 Subject: usrp: give dboards a name (not a blank string), do automatic selection when not provided --- host/include/uhd/usrp/dboard_manager.hpp | 2 +- host/lib/usrp/misc_utils.cpp | 20 +++++++++++++++----- host/lib/usrp/subdev_spec.cpp | 6 +----- host/lib/usrp/usrp2/mboard_impl.cpp | 10 ++++++---- 4 files changed, 23 insertions(+), 15 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp index e5831d4cf..c68f069f0 100644 --- a/host/include/uhd/usrp/dboard_manager.hpp +++ b/host/include/uhd/usrp/dboard_manager.hpp @@ -51,7 +51,7 @@ public: const dboard_id_t &dboard_id, dboard_ctor_t dboard_ctor, const std::string &name, - const prop_names_t &subdev_names = prop_names_t(1, "") + const prop_names_t &subdev_names = prop_names_t(1, "0") ); /*! diff --git a/host/lib/usrp/misc_utils.cpp b/host/lib/usrp/misc_utils.cpp index da22d79f1..930314fc2 100644 --- a/host/lib/usrp/misc_utils.cpp +++ b/host/lib/usrp/misc_utils.cpp @@ -127,14 +127,17 @@ static void verify_xx_subdev_spec( wax::obj mboard, std::string xx_type ){ + prop_names_t dboard_names = mboard[dboard_names_prop].as(); + UHD_ASSERT_THROW(dboard_names.size() > 0); //well i hope there is a dboard + //the subdevice specification is empty: handle automatic if (subdev_spec.empty()){ - BOOST_FOREACH(const std::string &db_name, mboard[dboard_names_prop].as()){ + BOOST_FOREACH(const std::string &db_name, dboard_names){ wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)]; //if the dboard slot is populated, take the first subdevice if (dboard[DBOARD_PROP_DBOARD_ID].as() != dboard_id_t::none()){ - std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as().at(0); + std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as().front(); subdev_spec.push_back(subdev_spec_pair_t(db_name, sd_name)); break; } @@ -142,16 +145,23 @@ static void verify_xx_subdev_spec( //didnt find any populated dboards: add the first subdevice if (subdev_spec.empty()){ - std::string db_name = mboard[dboard_names_prop].as().at(0); + std::string db_name = dboard_names.front(); wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)]; - std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as().at(0); + std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as().front(); subdev_spec.push_back(subdev_spec_pair_t(db_name, sd_name)); } } //sanity check that the dboard/subdevice names exist for this mboard BOOST_FOREACH(const subdev_spec_pair_t &pair, subdev_spec){ - uhd::assert_has(mboard[dboard_names_prop].as(), pair.db_name, xx_type + " dboard name"); + //empty db name means select dboard automatically + if (pair.db_name.empty()){ + if (dboard_names.size() != 1) throw std::runtime_error( + "A daughterboard name must be provided for multi-slot boards: " + subdev_spec.to_string() + ); + pair.db_name == dboard_names.front(); + } + uhd::assert_has(dboard_names, pair.db_name, xx_type + " dboard name"); wax::obj dboard = mboard[named_prop_t(dboard_prop, pair.db_name)]; uhd::assert_has(dboard[DBOARD_PROP_SUBDEV_NAMES].as(), pair.sd_name, xx_type + " subdev name"); } diff --git a/host/lib/usrp/subdev_spec.cpp b/host/lib/usrp/subdev_spec.cpp index 765eecb3d..7a3e72867 100644 --- a/host/lib/usrp/subdev_spec.cpp +++ b/host/lib/usrp/subdev_spec.cpp @@ -53,13 +53,9 @@ 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++) % db_name % sd_name << std::endl; + ) % (count++) % pair.db_name % pair.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 fe3ec6785..533b60bae 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -186,6 +186,8 @@ void usrp2_mboard_impl::issue_ddc_stream_cmd(const stream_cmd_t &stream_cmd){ /*********************************************************************** * MBoard Get Properties **********************************************************************/ +static const std::string dboard_name = "0"; + void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ wax::obj key; std::string name; boost::tie(key, name) = extract_named_prop(key_); @@ -222,21 +224,21 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ return; case MBOARD_PROP_RX_DBOARD: - UHD_ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(name == dboard_name); val = _rx_dboard_proxy->get_link(); return; case MBOARD_PROP_RX_DBOARD_NAMES: - val = prop_names_t(1, ""); + val = prop_names_t(1, dboard_name); return; case MBOARD_PROP_TX_DBOARD: - UHD_ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(name == dboard_name); val = _tx_dboard_proxy->get_link(); return; case MBOARD_PROP_TX_DBOARD_NAMES: - val = prop_names_t(1, ""); + val = prop_names_t(1, dboard_name); return; case MBOARD_PROP_RX_DSP: -- cgit v1.2.3 From 98ba0cc067489d417342314a7e7408d2dbbc8250 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 15 Aug 2010 10:51:25 -0700 Subject: uhd: extract named prop returns a named prop (not a tuple) simplifies the code after the property set/get declaration --- host/include/uhd/utils/props.hpp | 33 ++++++++++++++++++-------------- host/lib/usrp/dboard/db_basic_and_lf.cpp | 12 ++++-------- host/lib/usrp/dboard/db_dbsrx.cpp | 29 +++++++--------------------- host/lib/usrp/dboard/db_rfx.cpp | 26 +++++++++++-------------- host/lib/usrp/dboard/db_unknown.cpp | 12 ++++-------- host/lib/usrp/dboard/db_wbx.cpp | 32 ++++++++++++++----------------- host/lib/usrp/dboard/db_xcvr2450.cpp | 32 ++++++++++++++----------------- host/lib/usrp/usrp2/codec_impl.cpp | 8 ++------ host/lib/usrp/usrp2/dboard_impl.cpp | 14 ++++++-------- host/lib/usrp/usrp2/mboard_impl.cpp | 13 ++++++------- host/lib/usrp/usrp2/usrp2_impl.cpp | 5 ++--- host/lib/utils/props.cpp | 9 +++------ 12 files changed, 92 insertions(+), 133 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/utils/props.hpp b/host/include/uhd/utils/props.hpp index f376d2612..fbca03019 100644 --- a/host/include/uhd/utils/props.hpp +++ b/host/include/uhd/utils/props.hpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -36,8 +35,25 @@ namespace uhd{ * Allows properties to be sub-sectioned by name. */ struct UHD_API named_prop_t{ - wax::obj key; - std::string name; + const wax::obj key; + const std::string name; + + //! Convert the key to the specified type + template inline T as(void){ + return key.as(); + } + + /*! + * Utility function to convert generic key into a named prop. + * If the key was already a named prop, the prop will be split. + * Otherwise, the key will be the key, and the name will be used. + * \param key a reference to the prop object + * \param name a reference to the name object + * \return a named property struct with key and name + */ + static named_prop_t extract( + const wax::obj &key, const std::string &name = "" + ); /*! * Create a new named prop from key and name. @@ -47,17 +63,6 @@ namespace uhd{ named_prop_t(const wax::obj &key, const std::string &name); }; - /*! - * Utility function to separate a named property into its components. - * \param key a reference to the prop object - * \param name a reference to the name object - * \return a tuple that can be used with boost::tie - */ - UHD_API boost::tuple extract_named_prop( - const wax::obj &key, - const std::string &name = "" - ); - /*! * Throw when getting a not-implemented or write-only property. * Throw-site information will be included with this error. diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp index 9180828d8..f8236d598 100644 --- a/host/lib/usrp/dboard/db_basic_and_lf.cpp +++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp @@ -95,8 +95,7 @@ basic_rx::~basic_rx(void){ } void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -161,8 +160,7 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){ } void basic_rx::rx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -194,8 +192,7 @@ basic_tx::~basic_tx(void){ } void basic_tx::tx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -252,8 +249,7 @@ void basic_tx::tx_get(const wax::obj &key_, wax::obj &val){ } void basic_tx::tx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp index 072497dcc..06cf91d3b 100644 --- a/host/lib/usrp/dboard/db_dbsrx.cpp +++ b/host/lib/usrp/dboard/db_dbsrx.cpp @@ -500,8 +500,7 @@ void dbsrx::set_bandwidth(float bandwidth){ * RX Get and Set **********************************************************************/ void dbsrx::rx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -514,13 +513,13 @@ void dbsrx::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - assert_has(_gains.keys(), name, "dbsrx gain name"); - val = _gains[name]; + assert_has(_gains.keys(), key.name, "dbsrx gain name"); + val = _gains[key.name]; return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(dbsrx_gain_ranges.keys(), name, "dbsrx gain name"); - val = dbsrx_gain_ranges[name]; + assert_has(dbsrx_gain_ranges.keys(), key.name, "dbsrx gain name"); + val = dbsrx_gain_ranges[key.name]; return; case SUBDEV_PROP_GAIN_NAMES: @@ -543,19 +542,6 @@ void dbsrx::rx_get(const wax::obj &key_, wax::obj &val){ val = dbsrx_antennas; return; -/* - case SUBDEV_PROP_QUADRATURE: - val = true; - return; - - case SUBDEV_PROP_IQ_SWAPPED: - val = false; - return; - - case SUBDEV_PROP_SPECTRUM_INVERTED: - val = false; - return; -*/ case SUBDEV_PROP_CONNECTION: val = SUBDEV_CONN_COMPLEX_IQ; return; @@ -583,8 +569,7 @@ void dbsrx::rx_get(const wax::obj &key_, wax::obj &val){ } void dbsrx::rx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -594,7 +579,7 @@ void dbsrx::rx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_gain(val.as(), name); + this->set_gain(val.as(), key.name); return; case SUBDEV_PROP_BANDWIDTH: diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index b6b44199a..c3ab96e59 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -398,8 +398,7 @@ double rfx_xcvr::set_lo_freq( * RX Get and Set **********************************************************************/ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -412,13 +411,13 @@ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - assert_has(_rx_gains.keys(), name, "rfx rx gain name"); - val = _rx_gains[name]; + assert_has(_rx_gains.keys(), key.name, "rfx rx gain name"); + val = _rx_gains[key.name]; return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(_rx_gain_ranges.keys(), name, "rfx rx gain name"); - val = _rx_gain_ranges[name]; + assert_has(_rx_gain_ranges.keys(), key.name, "rfx rx gain name"); + val = _rx_gain_ranges[key.name]; return; case SUBDEV_PROP_GAIN_NAMES: @@ -458,8 +457,7 @@ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ } void rfx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -469,7 +467,7 @@ void rfx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_rx_gain(val.as(), name); + this->set_rx_gain(val.as(), key.name); return; case SUBDEV_PROP_ANTENNA: @@ -484,8 +482,7 @@ void rfx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ * TX Get and Set **********************************************************************/ void rfx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -499,7 +496,7 @@ void rfx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ case SUBDEV_PROP_GAIN: case SUBDEV_PROP_GAIN_RANGE: - assert_has(rfx_tx_gain_ranges.keys(), name, "rfx tx gain name"); + assert_has(rfx_tx_gain_ranges.keys(), key.name, "rfx tx gain name"); //no controllable tx gains, will not get here return; @@ -540,8 +537,7 @@ void rfx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ } void rfx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -551,7 +547,7 @@ void rfx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_tx_gain(val.as(), name); + this->set_tx_gain(val.as(), key.name); return; case SUBDEV_PROP_ANTENNA: diff --git a/host/lib/usrp/dboard/db_unknown.cpp b/host/lib/usrp/dboard/db_unknown.cpp index 9dd9b550b..f6f4f4a61 100644 --- a/host/lib/usrp/dboard/db_unknown.cpp +++ b/host/lib/usrp/dboard/db_unknown.cpp @@ -78,8 +78,7 @@ unknown_rx::~unknown_rx(void){ } void unknown_rx::rx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -136,8 +135,7 @@ void unknown_rx::rx_get(const wax::obj &key_, wax::obj &val){ } void unknown_rx::rx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -169,8 +167,7 @@ unknown_tx::~unknown_tx(void){ } void unknown_tx::tx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -227,8 +224,7 @@ void unknown_tx::tx_get(const wax::obj &key_, wax::obj &val){ } void unknown_tx::tx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ diff --git a/host/lib/usrp/dboard/db_wbx.cpp b/host/lib/usrp/dboard/db_wbx.cpp index 3038ce30b..ccd897674 100644 --- a/host/lib/usrp/dboard/db_wbx.cpp +++ b/host/lib/usrp/dboard/db_wbx.cpp @@ -467,8 +467,7 @@ double wbx_xcvr::set_lo_freq( * RX Get and Set **********************************************************************/ void wbx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -481,13 +480,13 @@ void wbx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - assert_has(_rx_gains.keys(), name, "wbx rx gain name"); - val = _rx_gains[name]; + assert_has(_rx_gains.keys(), key.name, "wbx rx gain name"); + val = _rx_gains[key.name]; return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(wbx_rx_gain_ranges.keys(), name, "wbx rx gain name"); - val = wbx_rx_gain_ranges[name]; + assert_has(wbx_rx_gain_ranges.keys(), key.name, "wbx rx gain name"); + val = wbx_rx_gain_ranges[key.name]; return; case SUBDEV_PROP_GAIN_NAMES: @@ -527,8 +526,7 @@ void wbx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ } void wbx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -538,7 +536,7 @@ void wbx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_rx_gain(val.as(), name); + this->set_rx_gain(val.as(), key.name); return; case SUBDEV_PROP_ANTENNA: @@ -553,8 +551,7 @@ void wbx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){ * TX Get and Set **********************************************************************/ void wbx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -567,13 +564,13 @@ void wbx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - assert_has(_tx_gains.keys(), name, "wbx tx gain name"); - val = _tx_gains[name]; + assert_has(_tx_gains.keys(), key.name, "wbx tx gain name"); + val = _tx_gains[key.name]; return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(wbx_tx_gain_ranges.keys(), name, "wbx tx gain name"); - val = wbx_tx_gain_ranges[name]; + assert_has(wbx_tx_gain_ranges.keys(), key.name, "wbx tx gain name"); + val = wbx_tx_gain_ranges[key.name]; return; case SUBDEV_PROP_GAIN_NAMES: @@ -613,8 +610,7 @@ void wbx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ } void wbx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -624,7 +620,7 @@ void wbx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_tx_gain(val.as(), name); + this->set_tx_gain(val.as(), key.name); return; case SUBDEV_PROP_ANTENNA: diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 2c94bcd2d..798ff74a3 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -438,8 +438,7 @@ void xcvr2450::set_rx_gain(float gain, const std::string &name){ * RX Get and Set **********************************************************************/ void xcvr2450::rx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -452,13 +451,13 @@ void xcvr2450::rx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - assert_has(_rx_gains.keys(), name, "xcvr rx gain name"); - val = _rx_gains[name]; + assert_has(_rx_gains.keys(), key.name, "xcvr rx gain name"); + val = _rx_gains[key.name]; return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(xcvr_rx_gain_ranges.keys(), name, "xcvr rx gain name"); - val = xcvr_rx_gain_ranges[name]; + assert_has(xcvr_rx_gain_ranges.keys(), key.name, "xcvr rx gain name"); + val = xcvr_rx_gain_ranges[key.name]; return; case SUBDEV_PROP_GAIN_NAMES: @@ -502,8 +501,7 @@ void xcvr2450::rx_get(const wax::obj &key_, wax::obj &val){ } void xcvr2450::rx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -513,7 +511,7 @@ void xcvr2450::rx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_rx_gain(val.as(), name); + this->set_rx_gain(val.as(), key.name); return; case SUBDEV_PROP_ANTENNA: @@ -528,8 +526,7 @@ void xcvr2450::rx_set(const wax::obj &key_, const wax::obj &val){ * TX Get and Set **********************************************************************/ void xcvr2450::tx_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -542,13 +539,13 @@ void xcvr2450::tx_get(const wax::obj &key_, wax::obj &val){ return; case SUBDEV_PROP_GAIN: - assert_has(_tx_gains.keys(), name, "xcvr tx gain name"); - val = _tx_gains[name]; + assert_has(_tx_gains.keys(), key.name, "xcvr tx gain name"); + val = _tx_gains[key.name]; return; case SUBDEV_PROP_GAIN_RANGE: - assert_has(xcvr_tx_gain_ranges.keys(), name, "xcvr tx gain name"); - val = xcvr_tx_gain_ranges[name]; + assert_has(xcvr_tx_gain_ranges.keys(), key.name, "xcvr tx gain name"); + val = xcvr_tx_gain_ranges[key.name]; return; case SUBDEV_PROP_GAIN_NAMES: @@ -588,8 +585,7 @@ void xcvr2450::tx_get(const wax::obj &key_, wax::obj &val){ } void xcvr2450::tx_set(const wax::obj &key_, const wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -599,7 +595,7 @@ void xcvr2450::tx_set(const wax::obj &key_, const wax::obj &val){ return; case SUBDEV_PROP_GAIN: - this->set_tx_gain(val.as(), name); + this->set_tx_gain(val.as(), key.name); return; case SUBDEV_PROP_ANTENNA: diff --git a/host/lib/usrp/usrp2/codec_impl.cpp b/host/lib/usrp/usrp2/codec_impl.cpp index b9d51abf5..fc917b102 100644 --- a/host/lib/usrp/usrp2/codec_impl.cpp +++ b/host/lib/usrp/usrp2/codec_impl.cpp @@ -40,9 +40,7 @@ void usrp2_mboard_impl::codec_init(void){ /*********************************************************************** * RX Codec Properties **********************************************************************/ -void usrp2_mboard_impl::rx_codec_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); +void usrp2_mboard_impl::rx_codec_get(const wax::obj &key, wax::obj &val){ //handle the get request conditioned on the key switch(key.as()){ @@ -69,9 +67,7 @@ void usrp2_mboard_impl::rx_codec_set(const wax::obj &, const wax::obj &){ /*********************************************************************** * TX Codec Properties **********************************************************************/ -void usrp2_mboard_impl::tx_codec_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); +void usrp2_mboard_impl::tx_codec_get(const wax::obj &key, wax::obj &val){ //handle the get request conditioned on the key switch(key.as()){ diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp index 075f22388..bafeb3f15 100644 --- a/host/lib/usrp/usrp2/dboard_impl.cpp +++ b/host/lib/usrp/usrp2/dboard_impl.cpp @@ -59,8 +59,7 @@ void usrp2_mboard_impl::dboard_init(void){ * RX DBoard Properties **********************************************************************/ void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -69,7 +68,7 @@ void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){ return; case DBOARD_PROP_SUBDEV: - val = _dboard_manager->get_rx_subdev(name); + val = _dboard_manager->get_rx_subdev(key.name); return; case DBOARD_PROP_SUBDEV_NAMES: @@ -90,7 +89,7 @@ void usrp2_mboard_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){ case DBOARD_PROP_GAIN_GROUP: val = make_gain_group( - _dboard_manager->get_rx_subdev(name), _rx_codec_proxy->get_link() + _dboard_manager->get_rx_subdev(key.name), _rx_codec_proxy->get_link() ); return; @@ -114,8 +113,7 @@ void usrp2_mboard_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){ * TX DBoard Properties **********************************************************************/ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -124,7 +122,7 @@ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){ return; case DBOARD_PROP_SUBDEV: - val = _dboard_manager->get_tx_subdev(name); + val = _dboard_manager->get_tx_subdev(key.name); return; case DBOARD_PROP_SUBDEV_NAMES: @@ -145,7 +143,7 @@ void usrp2_mboard_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){ case DBOARD_PROP_GAIN_GROUP: val = make_gain_group( - _dboard_manager->get_tx_subdev(name), _tx_codec_proxy->get_link() + _dboard_manager->get_tx_subdev(key.name), _tx_codec_proxy->get_link() ); return; diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 533b60bae..d354a943b 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -189,11 +189,10 @@ void usrp2_mboard_impl::issue_ddc_stream_cmd(const stream_cmd_t &stream_cmd){ static const std::string dboard_name = "0"; void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the other props - if (key.type() == typeid(std::string)){ + if (key_.type() == typeid(std::string)){ if (key.as() == "mac-addr"){ byte_vector_t bytes = _iface->read_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_MAC_ADDR, 6); val = mac_addr_t::from_bytes(bytes).to_string(); @@ -224,7 +223,7 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ return; case MBOARD_PROP_RX_DBOARD: - UHD_ASSERT_THROW(name == dboard_name); + UHD_ASSERT_THROW(key.name == dboard_name); val = _rx_dboard_proxy->get_link(); return; @@ -233,7 +232,7 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ return; case MBOARD_PROP_TX_DBOARD: - UHD_ASSERT_THROW(name == dboard_name); + UHD_ASSERT_THROW(key.name == dboard_name); val = _tx_dboard_proxy->get_link(); return; @@ -242,7 +241,7 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ return; case MBOARD_PROP_RX_DSP: - UHD_ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(key.name == ""); val = _rx_dsp_proxy->get_link(); return; @@ -251,7 +250,7 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){ return; case MBOARD_PROP_TX_DSP: - UHD_ASSERT_THROW(name == ""); + UHD_ASSERT_THROW(key.name == ""); val = _tx_dsp_proxy->get_link(); return; diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 45362c20f..568c87a22 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -201,8 +201,7 @@ usrp2_impl::~usrp2_impl(void){ * Device Properties **********************************************************************/ void usrp2_impl::get(const wax::obj &key_, wax::obj &val){ - wax::obj key; std::string name; - boost::tie(key, name) = extract_named_prop(key_); + named_prop_t key = named_prop_t::extract(key_); //handle the get request conditioned on the key switch(key.as()){ @@ -212,7 +211,7 @@ void usrp2_impl::get(const wax::obj &key_, wax::obj &val){ return; case DEVICE_PROP_MBOARD: - val = _mboard_dict[name]->get_link(); + val = _mboard_dict[key.name]->get_link(); return; case DEVICE_PROP_MBOARD_NAMES: diff --git a/host/lib/utils/props.cpp b/host/lib/utils/props.cpp index fac5fe24f..fc9f8e63f 100644 --- a/host/lib/utils/props.cpp +++ b/host/lib/utils/props.cpp @@ -29,15 +29,12 @@ named_prop_t::named_prop_t( /* NOP */ } -typedef boost::tuple named_prop_tuple; - -named_prop_tuple uhd::extract_named_prop( +named_prop_t named_prop_t::extract( const wax::obj &key, const std::string &name ){ if (key.type() == typeid(named_prop_t)){ - named_prop_t np = key.as(); - return named_prop_tuple(np.key, np.name); + return key.as(); } - return named_prop_tuple(key, name); + return named_prop_t(key, name); } -- cgit v1.2.3