diff options
author | Michael West <michael.west@ettus.com> | 2021-01-20 12:51:27 -0800 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-02-04 13:48:46 -0600 |
commit | c5d7e88a9ec0c2c720993977a67cfb6263ec8d20 (patch) | |
tree | 8740f61b95bb0802f43a24e8c770e92aebd6e767 /host/lib/usrp | |
parent | 6a5807ecab1c8580b2b187da441017735189fd53 (diff) | |
download | uhd-c5d7e88a9ec0c2c720993977a67cfb6263ec8d20.tar.gz uhd-c5d7e88a9ec0c2c720993977a67cfb6263ec8d20.tar.bz2 uhd-c5d7e88a9ec0c2c720993977a67cfb6263ec8d20.zip |
dboard_iface: Modify sleep() function
The algorithm for the sleep() function is changed to first increment the
command time if the command time is set. If the command time is not
set, it just performs a sleep on the host. The intention is to make a
best effort to create the requested delay on the device.
Signed-off-by: Michael West <michael.west@ettus.com>
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/dboard_iface.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/host/lib/usrp/dboard_iface.cpp b/host/lib/usrp/dboard_iface.cpp index b2ff23ab9..4a3836151 100644 --- a/host/lib/usrp/dboard_iface.cpp +++ b/host/lib/usrp/dboard_iface.cpp @@ -13,11 +13,20 @@ using namespace uhd::usrp; void dboard_iface::sleep(const boost::chrono::nanoseconds& time) { - // nanosleep is not really accurate in userland and it is also not very - // cross-platform. So just sleep for the minimum amount of time in us. - if (time < boost::chrono::microseconds(1)) { - std::this_thread::sleep_for(std::chrono::microseconds(1)); + // This sleep function is intended to create a delay on the + // device. If a command time is set, just increment that time. + // If not, the best we can do is just do a sleep on the host. + // FIXME: Create a delay in the FPGA on the device. + auto cmd_time = get_command_time(); + if (cmd_time.get_real_secs() != 0.0) { + set_command_time(cmd_time + uhd::time_spec_t(time.count())); } else { - std::this_thread::sleep_for(std::chrono::microseconds(time.count())); + // nanosleep is not really accurate in userland and it is also not very + // cross-platform. So just sleep for the minimum amount of time in us. + if (time < boost::chrono::microseconds(1)) { + std::this_thread::sleep_for(std::chrono::microseconds(1)); + } else { + std::this_thread::sleep_for(std::chrono::microseconds(time.count())); + } } } |