diff options
author | Josh Blum <josh@joshknows.com> | 2010-01-29 00:24:15 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-01-29 00:24:15 -0800 |
commit | 30a8d2ecc36ce8ad6c01032e514ac66a277f06d0 (patch) | |
tree | 894b16a38d02c677ab2038932838064edc325ab4 /lib/usrp/dboard | |
parent | d5d9da3114bf069c05a8dcb7fca32ccd70405512 (diff) | |
download | uhd-30a8d2ecc36ce8ad6c01032e514ac66a277f06d0.tar.gz uhd-30a8d2ecc36ce8ad6c01032e514ac66a277f06d0.tar.bz2 uhd-30a8d2ecc36ce8ad6c01032e514ac66a277f06d0.zip |
Added dboard id enum.
Moved timespec into its own header.
Diffstat (limited to 'lib/usrp/dboard')
-rw-r--r-- | lib/usrp/dboard/Makefile.am | 1 | ||||
-rw-r--r-- | lib/usrp/dboard/id.cpp | 27 | ||||
-rw-r--r-- | lib/usrp/dboard/manager.cpp | 11 |
3 files changed, 34 insertions, 5 deletions
diff --git a/lib/usrp/dboard/Makefile.am b/lib/usrp/dboard/Makefile.am index 20d28c9ed..3d14fc115 100644 --- a/lib/usrp/dboard/Makefile.am +++ b/lib/usrp/dboard/Makefile.am @@ -16,6 +16,7 @@ dboard_sources = \ lib_la_SOURCES = \ $(dboard_sources) \ base.cpp \ + id.cpp \ interface.cpp \ manager.cpp diff --git a/lib/usrp/dboard/id.cpp b/lib/usrp/dboard/id.cpp new file mode 100644 index 000000000..0aee3439e --- /dev/null +++ b/lib/usrp/dboard/id.cpp @@ -0,0 +1,27 @@ +// +// Copyright 2010 Ettus Research LLC +// + +#include <usrp_uhd/usrp/dboard/id.hpp> +#include <boost/assign/list_of.hpp> +#include <boost/format.hpp> +#include <map> + +using namespace usrp_uhd::usrp::dboard; + +std::ostream& operator<<(std::ostream &os, const dboard_id_t &id){ + //map the dboard ids to string representations + std::map<dboard_id_t, std::string> id_to_str = boost::assign::map_list_of + (ID_BASIC_TX, "basic tx") + (ID_BASIC_RX, "basic rx") + ; + + //get the string representation + if (id_to_str.count(id) != 0){ + os << id_to_str[id]; + } + else{ + os << boost::format("dboard id %u") % unsigned(id); + } + return os; +} diff --git a/lib/usrp/dboard/manager.cpp b/lib/usrp/dboard/manager.cpp index e9d973cb5..43152a064 100644 --- a/lib/usrp/dboard/manager.cpp +++ b/lib/usrp/dboard/manager.cpp @@ -11,6 +11,7 @@ using namespace usrp_uhd; using namespace usrp_uhd::usrp::dboard; +using namespace boost::assign; /*********************************************************************** * register internal dboards @@ -28,16 +29,16 @@ static void register_internal_dboards(void){ //ensure that this function can only be called once per instance static bool called = false; if (called) return; called = true; - //register the known dboards (dboard id, constructor, num subdevs) - manager::register_subdevs(0x0000, &basic_tx::make, boost::assign::list_of("")); - manager::register_subdevs(0x0001, &basic_rx::make, boost::assign::list_of("a")("b")("ab")); + //register the known dboards (dboard id, constructor, subdev names) + manager::register_subdevs(ID_BASIC_TX, &basic_tx::make, list_of("")); + manager::register_subdevs(ID_BASIC_RX, &basic_rx::make, list_of("a")("b")("ab")); } /*********************************************************************** * storage and registering for dboards **********************************************************************/ //map a dboard id to a dboard constructor -static std::map<manager::dboard_id_t, manager::dboard_ctor_t> id_to_ctor_map; +static std::map<dboard_id_t, manager::dboard_ctor_t> id_to_ctor_map; //map a dboard constructor to subdevice names static std::map<manager::dboard_ctor_t, prop_names_t> ctor_to_names_map; @@ -99,7 +100,7 @@ private: * dboard manager methods **********************************************************************/ static manager::dboard_ctor_t const& get_dboard_ctor( - manager::dboard_id_t dboard_id, + dboard_id_t dboard_id, std::string const& xx_type ){ //verify that there is a registered constructor for this id |