From 8be3b883f5b1a889f4f07611e8954449cc07c2b3 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 16 Mar 2010 13:49:39 -0700 Subject: Added ability to set the subdevices in use for rx and tx dboards. This is used to calculate and set the ddc and duc muxes. Also, minor fix for burning addrs (wrong pointer....) --- host/lib/usrp/dboard/basic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'host/lib/usrp/dboard') diff --git a/host/lib/usrp/dboard/basic.cpp b/host/lib/usrp/dboard/basic.cpp index 095b77ce1..5a82bf145 100644 --- a/host/lib/usrp/dboard/basic.cpp +++ b/host/lib/usrp/dboard/basic.cpp @@ -100,7 +100,7 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){ //handle the get request conditioned on the key switch(key.as()){ case SUBDEV_PROP_NAME: - val = std::string(str(boost::format("%s:%s") + val = std::string(str(boost::format("%s - %s") % dboard_id::to_string(get_rx_id()) % get_subdev_name() )); -- cgit v1.2.3 From 52dc73891474827a9c686f73cbfe70618a2dd6e4 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 16 Mar 2010 15:52:56 -0700 Subject: reimplemented dict to preserve order of insertion --- host/include/uhd/dict.hpp | 43 ++++++++++++++++++------------------------ host/lib/usrp/dboard/basic.cpp | 4 ++-- 2 files changed, 20 insertions(+), 27 deletions(-) (limited to 'host/lib/usrp/dboard') diff --git a/host/include/uhd/dict.hpp b/host/include/uhd/dict.hpp index 2224a0063..8f7cd5a0f 100644 --- a/host/include/uhd/dict.hpp +++ b/host/include/uhd/dict.hpp @@ -18,7 +18,7 @@ #ifndef INCLUDED_UHD_DICT_HPP #define INCLUDED_UHD_DICT_HPP -#include +#include #include #include #include @@ -27,11 +27,9 @@ namespace uhd{ /*! * A templated dictionary class with a python-like interface. - * Its wraps around a std::map internally. */ template class dict{ public: - typedef std::map map_t; typedef std::pair pair_t; /*! @@ -41,14 +39,6 @@ namespace uhd{ /* NOP */ } - /*! - * Create a dictionary from a map. - * \param map a map with key value pairs - */ - dict(const map_t &map){ - _map = map; - } - /*! * Destroy this dict. */ @@ -66,11 +56,12 @@ namespace uhd{ /*! * Get a list of the keys in this dict. + * Key order depends on insertion precedence. * \return vector of keys */ std::vector get_keys(void) const{ std::vector keys; - BOOST_FOREACH(pair_t p, _map){ + BOOST_FOREACH(const pair_t &p, _map){ keys.push_back(p.first); } return keys; @@ -78,11 +69,12 @@ namespace uhd{ /*! * Get a list of the values in this dict. + * Value order depends on insertion precedence. * \return vector of values */ std::vector get_vals(void) const{ std::vector vals; - BOOST_FOREACH(pair_t p, _map){ + BOOST_FOREACH(const pair_t &p, _map){ vals.push_back(p.second); } return vals; @@ -94,7 +86,7 @@ namespace uhd{ * \return true if found */ bool has_key(const Key &key) const{ - BOOST_FOREACH(pair_t p, _map){ + BOOST_FOREACH(const pair_t &p, _map){ if (p.first == key) return true; } return false; @@ -108,8 +100,8 @@ namespace uhd{ * \throw an exception when not found */ const Val &operator[](const Key &key) const{ - if (has_key(key)){ - return _map.find(key)->second; + BOOST_FOREACH(const pair_t &p, _map){ + if (p.first == key) return p.second; } throw std::invalid_argument("key not found in dict"); } @@ -121,7 +113,11 @@ namespace uhd{ * \return a reference to the value */ Val &operator[](const Key &key){ - return _map[key]; + BOOST_FOREACH(pair_t &p, _map){ + if (p.first == key) return p.second; + } + _map.push_back(pair_t(key, Val())); + return _map.back().second; } /*! @@ -130,17 +126,14 @@ namespace uhd{ * \return the value of the item * \throw an exception when not found */ - Val pop_key(const Key &key){ - if (has_key(key)){ - Val val = _map.find(key)->second; - _map.erase(key); - return val; - } - throw std::invalid_argument("key not found in dict"); + Val pop(const Key &key){ + Val val = (*this)[key]; + _map.remove(pair_t(key, val)); + return val; } private: - map_t _map; //private container + std::list _map; //private container }; } //namespace uhd diff --git a/host/lib/usrp/dboard/basic.cpp b/host/lib/usrp/dboard/basic.cpp index 5a82bf145..f88faf6a0 100644 --- a/host/lib/usrp/dboard/basic.cpp +++ b/host/lib/usrp/dboard/basic.cpp @@ -75,9 +75,9 @@ static dboard_base::sptr make_lf_tx(dboard_base::ctor_args_t const& args){ STATIC_BLOCK(reg_dboards){ dboard_manager::register_dboard(0x0000, &make_basic_tx, "Basic TX", list_of("")); - dboard_manager::register_dboard(0x0001, &make_basic_rx, "Basic RX", list_of("a")("b")("ab")); + dboard_manager::register_dboard(0x0001, &make_basic_rx, "Basic RX", list_of("ab")("a")("b")); dboard_manager::register_dboard(0x000e, &make_lf_tx, "LF TX", list_of("")); - dboard_manager::register_dboard(0x000f, &make_lf_rx, "LF RX", list_of("a")("b")("ab")); + dboard_manager::register_dboard(0x000f, &make_lf_rx, "LF RX", list_of("ab")("a")("b")); } /*********************************************************************** -- cgit v1.2.3 From 83c463d09613b72817a837117c5f0b23975c8def Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 16 Mar 2010 19:42:38 -0700 Subject: changes to get tuning working --- host/lib/simple_device.cpp | 12 ++++++++++-- host/lib/usrp/dboard/basic.cpp | 8 ++++++-- host/lib/usrp/usrp2/io_impl.cpp | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) (limited to 'host/lib/usrp/dboard') diff --git a/host/lib/simple_device.cpp b/host/lib/simple_device.cpp index 62a38cb79..79b035071 100644 --- a/host/lib/simple_device.cpp +++ b/host/lib/simple_device.cpp @@ -133,8 +133,16 @@ public: _mboard = (*_dev)[DEVICE_PROP_MBOARD]; _rx_ddc = _mboard[named_prop_t(MBOARD_PROP_RX_DSP, "ddc0")]; _tx_duc = _mboard[named_prop_t(MBOARD_PROP_TX_DSP, "duc0")]; - _rx_subdev = _mboard[MBOARD_PROP_RX_DBOARD][DBOARD_PROP_SUBDEV]; - _tx_subdev = _mboard[MBOARD_PROP_TX_DBOARD][DBOARD_PROP_SUBDEV]; + + //extract rx subdevice + wax::obj 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 + wax::obj 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_device_impl(void){ diff --git a/host/lib/usrp/dboard/basic.cpp b/host/lib/usrp/dboard/basic.cpp index f88faf6a0..02b391244 100644 --- a/host/lib/usrp/dboard/basic.cpp +++ b/host/lib/usrp/dboard/basic.cpp @@ -172,11 +172,13 @@ void basic_rx::rx_set(const wax::obj &key_, const wax::obj &val){ case SUBDEV_PROP_ENABLED: return; // it wont do you much good, but you can set it + case SUBDEV_PROP_FREQ: + return; // it wont do you much good, but you can set it + case SUBDEV_PROP_NAME: case SUBDEV_PROP_OTHERS: case SUBDEV_PROP_GAIN_RANGE: case SUBDEV_PROP_GAIN_NAMES: - case SUBDEV_PROP_FREQ: case SUBDEV_PROP_FREQ_RANGE: case SUBDEV_PROP_ANTENNA_NAMES: case SUBDEV_PROP_QUADRATURE: @@ -278,11 +280,13 @@ void basic_tx::tx_set(const wax::obj &key_, const wax::obj &val){ case SUBDEV_PROP_ENABLED: return; // it wont do you much good, but you can set it + case SUBDEV_PROP_FREQ: + return; // it wont do you much good, but you can set it + case SUBDEV_PROP_NAME: case SUBDEV_PROP_OTHERS: case SUBDEV_PROP_GAIN_RANGE: case SUBDEV_PROP_GAIN_NAMES: - case SUBDEV_PROP_FREQ: case SUBDEV_PROP_FREQ_RANGE: case SUBDEV_PROP_ANTENNA_NAMES: case SUBDEV_PROP_QUADRATURE: diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index cc7746720..e52c1e576 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -149,7 +149,7 @@ void usrp2_impl::recv_raw(rx_metadata_t &metadata){ //handle the packet count / sequence number size_t expected_packet_count = _rx_stream_id_to_packet_seq[metadata.stream_id]; if (packet_count_out != expected_packet_count){ - std::cerr << "bad packet count: " << packet_count_out << std::endl; + std::cerr << "S" << (packet_count_out - expected_packet_count)%16; } _rx_stream_id_to_packet_seq[metadata.stream_id] = (packet_count_out+1)%16; -- cgit v1.2.3