diff options
-rw-r--r-- | host/lib/usrp/mpmd/mpmd_impl.cpp | 27 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/rpc_server.py | 6 |
2 files changed, 33 insertions, 0 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_impl.cpp b/host/lib/usrp/mpmd/mpmd_impl.cpp index d8d21a464..d020e3546 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_impl.cpp @@ -49,6 +49,8 @@ namespace { const double MPMD_FIND_TIMEOUT = 0.5; //! 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<size_t> MPM_COMPAT_NUM = {1, 0}; const std::string MPMD_MGMT_ADDR_KEY = "mgmt_addr"; @@ -361,6 +363,31 @@ mpmd_mboard_impl::uptr mpmd_impl::setup_mb( } auto mb = mpmd_mboard_impl::make(device_args, rpc_addr); + // Check the compatibility number + UHD_LOGGER_TRACE("MPMD") << boost::format( + "Checking MPM compat number against ours: %i.%i") + % MPM_COMPAT_NUM[0] % MPM_COMPAT_NUM[1]; + const auto compat_num = mb->rpc->request<std::vector<size_t>>("get_mpm_compat_num"); + UHD_LOGGER_TRACE("MPMD") << boost::format( + "Compat number received: %d.%d") + % compat_num[0] % compat_num[1]; + + const size_t c_major = compat_num[0], c_minor = compat_num[1]; + if (c_major != MPM_COMPAT_NUM[0]) { + UHD_LOGGER_ERROR("MPMD") << boost::format( + "MPM major compat number mismatch." + "Expected %i.%i Actual %i.%i") + % MPM_COMPAT_NUM[0] % MPM_COMPAT_NUM[1] % c_major % c_minor; + throw uhd::runtime_error("MPM compatibility number mismatch."); + } + if (c_minor < MPM_COMPAT_NUM[1]) { + UHD_LOGGER_ERROR("MPMD") << boost::format( + "MPM minor compat number mismatch." + "Expected %d.%d Actual %d.%d") + % MPM_COMPAT_NUM[0] % MPM_COMPAT_NUM[1] % c_major % c_minor; + throw uhd::runtime_error("MPM compatibility number mismatch."); + } + if (device_args.has_key("skip_init")) { return mb; } diff --git a/mpm/python/usrp_mpm/rpc_server.py b/mpm/python/usrp_mpm/rpc_server.py index c3b4fc2dd..cf3f4a21b 100644 --- a/mpm/python/usrp_mpm/rpc_server.py +++ b/mpm/python/usrp_mpm/rpc_server.py @@ -45,6 +45,8 @@ class MPMServer(RPCServer): """ # This is a list of methods in this class which require a claim default_claimed_methods = ['init', 'update_component', 'reclaim', 'unclaim'] + # Compatibility number for MPM + MPM_COMPAT_NUM = (1, 0) def __init__(self, state, mgr, mgr_generator=None, *args, **kwargs): self.log = get_main_logger().getChild('RPCServer') @@ -240,6 +242,10 @@ class MPMServer(RPCServer): self.periph_manager.set_connection_type("remote") return self._state.claim_token.value + def get_mpm_compat_num(self): + """Get the MPM compatibility number""" + self.log.trace("Compat num requested: {}".format(self.MPM_COMPAT_NUM)) + return self.MPM_COMPAT_NUM def init(self, token, args): """ |