Browse Source

SITL: use AP_HAL::micros() for get_wall_time_us

apm_2208
Peter Barker 3 years ago committed by Peter Barker
parent
commit
0957131543
  1. 5
      libraries/SITL/SIM_Aircraft.cpp
  2. 2
      libraries/SITL/SIM_GPS.cpp

5
libraries/SITL/SIM_Aircraft.cpp

@ -536,6 +536,7 @@ float Aircraft::rangefinder_range() const @@ -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 @@ -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
}

2
libraries/SITL/SIM_GPS.cpp

@ -10,6 +10,8 @@ @@ -10,6 +10,8 @@
#if HAL_SIM_GPS_ENABLED
#include <time.h>
#include <AP_BoardConfig/AP_BoardConfig.h>
#include <AP_HAL/AP_HAL.h>
#include <SITL/SITL.h>

Loading…
Cancel
Save