diff options
author | Derek Kozel <derek.kozel@ettus.com> | 2016-07-28 18:14:20 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2016-08-09 10:21:53 -0700 |
commit | f360059b99d4ae11e5279b8999364ec1fe2997a3 (patch) | |
tree | 04b46481c368569ff1aeb3c1d7ff2a411a7f27bc | |
parent | 8607cf96932120bab3d4775ff297801add6403a0 (diff) | |
download | uhd-f360059b99d4ae11e5279b8999364ec1fe2997a3.tar.gz uhd-f360059b99d4ae11e5279b8999364ec1fe2997a3.tar.bz2 uhd-f360059b99d4ae11e5279b8999364ec1fe2997a3.zip |
dboard manager: Allow deferring dboard initialization
-rw-r--r-- | host/include/uhd/usrp/dboard_manager.hpp | 9 | ||||
-rw-r--r-- | host/lib/usrp/dboard_manager.cpp | 51 |
2 files changed, 48 insertions, 12 deletions
diff --git a/host/include/uhd/usrp/dboard_manager.hpp b/host/include/uhd/usrp/dboard_manager.hpp index 4ce943972..85fa65e81 100644 --- a/host/include/uhd/usrp/dboard_manager.hpp +++ b/host/include/uhd/usrp/dboard_manager.hpp @@ -124,6 +124,7 @@ public: * \param gdboard_id the id of the grand-dboard * \param iface the custom dboard interface * \param subtree the subtree to load with props + * \param bool defer initialising the daughterboards * \return an sptr to the new dboard manager */ static sptr make( @@ -131,12 +132,18 @@ public: dboard_id_t tx_dboard_id, dboard_id_t gdboard_id, dboard_iface::sptr iface, - property_tree::sptr subtree + property_tree::sptr subtree, + bool defer_db_init = false ); virtual ~dboard_manager() {} /*! + * Run dboard post constructor initializations if defered during make + */ + virtual void initialize_dboards() = 0; + + /*! * Returns a vector of RX frontend (subdev) names * \return a vector of names */ diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index 6099adcbb..56cd08fd7 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -182,7 +182,8 @@ public: dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, dboard_iface::sptr iface, - property_tree::sptr subtree + property_tree::sptr subtree, + bool defer_db_init ); virtual ~dboard_manager_impl(void); @@ -194,13 +195,17 @@ public: return _tx_frontends; } + void initialize_dboards(); + private: - void init(dboard_id_t, dboard_id_t, property_tree::sptr); + void init(dboard_id_t, dboard_id_t, property_tree::sptr, bool); //list of rx and tx dboards in this dboard_manager //each dboard here is actually a subdevice proxy //the subdevice proxy is internal to the cpp file uhd::dict<std::string, dboard_base::sptr> _rx_dboards; uhd::dict<std::string, dboard_base::sptr> _tx_dboards; + std::vector<dboard_base::sptr> _rx_containers; + std::vector<dboard_base::sptr> _tx_containers; std::vector<std::string> _rx_frontends; std::vector<std::string> _tx_frontends; dboard_iface::sptr _iface; @@ -215,13 +220,14 @@ dboard_manager::sptr dboard_manager::make( dboard_id_t tx_dboard_id, dboard_id_t gdboard_id, dboard_iface::sptr iface, - property_tree::sptr subtree + property_tree::sptr subtree, + bool defer_db_init ){ return dboard_manager::sptr( new dboard_manager_impl( rx_dboard_id, (gdboard_id == dboard_id_t::none())? tx_dboard_id : gdboard_id, - iface, subtree + iface, subtree, defer_db_init ) ); } @@ -233,12 +239,13 @@ dboard_manager_impl::dboard_manager_impl( dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, dboard_iface::sptr iface, - property_tree::sptr subtree + property_tree::sptr subtree, + bool defer_db_init ): _iface(iface) { try{ - this->init(rx_dboard_id, tx_dboard_id, subtree); + this->init(rx_dboard_id, tx_dboard_id, subtree, defer_db_init); } catch(const std::exception &e){ UHD_MSG(error) << boost::format( @@ -250,12 +257,12 @@ dboard_manager_impl::dboard_manager_impl( if (subtree->exists("rx_frontends")) subtree->remove("rx_frontends"); if (subtree->exists("tx_frontends")) subtree->remove("tx_frontends"); if (subtree->exists("iface")) subtree->remove("iface"); - this->init(dboard_id_t::none(), dboard_id_t::none(), subtree); + this->init(dboard_id_t::none(), dboard_id_t::none(), subtree, false); } } void dboard_manager_impl::init( - dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, property_tree::sptr subtree + dboard_id_t rx_dboard_id, dboard_id_t tx_dboard_id, property_tree::sptr subtree, bool defer_db_init ){ //find the dboard key matches for the dboard ids dboard_key_t rx_dboard_key, tx_dboard_key, xcvr_dboard_key; @@ -327,7 +334,11 @@ void dboard_manager_impl::init( //initialize the container after all subdevs have been created if (container_ctor) { - db_ctor_args.rx_container->initialize(); + if (defer_db_init) { + _rx_containers.push_back(db_ctor_args.rx_container); + } else { + db_ctor_args.rx_container->initialize(); + } } //Populate frontend names in-order. @@ -371,7 +382,11 @@ void dboard_manager_impl::init( //initialize the container after all subdevs have been created if (rx_cont_ctor) { - db_ctor_args.rx_container->initialize(); + if (defer_db_init) { + _rx_containers.push_back(db_ctor_args.rx_container); + } else { + db_ctor_args.rx_container->initialize(); + } } //force the tx key to the unknown board for bad combinations @@ -406,7 +421,11 @@ void dboard_manager_impl::init( //initialize the container after all subdevs have been created if (tx_cont_ctor) { - db_ctor_args.tx_container->initialize(); + if (defer_db_init) { + _tx_containers.push_back(db_ctor_args.tx_container); + } else { + db_ctor_args.tx_container->initialize(); + } } //Populate frontend names in-order. @@ -416,6 +435,16 @@ void dboard_manager_impl::init( } } +void dboard_manager_impl::initialize_dboards(void) { + BOOST_FOREACH(dboard_base::sptr& _rx_container, _rx_containers) { + _rx_container->initialize(); + } + + BOOST_FOREACH(dboard_base::sptr& _tx_container, _tx_containers) { + _tx_container->initialize(); + } +} + dboard_manager_impl::~dboard_manager_impl(void){UHD_SAFE_CALL( set_nice_dboard_if(); )} |