diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-06-06 00:53:01 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:03:59 -0800 |
commit | eb4a0cb6ebcff0bf3844df690a2d7653700211f2 (patch) | |
tree | 8eefda94a40ab2d96449e4b8d34760829c3c5852 /host/lib/usrp | |
parent | 14f0e113d967c9a9098be8cfea7f333c4bf5373f (diff) | |
download | uhd-eb4a0cb6ebcff0bf3844df690a2d7653700211f2.tar.gz uhd-eb4a0cb6ebcff0bf3844df690a2d7653700211f2.tar.bz2 uhd-eb4a0cb6ebcff0bf3844df690a2d7653700211f2.zip |
mpmd/mpm/n310: Added clock and time source APIs
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_impl.cpp | 61 | ||||
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_mboard_impl.cpp | 4 |
2 files changed, 63 insertions, 2 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_impl.cpp b/host/lib/usrp/mpmd/mpmd_impl.cpp index 04d66a5c4..533b5dabf 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_impl.cpp @@ -37,7 +37,63 @@ using namespace uhd; namespace { + /************************************************************************* + * Local constants + ************************************************************************/ const size_t MPMD_CROSSBAR_MAX_LADDR = 255; + + /************************************************************************* + * Helper functions + ************************************************************************/ + void init_property_tree( + uhd::property_tree::sptr tree, + fs_path mb_path, + mpmd_mboard_impl *mb + ) { + if (not tree->exists(fs_path("/name"))) { + tree->create<std::string>("/name") + .set(mb->device_info.get("name", "Unknown MPM device")) + ; + } + + /*** Clocking *******************************************************/ + tree->create<std::string>(mb_path / "clock_source/value") + .add_coerced_subscriber([mb](const std::string &clock_source){ + mb->rpc->notify_with_token("set_clock_source", clock_source); + }) + .set_publisher([mb](){ + return mb->rpc->request_with_token<std::string>( + "get_clock_source" + ); + }) + ; + tree->create<std::vector<std::string>>( + mb_path / "clock_source/options") + .set_publisher([mb](){ + return mb->rpc->request_with_token<std::vector<std::string>>( + "get_clock_sources" + ); + }) + ; + tree->create<std::string>(mb_path / "time_source/value") + .add_coerced_subscriber([mb](const std::string &time_source){ + mb->rpc->notify_with_token("set_time_source", time_source); + }) + .set_publisher([mb](){ + return mb->rpc->request_with_token<std::string>( + "get_time_source" + ); + }) + ; + tree->create<std::vector<std::string>>( + mb_path / "time_source/options") + .set_publisher([mb](){ + return mb->rpc->request_with_token<std::vector<std::string>>( + "get_time_sources" + ); + }) + ; + } } /***************************************************************************** @@ -76,8 +132,9 @@ mpmd_impl::mpmd_impl(const device_addr_t& device_args) setup_rfnoc_blocks(mb_i, mb_args[mb_i]); } - // TODO read this from the device info - _tree->create<std::string>("/name").set("MPMD - Series device"); + for (size_t mb_i = 0; mb_i < mb_args.size(); ++mb_i) { + init_property_tree(_tree, fs_path("/mboard") / mb_i, _mb[mb_i].get()); + } auto filtered_block_args = device_args; // TODO actually filter setup_rpc_blocks(filtered_block_args); diff --git a/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp b/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp index 135d2973e..0584813df 100644 --- a/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp @@ -22,6 +22,9 @@ #include <thread> namespace { + /************************************************************************* + * Local constants + ************************************************************************/ //! Time between reclaims (ms) const size_t MPMD_RECLAIM_INTERVAL_MS = 1000; //! Default timeout value for the init() RPC call (ms) @@ -30,6 +33,7 @@ namespace { const size_t MPMD_DEFAULT_RPC_TIMEOUT = 2000; const std::string MPMD_DEFAULT_SESSION_ID = "UHD"; + } using namespace uhd; |