From 9132fab60945f8665cac71a6921fd7e90ad68ec3 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 16 Jun 2015 16:27:22 -0700 Subject: b200: Modify initialization sequence to avoid warnings This will set the actual default rate to an integer factor of whatever the tick rate is, but leave the property tree value at zero. This avoids warnings if the chosen tick rate is not a multiple of the previous default rate, but also returns a zero value for the rate when it has not been initialized, allowing the user to probe if the value has not yet been set. --- host/lib/usrp/b200/b200_io_impl.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'host/lib/usrp/b200/b200_io_impl.cpp') diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp index 3171e25c3..c4e04f70a 100644 --- a/host/lib/usrp/b200/b200_io_impl.cpp +++ b/host/lib/usrp/b200/b200_io_impl.cpp @@ -111,16 +111,9 @@ void b200_impl::set_auto_tick_rate( % (this_dsp_rate / 1e6) % (max_tick_rate / 1e6) )); } - // If this_dsp_rate == B200_DEFAULT_RATE, we assume the user did not actually set - // the sampling rate. If the user *did* set the rate to - // B200_DEFAULT_RATE on all DSPs, then this will still work (see below). - // If the user set one DSP to B200_DEFAULT_RATE and the other to - // a different rate, this also works if the rates are integer multiples - // of one another. Only for certain configurations of B200_DEFAULT_RATE - // and another rate that is not an integer multiple, this will be problematic. - // Since this case is less common than the case where a rate is left unset, - // we don't handle that but rather explain that corner case in the documentation. - if (this_dsp_rate == B200_DEFAULT_RATE) { + // If this_dsp_rate == 0.0, the sampling rate for this DSP hasn't been set, so + // we don't take that into consideration. + if (this_dsp_rate == 0.0) { continue; } lcm_rate = boost::math::lcm( @@ -130,11 +123,11 @@ void b200_impl::set_auto_tick_rate( } } if (lcm_rate == 1) { - lcm_rate = static_cast(B200_DEFAULT_RATE); + // In this case, no one has ever set a sampling rate. + return; } - // Step 2: Determine whether if we can use lcm_rate (preferred), - // or have to give up because too large: + // Step 2: Check if the lcm_rate is within available limits: double base_rate = static_cast(lcm_rate); if (uhd::math::fp_compare::fp_compare_delta(base_rate, uhd::math::FREQ_COMPARISON_DELTA_HZ) > uhd::math::fp_compare::fp_compare_delta(max_tick_rate, uhd::math::FREQ_COMPARISON_DELTA_HZ)) { @@ -152,6 +145,7 @@ void b200_impl::set_auto_tick_rate( // An equation that does all that is: // // f_auto = r * 2^floor(log2(f_max/r)) + // = base_rate * multiplier // // where r is the base rate and f_max is the maximum tick rate. The case // where floor() yields 1 must be caught. @@ -173,7 +167,7 @@ void b200_impl::set_auto_tick_rate( uhd::math::fp_compare::fp_compare_delta(max_tick_rate, uhd::math::FREQ_COMPARISON_DELTA_HZ) ); - if (_tree->access("/mboards/0/tick_rate").get() != new_rate) { + if (!uhd::math::frequencies_are_equal(_tree->access("/mboards/0/tick_rate").get(), new_rate)) { _tree->access("/mboards/0/tick_rate").set(new_rate); } } -- cgit v1.2.3