From 1be93abaef6b9c64fb6bd04ab639166fec5af550 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Mon, 5 Nov 2018 15:21:48 -0800 Subject: mpmd: Improve error message for compat number mismatches --- host/lib/usrp/mpmd/mpmd_impl.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/host/lib/usrp/mpmd/mpmd_impl.cpp b/host/lib/usrp/mpmd/mpmd_impl.cpp index 80061ede3..87e911e17 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_impl.cpp @@ -106,11 +106,14 @@ namespace { * number. * \param actual Tuple of 2 integers representing MAJOR.MINOR compat * number. + * \param advice_on_failure A string that is appended to the error message + * when compat number mismatches have occurred. */ void assert_compat_number_throw( const std::string &component, const std::vector &expected, - const std::vector &actual + const std::vector &actual, + const std::string& advice_on_failure="" ) { UHD_ASSERT_THROW(expected.size() == 2); UHD_ASSERT_THROW(actual.size() == 2); @@ -124,20 +127,24 @@ namespace { if (actual[0] != expected[0]) { const std::string err_msg = str(boost::format("%s major compat number mismatch. " - "Expected: %i.%i Actual: %i.%i") + "Expected: %i.%i Actual: %i.%i.%s%s") % component % expected[0] % expected[1] - % actual[0] % actual[1]); + % actual[0] % actual[1] + % (advice_on_failure.empty() ? "" : " ") + % advice_on_failure); UHD_LOG_ERROR("MPMD", err_msg); throw uhd::runtime_error(err_msg); } if (actual[1] < expected[1]) { const std::string err_msg = str(boost::format("%s minor compat number mismatch. " - "Expected: %i.%i Actual: %i.%i") + "Expected: %i.%i Actual: %i.%i.%s%s") % component % expected[0] % expected[1] - % actual[0] % actual[1]); + % actual[0] % actual[1] + % (advice_on_failure.empty() ? "" : " ") + % advice_on_failure); UHD_LOG_ERROR("MPMD", err_msg); throw uhd::runtime_error(err_msg); } @@ -279,7 +286,8 @@ void mpmd_impl::setup_mb( assert_compat_number_throw( "MPM", MPM_COMPAT_NUM, - mb->rpc->request>("get_mpm_compat_num") + mb->rpc->request>("get_mpm_compat_num"), + "Please update the version of MPM on your USRP device." ); UHD_LOG_DEBUG("MPMD", "Initializing mboard " << mb_index); -- cgit v1.2.3