From a5ee66ade97fe4bea9c2149fd8a5461d82f19c82 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 11 Jul 2023 12:35:45 +0200 Subject: [PATCH] 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. --- host/lib/usrp/dboard_iface.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/host/lib/usrp/dboard_iface.cpp b/host/lib/usrp/dboard_iface.cpp index 9445e6abf..d23e469f9 100644 --- a/host/lib/usrp/dboard_iface.cpp +++ b/host/lib/usrp/dboard_iface.cpp @@ -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 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.