diff --git a/libraries/AP_HAL_QURT/Scheduler.cpp b/libraries/AP_HAL_QURT/Scheduler.cpp index 18870873e5..3d98231f91 100644 --- a/libraries/AP_HAL_QURT/Scheduler.cpp +++ b/libraries/AP_HAL_QURT/Scheduler.cpp @@ -70,7 +70,7 @@ void Scheduler::delay_microseconds(uint16_t usec) void Scheduler::delay(uint16_t ms) { - if (in_timerprocess()) { + if (!in_main_thread()) { ::printf("ERROR: delay() from timer process\n"); return; } @@ -266,6 +266,11 @@ bool Scheduler::in_timerprocess() return getpid() != _main_task_pid; } +bool Scheduler::in_main_thread() +{ + return getpid() == _main_task_pid; +} + void Scheduler::system_initialized() { if (_initialized) { AP_HAL::panic("PANIC: scheduler::system_initialized called" diff --git a/libraries/AP_HAL_QURT/Scheduler.h b/libraries/AP_HAL_QURT/Scheduler.h index bbe5fbd8ee..1bfced3071 100644 --- a/libraries/AP_HAL_QURT/Scheduler.h +++ b/libraries/AP_HAL_QURT/Scheduler.h @@ -31,6 +31,7 @@ public: void resume_timer_procs(); void reboot(bool hold_in_bootloader); + bool in_main_thread(); bool in_timerprocess(); void system_initialized(); void hal_initialized();