summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-08-05 16:41:51 -0700
committerJosh Blum <josh@joshknows.com>2010-08-06 12:15:05 -0700
commit5ec42578fa9f69e92ae935c16717957a6ea66324 (patch)
treedb54b506b9dccb857723b7b07ce236986e070e8b /host
parenta333a01ac0d1d0cb011d52f04bed2534a708f944 (diff)
downloaduhd-5ec42578fa9f69e92ae935c16717957a6ea66324.tar.gz
uhd-5ec42578fa9f69e92ae935c16717957a6ea66324.tar.bz2
uhd-5ec42578fa9f69e92ae935c16717957a6ea66324.zip
uhd: created subdevice pair struct for subdev spec (easier than first/second)
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/usrp/subdev_spec.hpp24
-rw-r--r--host/lib/usrp/mimo_usrp.cpp8
-rw-r--r--host/lib/usrp/simple_usrp.cpp8
-rw-r--r--host/lib/usrp/subdev_spec.cpp21
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp16
-rw-r--r--host/test/subdev_spec_test.cpp8
6 files changed, 56 insertions, 29 deletions
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,13 +19,32 @@
#define INCLUDED_UHD_USRP_SUBDEV_SPEC_HPP
#include <uhd/config.hpp>
-#include <utility> //std::pair
#include <vector>
#include <string>
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:
*
* A subdevice specification represents a list of subdevices on a motherboard.
@@ -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<std::pair<std::string, std::string> >{
+ class UHD_API subdev_spec_t : public std::vector<subdev_spec_pair_t>{
public:
- typedef std::pair<std::string, std::string> 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<subdev_spec_t>().front().first;
+ std::string db_name = _mboard(chan)[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>().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<subdev_spec_t>().front().first;
+ std::string db_name = _mboard(chan)[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>().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<subdev_spec_t>().front().first;
+ std::string sd_name = _mboard(chan)[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>().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<subdev_spec_t>().front().first;
+ std::string sd_name = _mboard(chan)[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>().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<subdev_spec_t>().front().first;
+ std::string db_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>().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<subdev_spec_t>().front().first;
+ std::string db_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>().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<subdev_spec_t>().front().first;
+ std::string sd_name = _mboard()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>().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<subdev_spec_t>().front().first;
+ std::string sd_name = _mboard()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>().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<std::string> 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<std::string> 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<subdev_spec_t>();
//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<prop_names_t>(), _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<prop_names_t>(), _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<subdev_conn_t>()
+ _dboard_manager->get_rx_subdev(_rx_subdev_spec.front().sd_name)[SUBDEV_PROP_CONNECTION].as<subdev_conn_t>()
));
return;
@@ -340,16 +340,16 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){
_tx_subdev_spec = val.as<subdev_spec_t>();
//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<prop_names_t>(), _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<prop_names_t>(), _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<subdev_conn_t>()
+ _dboard_manager->get_tx_subdev(_tx_subdev_spec.front().sd_name)[SUBDEV_PROP_CONNECTION].as<subdev_conn_t>()
));
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);
}
}