SITL: usleep only on AP_HAL_SITL

This commit is contained in:
Peter Barker 2021-11-01 18:18:52 +11:00 committed by Peter Barker
parent b360521d0b
commit edef2ceb56

View File

@ -40,6 +40,8 @@
using namespace SITL;
extern const AP_HAL::HAL& hal;
/*
parent class for all simulator types
*/
@ -281,7 +283,13 @@ void Aircraft::sync_frame_time(void)
}
if (sleep_debt_us > min_sleep_time) {
// sleep if we have built up a debt of min_sleep_tim
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
usleep(sleep_debt_us);
#elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
hal.scheduler->delay_microseconds(sleep_debt_us);
#else
// ??
#endif
sleep_debt_us -= (get_wall_time_us() - now);
}
last_wall_time_us = get_wall_time_us();