mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-29 19:57:12 +08:00
Hotfix: Fix typos in tutorial code
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
* Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved.
|
||||||
* Author: @author Example User <mail@example.com>
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -33,27 +32,32 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file px4_deamon_app.c
|
* @file px4_daemon_app.c
|
||||||
* Deamon application example for PX4 autopilot
|
* daemon application example for PX4 autopilot
|
||||||
|
*
|
||||||
|
* @author Example User <mail@example.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
#include <nuttx/sched.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static bool thread_should_exit = false; /**< Deamon exit flag */
|
#include <systemlib/err.h>
|
||||||
static bool thread_running = false; /**< Deamon status flag */
|
|
||||||
static int deamon_task; /**< Handle of deamon task / thread */
|
static bool thread_should_exit = false; /**< daemon exit flag */
|
||||||
|
static bool thread_running = false; /**< daemon status flag */
|
||||||
|
static int daemon_task; /**< Handle of daemon task / thread */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deamon management function.
|
* daemon management function.
|
||||||
*/
|
*/
|
||||||
__EXPORT int px4_deamon_app_main(int argc, char *argv[]);
|
__EXPORT int px4_daemon_app_main(int argc, char *argv[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mainloop of deamon.
|
* Mainloop of daemon.
|
||||||
*/
|
*/
|
||||||
int px4_deamon_thread_main(int argc, char *argv[]);
|
int px4_daemon_thread_main(int argc, char *argv[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print the correct usage.
|
* Print the correct usage.
|
||||||
@@ -64,20 +68,19 @@ static void
|
|||||||
usage(const char *reason)
|
usage(const char *reason)
|
||||||
{
|
{
|
||||||
if (reason)
|
if (reason)
|
||||||
fprintf(stderr, "%s\n", reason);
|
warnx("%s\n", reason);
|
||||||
fprintf(stderr, "usage: deamon {start|stop|status} [-p <additional params>]\n\n");
|
errx(1, "usage: daemon {start|stop|status} [-p <additional params>]\n\n");
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The deamon app only briefly exists to start
|
* The daemon app only briefly exists to start
|
||||||
* the background job. The stack size assigned in the
|
* the background job. The stack size assigned in the
|
||||||
* Makefile does only apply to this management task.
|
* Makefile does only apply to this management task.
|
||||||
*
|
*
|
||||||
* The actual stack size should be set in the call
|
* The actual stack size should be set in the call
|
||||||
* to task_create().
|
* to task_create().
|
||||||
*/
|
*/
|
||||||
int px4_deamon_app_main(int argc, char *argv[])
|
int px4_daemon_app_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc < 1)
|
if (argc < 1)
|
||||||
usage("missing command");
|
usage("missing command");
|
||||||
@@ -85,17 +88,17 @@ int px4_deamon_app_main(int argc, char *argv[])
|
|||||||
if (!strcmp(argv[1], "start")) {
|
if (!strcmp(argv[1], "start")) {
|
||||||
|
|
||||||
if (thread_running) {
|
if (thread_running) {
|
||||||
printf("deamon already running\n");
|
warnx("daemon already running\n");
|
||||||
/* this is not an error */
|
/* this is not an error */
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_should_exit = false;
|
thread_should_exit = false;
|
||||||
deamon_task = task_spawn("deamon",
|
daemon_task = task_spawn("daemon",
|
||||||
SCHED_DEFAULT,
|
SCHED_DEFAULT,
|
||||||
SCHED_PRIORITY_DEFAULT,
|
SCHED_PRIORITY_DEFAULT,
|
||||||
4096,
|
4096,
|
||||||
px4_deamon_thread_main,
|
px4_daemon_thread_main,
|
||||||
(argv) ? (const char **)&argv[2] : (const char **)NULL);
|
(argv) ? (const char **)&argv[2] : (const char **)NULL);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -107,9 +110,9 @@ int px4_deamon_app_main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!strcmp(argv[1], "status")) {
|
if (!strcmp(argv[1], "status")) {
|
||||||
if (thread_running) {
|
if (thread_running) {
|
||||||
printf("\tdeamon app is running\n");
|
printf("\tdaemon app is running\n");
|
||||||
} else {
|
} else {
|
||||||
printf("\tdeamon app not started\n");
|
printf("\tdaemon app not started\n");
|
||||||
}
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@@ -118,18 +121,18 @@ int px4_deamon_app_main(int argc, char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int px4_deamon_thread_main(int argc, char *argv[]) {
|
int px4_daemon_thread_main(int argc, char *argv[]) {
|
||||||
|
|
||||||
printf("[deamon] starting\n");
|
printf("[daemon] starting\n");
|
||||||
|
|
||||||
thread_running = true;
|
thread_running = true;
|
||||||
|
|
||||||
while (!thread_should_exit) {
|
while (!thread_should_exit) {
|
||||||
printf("Hello Deamon!\n");
|
printf("Hello daemon!\n");
|
||||||
sleep(10);
|
sleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[deamon] exiting.\n");
|
printf("[daemon] exiting.\n");
|
||||||
|
|
||||||
thread_running = false;
|
thread_running = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user