From 9b7170551c2b2b23ae3bc587c365ecbef8160a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Fri, 2 Jul 2021 11:28:09 +0200 Subject: [PATCH] ModuleBase: allow configurable timeout for wait_until_running() --- platforms/common/include/px4_platform_common/module.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platforms/common/include/px4_platform_common/module.h b/platforms/common/include/px4_platform_common/module.h index 1304c9241a..63867df4e2 100644 --- a/platforms/common/include/px4_platform_common/module.h +++ b/platforms/common/include/px4_platform_common/module.h @@ -362,17 +362,16 @@ protected: * @brief Waits until _object is initialized, (from the new thread). This can be called from task_spawn(). * @return Returns 0 iff successful, -1 on timeout or otherwise. */ - static int wait_until_running() + static int wait_until_running(int timeout_ms = 1000) { int i = 0; do { - /* Wait up to 1s. */ - px4_usleep(2500); + px4_usleep(2000); - } while (!_object.load() && ++i < 400); + } while (!_object.load() && ++i < timeout_ms / 2); - if (i == 400) { + if (i >= timeout_ms / 2) { PX4_ERR("Timed out while waiting for thread to start"); return -1; }