From 40235b8c5aba6acec2acdc4135b828b1d9785a96 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sat, 3 Jun 2017 01:33:54 -0700 Subject: mpm/mpmd: Call init() during UHD session init, not on hwd spawn --- host/lib/usrp/mpmd/mpmd_mboard_impl.cpp | 39 +++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'host/lib/usrp/mpmd/mpmd_mboard_impl.cpp') diff --git a/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp b/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp index 82967ecad..135d2973e 100644 --- a/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp @@ -22,7 +22,12 @@ #include namespace { - const size_t MPMD_RECLAIM_INTERVAL_MS = 1000; + //! Time between reclaims (ms) + const size_t MPMD_RECLAIM_INTERVAL_MS = 1000; + //! Default timeout value for the init() RPC call (ms) + const size_t MPMD_DEFAULT_INIT_TIMEOUT = 30000; + //! Default timeout value for RPC calls (ms) + const size_t MPMD_DEFAULT_RPC_TIMEOUT = 2000; const std::string MPMD_DEFAULT_SESSION_ID = "UHD"; } @@ -43,12 +48,6 @@ mpmd_mboard_impl::mpmd_mboard_impl( << rpc_server_addr << " mboard args: " << mb_args.to_string() ; - auto device_info_dict = rpc->request("get_device_info"); - for (const auto &info_pair: device_info_dict) { - device_info[info_pair.first] = info_pair.second; - } - UHD_LOGGER_TRACE("MPMD") - << "MPM reports device info: " << device_info.to_string(); // Claim logic auto rpc_token = rpc->request("claim", @@ -68,6 +67,32 @@ mpmd_mboard_impl::mpmd_mboard_impl( ); }); + // Init and query info + std::map mpm_device_args; + const std::set key_blacklist{ // TODO put this somewhere else + "serial", "claimed", "type", "rev", "addr" + }; + for (const auto &key : mb_args.keys()) { + if (not key_blacklist.count(key)) { + mpm_device_args[key] = mb_args[key]; + } + } + rpc->set_timeout(mb_args.cast( + "init_timeout", MPMD_DEFAULT_INIT_TIMEOUT + )); + if (not rpc->request_with_token("init", mpm_device_args)) { + throw uhd::runtime_error("Failed to initialize device."); + } + auto device_info_dict = rpc->request("get_device_info"); + for (const auto &info_pair : device_info_dict) { + device_info[info_pair.first] = info_pair.second; + } + UHD_LOGGER_TRACE("MPMD") + << "MPM reports device info: " << device_info.to_string(); + rpc->set_timeout(mb_args.cast( + "rpc_timeout", MPMD_DEFAULT_RPC_TIMEOUT + )); + // Initialize properties this->num_xbars = rpc->request("get_num_xbars"); // Local addresses are not yet valid after this! -- cgit v1.2.3