From 08637f1dcc8f27406e68bd5fea0b40af9fa9a666 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Wed, 2 Aug 2017 01:46:17 -0700 Subject: [PATCH] AP_HAL_VRBRAIN: Scheduler: replace use of in_timerprocess() This function actually checks if we are not in the main thread rather than if we are in the timer thread. Add a new function that does what it's supposed to do. --- libraries/AP_HAL_VRBRAIN/Scheduler.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_VRBRAIN/Scheduler.cpp b/libraries/AP_HAL_VRBRAIN/Scheduler.cpp index c86201a670..c9df6edd36 100644 --- a/libraries/AP_HAL_VRBRAIN/Scheduler.cpp +++ b/libraries/AP_HAL_VRBRAIN/Scheduler.cpp @@ -138,7 +138,7 @@ void VRBRAINScheduler::delay_microseconds_boost(uint16_t usec) void VRBRAINScheduler::delay(uint16_t ms) { - if (in_timerprocess()) { + if (!in_main_thread()) { ::printf("ERROR: delay() from timer process\n"); return; } @@ -375,6 +375,11 @@ bool VRBRAINScheduler::in_timerprocess() return getpid() != _main_task_pid; } +bool VRBRAINScheduler::in_main_thread() +{ + return getpid() == _main_task_pid; +} + void VRBRAINScheduler::system_initialized() { if (_initialized) { AP_HAL::panic("PANIC: scheduler::system_initialized called"