From a91c4b2226a990b6eb78dec327793873315b18ed Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Mon, 26 Mar 2018 10:52:41 -0700 Subject: x300: Properly coerce master clock rate (tick rate) - A call to multi_usrp::set_master_clock_rate() on the X3x0 will now properly coerce the value, and show a warning when it had to coerce. It will not throw an exception. - Did a minirefactoring of the tick_rate property setup and removed two more boost::binds. --- host/lib/usrp/x300/x300_impl.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'host/lib/usrp') diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index 9ea3a814d..3abaf21c7 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -968,11 +969,28 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) _tree->create(mb_path / "clock_source" / "output") .add_coerced_subscriber(boost::bind(&x300_clock_ctrl::set_ref_out, mb.clock, _1)); - //initialize tick rate (must be done before setting time) + // Initialize tick rate (must be done before setting time) + // Note: The master tick rate can't be changed at runtime! + const double master_clock_rate = mb.clock->get_master_clock_rate(); _tree->create(mb_path / "tick_rate") - .add_coerced_subscriber(boost::bind(&device3_impl::update_tx_streamers, this, _1)) - .add_coerced_subscriber(boost::bind(&device3_impl::update_rx_streamers, this, _1)) - .set(mb.clock->get_master_clock_rate()) + .set_coercer([master_clock_rate](const double rate){ + // The contract of multi_usrp::set_master_clock_rate() is to coerce + // and not throw, so we'll follow that behaviour here. + if (!uhd::math::frequencies_are_equal(rate, master_clock_rate)) { + UHD_LOGGER_WARNING("X300") << + "Cannot update master clock rate! X300 Series does not " + "allow changing the clock rate during runtime." + ; + } + return master_clock_rate; + }) + .add_coerced_subscriber([this](const double rate){ + this->update_tx_streamers(rate); + }) + .add_coerced_subscriber([this](const double rate){ + this->update_rx_streamers(rate); + }) + .set(master_clock_rate) ; //////////////////////////////////////////////////////////////////// -- cgit v1.2.3