diff options
author | Balint Seeber <balint@ettus.com> | 2014-02-13 15:26:54 -0800 |
---|---|---|
committer | Balint Seeber <balint@ettus.com> | 2014-02-14 15:40:30 -0800 |
commit | 383128e2c9c3539e1bc8de7d13a894f50fc9719a (patch) | |
tree | 9b2a5c5603e2c781bcae6e3edbd4d8408cae951a /host/lib/usrp/b200/b200_impl.cpp | |
parent | 7fef199d194c9a63b3312845979fa353f90f4d23 (diff) | |
download | uhd-383128e2c9c3539e1bc8de7d13a894f50fc9719a.tar.gz uhd-383128e2c9c3539e1bc8de7d13a894f50fc9719a.tar.bz2 uhd-383128e2c9c3539e1bc8de7d13a894f50fc9719a.zip |
b200: throw exception when master clock rate (tick rate) is requested to be > max for certain # of channels (i.e. restrict to 30.72MHz for MIMO)
Also includes sscanf type fix in b200_impl and longer timeout for AD9361 read
Diffstat (limited to 'host/lib/usrp/b200/b200_impl.cpp')
-rw-r--r-- | host/lib/usrp/b200/b200_impl.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index 8ed8e99af..3edd12b90 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -156,8 +156,8 @@ b200_impl::b200_impl(const device_addr_t &device_addr) const fs_path mb_path = "/mboards/0"; //try to match the given device address with something on the USB bus - uint16_t vid = B200_VENDOR_ID; - uint16_t pid = B200_PRODUCT_ID; + unsigned int vid = B200_VENDOR_ID; + unsigned int pid = B200_PRODUCT_ID; if (device_addr.has_key("vid")) sscanf(device_addr.get("vid").c_str(), "%x", &vid); if (device_addr.has_key("pid")) @@ -659,9 +659,27 @@ void b200_impl::codec_loopback_self_test(wb_iface::sptr iface) /*********************************************************************** * Sample and tick rate comprehension below **********************************************************************/ +void b200_impl::enforce_tick_rate_limits(size_t chan_count, double tick_rate, const char* direction /*= NULL*/) +{ + const size_t max_chans = 2; + if (chan_count > max_chans) + { + throw uhd::value_error(boost::str(boost::format("cannot not setup %d %s channels (maximum is %d)") % chan_count % (direction ? direction : "data") % max_chans)); + } + else + { + const double max_tick_rate = ((chan_count <= 1) ? AD9361_1_CHAN_CLOCK_RATE_MAX : AD9361_2_CHAN_CLOCK_RATE_MAX); + if (tick_rate > max_tick_rate) + throw uhd::value_error(boost::str(boost::format("current master clock rate (%.2f MHz) exceeds maximum possible master clock rate (%.2f MHz) when using %d %s channels") % (tick_rate/1e6) % (max_tick_rate/1e6) % chan_count % (direction ? direction : "data"))); + } +} + double b200_impl::set_tick_rate(const double rate) { UHD_MSG(status) << "Asking for clock rate " << rate/1e6 << " MHz\n"; + + check_tick_rate_with_current_streamers(rate); // Defined in b200_io_impl.cpp + _tick_rate = _codec_ctrl->set_clock_rate(rate); UHD_MSG(status) << "Actually got clock rate " << _tick_rate/1e6 << " MHz\n"; |