From bd2a51855589a939159b42e702dd01684c7b1d80 Mon Sep 17 00:00:00 2001 From: Brent Stapleton Date: Fri, 2 Feb 2018 11:48:35 -0800 Subject: mpmd: add getter for components in property tree Adding a publisher for updateable components listed in the property tree. This calls MPM.get_component_info for the desired component, and returns a dictionary containing that metadata. --- host/lib/usrp/mpmd/mpmd_impl.cpp | 2 +- host/lib/usrp/mpmd/mpmd_prop_tree.cpp | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'host/lib/usrp') diff --git a/host/lib/usrp/mpmd/mpmd_impl.cpp b/host/lib/usrp/mpmd/mpmd_impl.cpp index 064b73893..4d3fba8a1 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_impl.cpp @@ -31,7 +31,7 @@ namespace { //! Most pessimistic time for a CHDR query to go to device and back const double MPMD_CHDR_MAX_RTT = 0.02; //! MPM Compatibility number - const std::vector MPM_COMPAT_NUM = {1, 1}; + const std::vector MPM_COMPAT_NUM = {1, 2}; /************************************************************************* * Helper functions diff --git a/host/lib/usrp/mpmd/mpmd_prop_tree.cpp b/host/lib/usrp/mpmd/mpmd_prop_tree.cpp index 64e68c486..a087b02dd 100644 --- a/host/lib/usrp/mpmd/mpmd_prop_tree.cpp +++ b/host/lib/usrp/mpmd/mpmd_prop_tree.cpp @@ -62,6 +62,28 @@ namespace { return all_comps_copy; } + /* + * Query the device to get the metadata for desired component + * + * \param comp_name String component name + * \param mb Reference to the actual device + * \return component files containing the component metadata + */ + uhd::usrp::component_files_t _get_component_info( + const std::string &comp_name, + mpmd_mboard_impl *mb + ) { + UHD_LOG_TRACE("MPMD", "Getting component info for " << comp_name); + const auto component_metadata = mb->rpc->request>( + "get_component_info", comp_name); + // Copy the contents of the component metadata into a object we can return + uhd::usrp::component_file_t return_component; + auto &return_metadata = return_component.metadata; + for (auto item : component_metadata) { + return_metadata[item.first] = item.second; + } + return uhd::usrp::component_files_t {return_component}; + } } void mpmd_impl::init_property_tree( @@ -210,13 +232,19 @@ void mpmd_impl::init_property_tree( UHD_LOG_TRACE("MPMD", "Adding motherboard component: " << comp_name); tree->create(mb_path / "components" / comp_name) - .set_coercer([mb](const uhd::usrp::component_files_t& comp_files) { + .set_coercer([mb](const uhd::usrp::component_files_t& comp_files){ return _update_component( comp_files, mb ); - }) - ; + }) + .set_publisher([mb, comp_name](){ + return _get_component_info( + comp_name, + mb + ); + }) + ; // Done adding component to property tree } /*** MTUs ***********************************************************/ -- cgit v1.2.3