diff options
author | Martin Braun <martin.braun@ettus.com> | 2015-04-14 15:04:30 -0500 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2015-04-24 19:25:44 -0700 |
commit | 47ddba6fcc0c14ddac961dfe73ce5c3aa15dbba4 (patch) | |
tree | 2ef499aac96857c6b91cab8d82127dc7f711405f /host | |
parent | 04256ee8c38478a48d5969dc63faff10361962f5 (diff) | |
download | uhd-47ddba6fcc0c14ddac961dfe73ce5c3aa15dbba4.tar.gz uhd-47ddba6fcc0c14ddac961dfe73ce5c3aa15dbba4.tar.bz2 uhd-47ddba6fcc0c14ddac961dfe73ce5c3aa15dbba4.zip |
b200: Throw error for unreachable sampling rates
When auto tick rate is used, and the sampling rate exceeds the
limits, throw an error instead of coercing to the default rate.
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/usrp/b200/b200_io_impl.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp index eb7bbe048..52a90a623 100644 --- a/host/lib/usrp/b200/b200_io_impl.cpp +++ b/host/lib/usrp/b200/b200_io_impl.cpp @@ -81,6 +81,7 @@ void b200_impl::set_auto_tick_rate( if (num_chans == 0) { // Divine them num_chans = std::max(size_t(1), max_chan_count()); } + const double max_tick_rate = ad9361_device_t::AD9361_MAX_CLOCK_RATE/num_chans; // See also the doxygen documentation for these steps in b200_impl.hpp // Step 1: Obtain LCM and max rate from all relevant dsps @@ -94,6 +95,13 @@ void b200_impl::set_auto_tick_rate( continue; } double this_dsp_rate = _tree->access<double>(dsp_path / "rate/value").get(); + // Check if the user selected something completely unreasonable: + if (this_dsp_rate > max_tick_rate) { + throw uhd::value_error(str( + boost::format("Requested sampling rate (%.2f Msps) exceeds maximum tick rate of %.2f MHz.") + % (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). @@ -118,7 +126,6 @@ void b200_impl::set_auto_tick_rate( // Step 2: Determine whether if we can use lcm_rate (preferred), // or have to give up because too large: - const double max_tick_rate = ad9361_device_t::AD9361_MAX_CLOCK_RATE/num_chans; double base_rate = static_cast<double>(lcm_rate); if (base_rate > max_tick_rate) { UHD_MSG(warning) @@ -175,10 +182,19 @@ void b200_impl::update_tick_rate(const double new_tick_rate) } } +#define CHECK_RATE_AND_THROW(rate) \ + if (rate >ad9361_device_t::AD9361_MAX_CLOCK_RATE ) { \ + throw uhd::value_error(str( \ + boost::format("Requested sampling rate (%.2f Msps) exceeds maximum tick rate.") \ + % (rate / 1e6) \ + )); \ + } + double b200_impl::coerce_rx_samp_rate(rx_dsp_core_3000::sptr ddc, size_t dspno, const double rx_rate) { // Have to set tick rate first, or the ddc will change the requested rate based on default tick rate if (_tree->access<bool>("/mboards/0/auto_tick_rate").get()) { + CHECK_RATE_AND_THROW(rx_rate); const std::string dsp_path = (boost::format("/mboards/0/rx_dsps/%s") % dspno).str(); set_auto_tick_rate(rx_rate, dsp_path); } @@ -208,6 +224,7 @@ double b200_impl::coerce_tx_samp_rate(tx_dsp_core_3000::sptr duc, size_t dspno, { // Have to set tick rate first, or the duc will change the requested rate based on default tick rate if (_tree->access<bool>("/mboards/0/auto_tick_rate").get()) { + CHECK_RATE_AND_THROW(tx_rate); const std::string dsp_path = (boost::format("/mboards/0/tx_dsps/%s") % dspno).str(); set_auto_tick_rate(tx_rate, dsp_path); } |