diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-05-09 16:56:35 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-05-14 17:24:19 -0700 |
commit | 38a7fa64f464084fa11708bdbe00cfabc311df29 (patch) | |
tree | d8fa3985a87d237715496ae1f800c76dbf189f6f /host | |
parent | 5df5177d49b999ccab30199f9becfa84c1bef52e (diff) | |
download | uhd-38a7fa64f464084fa11708bdbe00cfabc311df29.tar.gz uhd-38a7fa64f464084fa11708bdbe00cfabc311df29.tar.bz2 uhd-38a7fa64f464084fa11708bdbe00cfabc311df29.zip |
lib: Remove some unnecessary use of boost::posix_time
Replace by std::chrono.
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/usrp/b200/b200_impl.cpp | 18 | ||||
-rw-r--r-- | host/lib/usrp/common/ad9361_driver/ad9361_device.cpp | 12 | ||||
-rw-r--r-- | host/lib/usrp/multi_usrp.cpp | 12 |
3 files changed, 24 insertions, 18 deletions
diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index 56b05a9ae..dac54bb05 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -26,6 +26,7 @@ #include <cstdio> #include <ctime> #include <cmath> +#include <chrono> #include "../../transport/libusb1_base.hpp" @@ -34,7 +35,9 @@ using namespace uhd::usrp; using namespace uhd::usrp::gpio_atr; using namespace uhd::transport; -static const boost::posix_time::milliseconds REENUMERATION_TIMEOUT_MS(3000); +namespace { + constexpr int64_t REENUMERATION_TIMEOUT_MS = 3000; +} // B200 + B210: class b200_ad9361_client_t : public ad9361_params { @@ -197,13 +200,14 @@ static device_addrs_t b200_find(const device_addr_t &hint) found++; } - const boost::system_time timeout_time = boost::get_system_time() + REENUMERATION_TIMEOUT_MS; - + const auto timeout_time = + std::chrono::steady_clock::now() + + std::chrono::milliseconds(REENUMERATION_TIMEOUT_MS); //search for the device until found or timeout - while (boost::get_system_time() < timeout_time and b200_addrs.empty() and found != 0) - { - for(usb_device_handle::sptr handle: get_b200_device_handles(hint)) - { + while (std::chrono::steady_clock::now() < timeout_time + and b200_addrs.empty() + and found != 0) { + for(usb_device_handle::sptr handle: get_b200_device_handles(hint)) { usb_control::sptr control; try{control = usb_control::make(handle, 0);} catch(const uhd::exception &){continue;} //ignore claimed diff --git a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp index 54f15d1a8..56df8bd12 100644 --- a/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp +++ b/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp @@ -2188,15 +2188,15 @@ double ad9361_device_t::_get_temperature(const double cal_offset, const double t _io_iface->poke8(0x00B, 0); //set offset to 0 _io_iface->poke8(0x00C, 0x01); //start reading, clears bit 0x00C[1] - boost::posix_time::ptime start_time = boost::posix_time::microsec_clock::local_time(); - boost::posix_time::time_duration elapsed; + auto end_time = + std::chrono::steady_clock::now() + + std::chrono::milliseconds(int64_t(timeout * 1000)); //wait for valid data (toggle of bit 1 in 0x00C) while(((_io_iface->peek8(0x00C) >> 1) & 0x01) == 0) { std::this_thread::sleep_for(std::chrono::microseconds(100)); - elapsed = boost::posix_time::microsec_clock::local_time() - start_time; - if(elapsed.total_milliseconds() > (timeout*1000)) - { - throw uhd::runtime_error("[ad9361_device_t] timeout while reading temperature"); + if (std::chrono::steady_clock::now() > end_time) { + throw uhd::runtime_error( + "[ad9361_device_t] timeout while reading temperature"); } } _io_iface->poke8(0x00C, 0x00); //clear read flag diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 2a3e2e80f..b408e44e4 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -612,13 +612,14 @@ public: } void set_time_unknown_pps(const time_spec_t &time_spec){ - UHD_LOGGER_INFO("MULTI_USRP") << " 1) catch time transition at pps edge"; - boost::system_time end_time = boost::get_system_time() + boost::posix_time::milliseconds(1100); + UHD_LOGGER_INFO("MULTI_USRP") + << " 1) catch time transition at pps edge"; + auto end_time = std::chrono::steady_clock::now() + + std::chrono::milliseconds(1100); time_spec_t time_start_last_pps = get_time_last_pps(); while (time_start_last_pps == get_time_last_pps()) { - if (boost::get_system_time() > end_time) - { + if (std::chrono::steady_clock::now() > end_time) { throw uhd::runtime_error( "Board 0 may not be getting a PPS signal!\n" "No PPS detected within the time interval.\n" @@ -628,7 +629,8 @@ public: std::this_thread::sleep_for(std::chrono::milliseconds(1)); } - UHD_LOGGER_INFO("MULTI_USRP") << " 2) set times next pps (synchronously)"; + UHD_LOGGER_INFO("MULTI_USRP") + << " 2) set times next pps (synchronously)"; set_time_next_pps(time_spec, ALL_MBOARDS); std::this_thread::sleep_for(std::chrono::seconds(1)); |