mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
ModuleBase: allow configurable timeout for wait_until_running()
This commit is contained in:
@@ -362,17 +362,16 @@ protected:
|
|||||||
* @brief Waits until _object is initialized, (from the new thread). This can be called from task_spawn().
|
* @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.
|
* @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;
|
int i = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Wait up to 1s. */
|
px4_usleep(2000);
|
||||||
px4_usleep(2500);
|
|
||||||
|
|
||||||
} 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");
|
PX4_ERR("Timed out while waiting for thread to start");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user