From 4a19b43176fe3402d5aefd588d2bf6446877de18 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 2 May 2010 12:16:41 -0700 Subject: Cleaned up some dboard manager construction logic. Moved the dboard base private stuff into a forward declaration. --- host/lib/usrp/dboard_manager.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'host/lib/usrp/dboard_manager.cpp') diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index 390c1d3c9..85d651c0c 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -26,6 +26,7 @@ #include #include #include +#include using namespace uhd; using namespace uhd::usrp; @@ -162,26 +163,27 @@ dboard_manager::sptr dboard_manager::make( * implementation class methods **********************************************************************/ static args_t get_dboard_args( - dboard_id_t dboard_id, - std::string const& xx_type + dboard_iface::unit_t unit, + dboard_id_t dboard_id ){ - //special case, its rx and the none id (0xffff) - if (xx_type == "rx" and dboard_id == dboard_id::NONE){ - return get_dboard_args(0x0001, xx_type); - } - - //special case, its tx and the none id (0xffff) - if (xx_type == "tx" and dboard_id == dboard_id::NONE){ - return get_dboard_args(0x0000, xx_type); + //special case, the none id was provided, use the following ids + if (dboard_id == dboard_id::NONE){ + std::cerr << boost::format( + "Warning: unregistered dboard id: %s" + " -> defaulting to a basic board" + ) % dboard_id::to_string(dboard_id) << std::endl; + UHD_ASSERT_THROW(get_id_to_args_map().has_key(0x0001)); + UHD_ASSERT_THROW(get_id_to_args_map().has_key(0x0000)); + switch(unit){ + case dboard_iface::UNIT_RX: return get_dboard_args(unit, 0x0001); + case dboard_iface::UNIT_TX: return get_dboard_args(unit, 0x0000); + default: UHD_ASSERT_THROW(false); + } } //verify that there is a registered constructor for this id if (not get_id_to_args_map().has_key(dboard_id)){ - /*throw std::runtime_error(str( - boost::format("Unregistered %s dboard id: %s") - % xx_type % dboard_id::to_string(dboard_id) - ));*/ - return get_dboard_args(dboard_id::NONE, xx_type); + return get_dboard_args(unit, dboard_id::NONE); } //return the dboard args for this id @@ -196,10 +198,10 @@ dboard_manager_impl::dboard_manager_impl( _iface = iface; dboard_ctor_t rx_dboard_ctor; std::string rx_name; prop_names_t rx_subdevs; - boost::tie(rx_dboard_ctor, rx_name, rx_subdevs) = get_dboard_args(rx_dboard_id, "rx"); + boost::tie(rx_dboard_ctor, rx_name, rx_subdevs) = get_dboard_args(dboard_iface::UNIT_RX, rx_dboard_id); dboard_ctor_t tx_dboard_ctor; std::string tx_name; prop_names_t tx_subdevs; - boost::tie(tx_dboard_ctor, tx_name, tx_subdevs) = get_dboard_args(tx_dboard_id, "tx"); + boost::tie(tx_dboard_ctor, tx_name, tx_subdevs) = get_dboard_args(dboard_iface::UNIT_TX, tx_dboard_id); //initialize the gpio pins before creating subdevs set_nice_dboard_if(); -- cgit v1.2.3