diff options
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | INSTALL | 5 | ||||
-rw-r--r-- | include/usrp_uhd/Makefile.am | 1 | ||||
-rw-r--r-- | include/usrp_uhd/props.hpp | 32 | ||||
-rw-r--r-- | include/usrp_uhd/time_spec.hpp | 44 | ||||
-rw-r--r-- | include/usrp_uhd/usrp/dboard/Makefile.am | 1 | ||||
-rw-r--r-- | include/usrp_uhd/usrp/dboard/id.hpp | 21 | ||||
-rw-r--r-- | include/usrp_uhd/usrp/dboard/manager.hpp | 3 | ||||
-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 | ||||
-rw-r--r-- | lib/usrp/mboard/test.cpp | 2 | ||||
-rw-r--r-- | test/usrp_dboard_test.cpp | 2 |
13 files changed, 111 insertions, 40 deletions
@@ -0,0 +1 @@ +Josh Blum - josh@ettus.com @@ -0,0 +1,5 @@ +./bootstrap +./configure +make +make check +sudo make install diff --git a/include/usrp_uhd/Makefile.am b/include/usrp_uhd/Makefile.am index 0a19bfe56..c546fd0e2 100644 --- a/include/usrp_uhd/Makefile.am +++ b/include/usrp_uhd/Makefile.am @@ -12,5 +12,6 @@ this_include_HEADERS = \ device_addr.hpp \ gain_handler.hpp \ props.hpp \ + time_spec.hpp \ utils.hpp \ wax.hpp diff --git a/include/usrp_uhd/props.hpp b/include/usrp_uhd/props.hpp index b74493961..2e740045f 100644 --- a/include/usrp_uhd/props.hpp +++ b/include/usrp_uhd/props.hpp @@ -3,46 +3,16 @@ // #include <boost/tuple/tuple.hpp> +#include <usrp_uhd/time_spec.hpp> #include <usrp_uhd/wax.hpp> #include <complex> #include <vector> -#include <stdint.h> #ifndef INCLUDED_USRP_UHD_PROPS_HPP #define INCLUDED_USRP_UHD_PROPS_HPP namespace usrp_uhd{ - /*! - * A time_spec_t holds a seconds and ticks time value. - * The temporal width of a tick depends on the device's clock rate. - * The time_spec_t can be used when setting the time on devices - * and for controlling the start of streaming for applicable dsps. - */ - struct time_spec_t{ - uint32_t secs; - uint32_t ticks; - - /*! - * Create a time_spec_t that holds a wildcard time. - * This will have implementation-specific meaning. - */ - time_spec_t(void){ - secs = ~0; - ticks = ~0; - } - - /*! - * Create a time_spec_t from seconds and ticks. - * \param new_secs the new seconds - * \param new_ticks the new ticks (default = 0) - */ - time_spec_t(uint32_t new_secs, uint32_t new_ticks = 0){ - secs = new_secs; - ticks = new_ticks; - } - }; - //common typedefs for board properties typedef float gain_t; typedef double freq_t; diff --git a/include/usrp_uhd/time_spec.hpp b/include/usrp_uhd/time_spec.hpp new file mode 100644 index 000000000..dc16a72aa --- /dev/null +++ b/include/usrp_uhd/time_spec.hpp @@ -0,0 +1,44 @@ +// +// Copyright 2010 Ettus Research LLC +// + +#include <stdint.h> + +#ifndef INCLUDED_USRP_UHD_TIME_SPEC_HPP +#define INCLUDED_USRP_UHD_TIME_SPEC_HPP + +namespace usrp_uhd{ + + /*! + * A time_spec_t holds a seconds and ticks time value. + * The temporal width of a tick depends on the device's clock rate. + * The time_spec_t can be used when setting the time on devices + * and for controlling the start of streaming for applicable dsps. + */ + struct time_spec_t{ + uint32_t secs; + uint32_t ticks; + + /*! + * Create a time_spec_t that holds a wildcard time. + * This will have implementation-specific meaning. + */ + time_spec_t(void){ + secs = ~0; + ticks = ~0; + } + + /*! + * Create a time_spec_t from seconds and ticks. + * \param new_secs the new seconds + * \param new_ticks the new ticks (default = 0) + */ + time_spec_t(uint32_t new_secs, uint32_t new_ticks = 0){ + secs = new_secs; + ticks = new_ticks; + } + }; + +} //namespace usrp_uhd + +#endif /* INCLUDED_USRP_UHD_TIME_SPEC_HPP */ diff --git a/include/usrp_uhd/usrp/dboard/Makefile.am b/include/usrp_uhd/usrp/dboard/Makefile.am index d8c240351..2ce268a41 100644 --- a/include/usrp_uhd/usrp/dboard/Makefile.am +++ b/include/usrp_uhd/usrp/dboard/Makefile.am @@ -9,5 +9,6 @@ SUBDIRS = this_includedir = $(includedir)/usrp_uhd/usrp/dboard this_include_HEADERS = \ base.hpp \ + id.hpp \ interface.hpp \ manager.hpp diff --git a/include/usrp_uhd/usrp/dboard/id.hpp b/include/usrp_uhd/usrp/dboard/id.hpp new file mode 100644 index 000000000..b2dc7b7cf --- /dev/null +++ b/include/usrp_uhd/usrp/dboard/id.hpp @@ -0,0 +1,21 @@ +// +// Copyright 2010 Ettus Research LLC +// + +#include <iostream> + +#ifndef INCLUDED_USRP_UHD_USRP_DBOARD_ID_HPP +#define INCLUDED_USRP_UHD_USRP_DBOARD_ID_HPP + +namespace usrp_uhd{ namespace usrp{ namespace dboard{ + +enum dboard_id_t{ + ID_BASIC_TX = 0x0000, + ID_BASIC_RX = 0x0001 +}; + +}}} //namespace + +std::ostream& operator<<(std::ostream &, const usrp_uhd::usrp::dboard::dboard_id_t &); + +#endif /* INCLUDED_USRP_UHD_USRP_DBOARD_ID_HPP */ diff --git a/include/usrp_uhd/usrp/dboard/manager.hpp b/include/usrp_uhd/usrp/dboard/manager.hpp index 4eaa9f889..56adf5eea 100644 --- a/include/usrp_uhd/usrp/dboard/manager.hpp +++ b/include/usrp_uhd/usrp/dboard/manager.hpp @@ -11,6 +11,7 @@ #include <boost/utility.hpp> #include <boost/shared_ptr.hpp> #include <usrp_uhd/usrp/dboard/base.hpp> +#include <usrp_uhd/usrp/dboard/id.hpp> namespace usrp_uhd{ namespace usrp{ namespace dboard{ @@ -22,8 +23,6 @@ namespace usrp_uhd{ namespace usrp{ namespace dboard{ class manager : boost::noncopyable{ public: - //a dboard can be identified by a 16 bit integer - typedef uint16_t dboard_id_t; //dboard constructor (each dboard should have a ::make with this signature) typedef base::sptr(*dboard_ctor_t)(base::ctor_args_t const&); 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 diff --git a/lib/usrp/mboard/test.cpp b/lib/usrp/mboard/test.cpp index 321ec0855..f3bcca670 100644 --- a/lib/usrp/mboard/test.cpp +++ b/lib/usrp/mboard/test.cpp @@ -100,7 +100,7 @@ test::test(const device_addr_t &device_addr){ for (size_t i = 0; i < device_addr.virtual_args.num_dboards; i++){ dboard::interface::sptr ifc(new dummy_interface()); _dboard_managers[boost::lexical_cast<std::string>(i)] = dboard::manager::sptr( - new dboard::manager(0x0001, 0x0000, ifc) + new dboard::manager(dboard::ID_BASIC_RX, dboard::ID_BASIC_TX, ifc) ); } } diff --git a/test/usrp_dboard_test.cpp b/test/usrp_dboard_test.cpp index d297c26ab..9b5bf7985 100644 --- a/test/usrp_dboard_test.cpp +++ b/test/usrp_dboard_test.cpp @@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE(test_manager){ interface::sptr ifc0(new dummy_interface()); std::cout << "Making a usrp dboard manager..." << std::endl; - manager::sptr mgr0(new manager(0x0001, 0x0000, ifc0)); //basic rx, basic tx + manager::sptr mgr0(new manager(ID_BASIC_RX, ID_BASIC_TX, ifc0)); std::cout << "Testing the dboard manager..." << std::endl; BOOST_CHECK_EQUAL(size_t(3), mgr0->get_rx_subdev_names().size()); |