summaryrefslogtreecommitdiff
path: root/gr-uhd/lib/usrp_block_impl.cc
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2021-01-29 11:53:37 +0100
committerMartin Braun <martin@gnuradio.org>2021-02-05 07:48:06 -0800
commit7e43e0a149bf7889531297916dbf1482bab76e50 (patch)
treef23a471a052a3a8f3dfc65efa6c336d78073db68 /gr-uhd/lib/usrp_block_impl.cc
parent6df5b3a6e5397eb0b08dfabfcd78d96aea46f447 (diff)
uhd: Remove (almost all) occurrences of Boost
The following usages of Boost remain: - boost::format - boost::program_options for the examples - Boost thread interruption directives to interact with GNU Radio runtime Signed-off-by: Martin Braun <martin@gnuradio.org>
Diffstat (limited to 'gr-uhd/lib/usrp_block_impl.cc')
-rw-r--r--gr-uhd/lib/usrp_block_impl.cc47
1 files changed, 19 insertions, 28 deletions
diff --git a/gr-uhd/lib/usrp_block_impl.cc b/gr-uhd/lib/usrp_block_impl.cc
index 675c466d5..2b57761c8 100644
--- a/gr-uhd/lib/usrp_block_impl.cc
+++ b/gr-uhd/lib/usrp_block_impl.cc
@@ -10,10 +10,14 @@
#include "usrp_block_impl.h"
#include <chrono>
+#include <thread>
using namespace gr::uhd;
+using namespace std::chrono_literals;
-const double usrp_block_impl::LOCK_TIMEOUT = 1.5;
+namespace {
+constexpr auto LOCK_TIMEOUT = 1.5s;
+}
/**********************************************************************
* Structors
@@ -200,36 +204,23 @@ bool usrp_block_impl::_wait_for_locked_sensor(std::vector<std::string> sensor_na
get_sensor_fn_t get_sensor_fn)
{
if (std::find(sensor_names.begin(), sensor_names.end(), sensor_name) ==
- sensor_names.end())
+ sensor_names.end()) {
return true;
+ }
- boost::system_time start = boost::get_system_time();
- boost::system_time first_lock_time;
-
- while (true) {
- if ((not first_lock_time.is_not_a_date_time()) and
- (boost::get_system_time() >
- (first_lock_time +
- boost::posix_time::seconds(static_cast<long>(LOCK_TIMEOUT))))) {
- break;
- }
+ const auto start = std::chrono::steady_clock::now();
+ const auto timeout = start + LOCK_TIMEOUT;
+ while (std::chrono::steady_clock::now() < timeout) {
if (get_sensor_fn(sensor_name).to_bool()) {
- if (first_lock_time.is_not_a_date_time())
- first_lock_time = boost::get_system_time();
- } else {
- first_lock_time = boost::system_time(); // reset to 'not a date time'
-
- if (boost::get_system_time() >
- (start + boost::posix_time::seconds(static_cast<long>(LOCK_TIMEOUT)))) {
- return false;
- }
+ return true;
}
- boost::this_thread::sleep(boost::posix_time::milliseconds(100));
+ std::this_thread::sleep_for(100ms);
}
- return true;
+ // One last try:
+ return get_sensor_fn(sensor_name).to_bool();
}
bool usrp_block_impl::_unpack_chan_command(std::string& command,
@@ -387,9 +378,9 @@ std::vector<std::string> usrp_block_impl::get_gpio_banks(const size_t mboard)
#endif
}
-boost::uint32_t usrp_block_impl::get_gpio_attr(const std::string& bank,
- const std::string& attr,
- const size_t mboard)
+uint32_t usrp_block_impl::get_gpio_attr(const std::string& bank,
+ const std::string& attr,
+ const size_t mboard)
{
#ifdef UHD_USRP_MULTI_USRP_GPIO_API
return _dev->get_gpio_attr(bank, attr, mboard);
@@ -460,8 +451,8 @@ void usrp_block_impl::set_user_register(const uint8_t addr,
void usrp_block_impl::set_gpio_attr(const std::string& bank,
const std::string& attr,
- const boost::uint32_t value,
- const boost::uint32_t mask,
+ const uint32_t value,
+ const uint32_t mask,
const size_t mboard)
{
#ifdef UHD_USRP_MULTI_USRP_GPIO_API