From 11f80ceb64bc6e508a259299b20b342e54b2dc1e Mon Sep 17 00:00:00 2001 From: Ban Siesta Date: Mon, 25 May 2015 19:01:34 +0100 Subject: [PATCH] land_detector: get rid of one dot at a time --- .../land_detector/land_detector_main.cpp | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/modules/land_detector/land_detector_main.cpp b/src/modules/land_detector/land_detector_main.cpp index c3829bb70d..e0f96ec77f 100644 --- a/src/modules/land_detector/land_detector_main.cpp +++ b/src/modules/land_detector/land_detector_main.cpp @@ -151,20 +151,26 @@ static int land_detector_start(const char *mode) /* avoid memory fragmentation by not exiting start handler until the task has fully started */ const uint32_t timeout = hrt_absolute_time() + 5000000; //5 second timeout - while (!land_detector_task->isRunning()) { - usleep(50000); - printf("."); - fflush(stdout); + /* avoid printing dots just yet and do one sleep before the first check */ + usleep(10000); - if (hrt_absolute_time() > timeout) { - err(1, "start failed - timeout"); - land_detector_stop(); - exit(1); + /* check if the waiting involving dots and a newline are still needed */ + if (!land_detector_task->isRunning()) { + while (!land_detector_task->isRunning()) { + + printf("."); + fflush(stdout); + usleep(50000); + + if (hrt_absolute_time() > timeout) { + err(1, "start failed - timeout"); + land_detector_stop(); + exit(1); + } } + printf("\n"); } - printf("\n"); - //Remember current active mode strncpy(_currentMode, mode, 12);