forked from Archive/PX4-Autopilot
Land detector main: Fix style
This commit is contained in:
parent
75132a50e6
commit
35efe651ac
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2013-2015 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2013-2017 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -36,6 +36,7 @@
|
|||
* Land detection algorithm
|
||||
*
|
||||
* @author Johan Jansen <jnsn.johan@gmail.com>
|
||||
* @author Lorenz Meier <lorenz@px4.io>
|
||||
*/
|
||||
|
||||
#include <px4_config.h>
|
||||
|
@ -59,7 +60,7 @@
|
|||
namespace land_detector
|
||||
{
|
||||
|
||||
//Function prototypes
|
||||
// Function prototypes
|
||||
static int land_detector_start(const char *mode);
|
||||
static void land_detector_stop();
|
||||
|
||||
|
@ -70,13 +71,13 @@ static void land_detector_stop();
|
|||
*/
|
||||
extern "C" __EXPORT int land_detector_main(int argc, char *argv[]);
|
||||
|
||||
//Private variables
|
||||
// Private variables
|
||||
static LandDetector *land_detector_task = nullptr;
|
||||
static char _currentMode[12];
|
||||
|
||||
/**
|
||||
* Stop the task, force killing it if it doesn't stop by itself
|
||||
**/
|
||||
* Stop the task, force killing it if it doesn't stop by itself
|
||||
*/
|
||||
static void land_detector_stop()
|
||||
{
|
||||
if (land_detector_task == nullptr) {
|
||||
|
@ -90,7 +91,7 @@ static void land_detector_stop()
|
|||
int i = 0;
|
||||
|
||||
do {
|
||||
/* wait 20ms */
|
||||
// wait 20ms at a time
|
||||
usleep(20000);
|
||||
|
||||
} while (land_detector_task->is_running() && ++i < 50);
|
||||
|
@ -102,8 +103,8 @@ static void land_detector_stop()
|
|||
}
|
||||
|
||||
/**
|
||||
* Start new task, fails if it is already running. Returns OK if successful
|
||||
**/
|
||||
* Start new task, fails if it is already running. Returns OK if successful
|
||||
*/
|
||||
static int land_detector_start(const char *mode)
|
||||
{
|
||||
if (land_detector_task != nullptr) {
|
||||
|
@ -126,13 +127,13 @@ static int land_detector_start(const char *mode)
|
|||
return -1;
|
||||
}
|
||||
|
||||
//Check if alloc worked
|
||||
// Check if alloc worked
|
||||
if (land_detector_task == nullptr) {
|
||||
PX4_WARN("alloc failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Start new thread task
|
||||
// Start new thread task
|
||||
int ret = land_detector_task->start();
|
||||
|
||||
if (ret) {
|
||||
|
@ -140,13 +141,12 @@ static int land_detector_start(const char *mode)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* avoid memory fragmentation by not exiting start handler until the task has fully started */
|
||||
const uint64_t timeout = hrt_absolute_time() + 5000000; //5 second timeout
|
||||
// Avoid memory fragmentation by not exiting start handler until the task has fully started
|
||||
const uint64_t timeout = hrt_absolute_time() + 5000000; // 5 second timeout
|
||||
|
||||
/* avoid printing dots just yet and do one sleep before the first check */
|
||||
// Do one sleep before the first check
|
||||
usleep(10000);
|
||||
|
||||
/* check if the waiting involving dots and a newline are still needed */
|
||||
if (!land_detector_task->is_running()) {
|
||||
while (!land_detector_task->is_running()) {
|
||||
usleep(50000);
|
||||
|
@ -167,8 +167,8 @@ static int land_detector_start(const char *mode)
|
|||
}
|
||||
|
||||
/**
|
||||
* Main entry point for this module
|
||||
**/
|
||||
* Main entry point for this module
|
||||
*/
|
||||
int land_detector_main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in New Issue