px4-firmware/cmake/qurt/apps.h_in

85 lines
1.9 KiB
Plaintext

/* builtin command list - automatically generated, do not edit */
#include <string>
#include <map>
#include <stdio.h>
#include <px4_tasks.h>
#include <px4_posix.h>
#include <px4_log.h>
#include <stdlib.h>
using namespace std;
extern void px4_show_devices(void);
extern "C" {
${builtin_apps_decl_string}
static int shutdown_main(int argc, char *argv[]);
static int list_tasks_main(int argc, char *argv[]);
static int list_files_main(int argc, char *argv[]);
static int list_devices_main(int argc, char *argv[]);
static int list_topics_main(int argc, char *argv[]);
static int sleep_main(int argc, char *argv[]);
}
void init_app_map(map<string,px4_main_t> &apps)
{
${builtin_apps_string}
apps["shutdown"] = shutdown_main;
apps["list_tasks"] = list_tasks_main;
apps["list_files"] = list_files_main;
apps["list_devices"] = list_devices_main;
apps["list_topics"] = list_topics_main;
apps["sleep"] = sleep_main;
}
void list_builtins(map<string,px4_main_t> &apps)
{
printf("Builtin Commands:\\n");
for (map<string,px4_main_t>::iterator it=apps.begin(); it!=apps.end(); ++it)
printf("\\t%s\\n", (it->first).c_str());
}
static int shutdown_main(int argc, char *argv[])
{
printf("Shutting down\\n");
exit(0);
}
static int list_tasks_main(int argc, char *argv[])
{
px4_show_tasks();
return 0;
}
static int list_devices_main(int argc, char *argv[])
{
px4_show_devices();
return 0;
}
static int list_topics_main(int argc, char *argv[])
{
px4_show_topics();
return 0;
}
static int list_files_main(int argc, char *argv[])
{
px4_show_files();
return 0;
}
static int sleep_main(int argc, char *argv[])
{
if (argc != 2) {
PX4_WARN( "Usage: sleep <seconds>" );
return 1;
}
unsigned long usecs = ( (unsigned long) atol( argv[1] ) ) * 1000 * 1000;
PX4_WARN("Sleeping for %s, %ld",argv[1],usecs);
usleep( usecs );
return 0;
}