From 09571315435a227b39b3658033eeaa185a3c908e Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 11 Oct 2021 16:08:40 +1100 Subject: [PATCH] SITL: use AP_HAL::micros() for get_wall_time_us --- libraries/SITL/SIM_Aircraft.cpp | 5 ++++- libraries/SITL/SIM_GPS.cpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/SITL/SIM_Aircraft.cpp b/libraries/SITL/SIM_Aircraft.cpp index d99a39a14d..bcc95e8587 100644 --- a/libraries/SITL/SIM_Aircraft.cpp +++ b/libraries/SITL/SIM_Aircraft.cpp @@ -536,6 +536,7 @@ float Aircraft::rangefinder_range() const } +// potentially replace this with a call to AP_HAL::Util::get_hw_rtc uint64_t Aircraft::get_wall_time_us() const { #if defined(__CYGWIN__) || defined(__CYGWIN64__) @@ -549,10 +550,12 @@ uint64_t Aircraft::get_wall_time_us() const last_ret_us += (uint64_t)((now - tPrev)*1000UL); tPrev = now; return last_ret_us; -#else +#elif CONFIG_HAL_BOARD == HAL_BOARD_SITL struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return uint64_t(ts.tv_sec * 1000000ULL + ts.tv_nsec / 1000ULL); +#else + return AP_HAL::micros64(); #endif } diff --git a/libraries/SITL/SIM_GPS.cpp b/libraries/SITL/SIM_GPS.cpp index 4a2479e153..9790ef49ec 100644 --- a/libraries/SITL/SIM_GPS.cpp +++ b/libraries/SITL/SIM_GPS.cpp @@ -10,6 +10,8 @@ #if HAL_SIM_GPS_ENABLED +#include + #include #include #include