mirror of
https://github.com/saymrwulf/uhd.git
synced 2026-05-16 21:10:10 +00:00
lib: Fix time-cast for dboard_iface::sleep()
The previous cast would take the number of nanoseconds, cast them to an integer, and then add that to the previous command time. Now, we cast the nanoseconds duration to a number of seconds, represented as a double, first.
This commit is contained in:
parent
9ddbe93fcb
commit
a5ee66ade9
1 changed files with 4 additions and 1 deletions
|
|
@ -19,7 +19,10 @@ void dboard_iface::sleep(const std::chrono::nanoseconds& time)
|
|||
// 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()));
|
||||
// Cast to double-represented duration so that time_spec_t() ctor knows
|
||||
// which overloaded ctor to choose
|
||||
const std::chrono::duration<double> time_s = time;
|
||||
set_command_time(cmd_time + uhd::time_spec_t(time_s.count()));
|
||||
} else {
|
||||
// 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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue