From 7cab06dd395928f3cc68560ec3947c181046f017 Mon Sep 17 00:00:00 2001 From: Brent Stapleton Date: Mon, 6 Nov 2017 09:54:06 -0800 Subject: fpga load: adding updateable components to mpmd property tree The FPGA image, and other components, can now be set from the property tree. The registered function expects a component_file_t, which combines the data file and metadata dictionary. --- host/lib/usrp/mpmd/mpmd_impl.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/host/lib/usrp/mpmd/mpmd_impl.cpp b/host/lib/usrp/mpmd/mpmd_impl.cpp index fa10c74e8..6285ca11c 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_impl.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,23 @@ namespace { /************************************************************************* * Helper functions ************************************************************************/ + uhd::usrp::component_file_t _update_component( + const uhd::usrp::component_file_t& comp, + mpmd_mboard_impl *mb + ) { + std::vector data = comp.data; + std::map metadata; + for (const auto& key : comp.metadata.keys()) { + metadata[key] = comp.metadata[key]; + } + mb->rpc->notify_with_token("update_component", metadata, data); + + uhd::usrp::component_file_t comp_copy; + comp_copy.metadata = comp.metadata; + return comp_copy; + } + + void init_property_tree( uhd::property_tree::sptr tree, fs_path mb_path, @@ -151,6 +169,26 @@ namespace { return mb_eeprom_dict; }) ; + + /*** Updateable Components ******************************************/ + std::vector updateable_components = {"fpga"}; + //TODO: get with "list_updateable_components" + UHD_LOG_DEBUG("MPMD", + "Found " << updateable_components.size() << " updateable motherboard components." + ); + for (const auto& comp_name : updateable_components) { + UHD_LOG_TRACE("MPMD", + "Adding motherboard component: " << comp_name); + tree->create(mb_path / "components" / comp_name) + .set_coercer([mb](const uhd::usrp::component_file_t& comp_file) { + return _update_component( + comp_file, + mb + ); + }) + ; + } + } void reset_time_synchronized(uhd::property_tree::sptr tree) -- cgit v1.2.3