You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
2.5 KiB
122 lines
2.5 KiB
9 years ago
|
/* definitions of builtin command list - automatically generated, do not edit */
|
||
7 years ago
|
#include "px4_time.h"
|
||
9 years ago
|
#include "px4_posix.h"
|
||
|
#include "px4_log.h"
|
||
|
|
||
|
#include "apps.h"
|
||
|
|
||
8 years ago
|
#include <cstdio>
|
||
9 years ago
|
#include <map>
|
||
|
#include <string>
|
||
|
|
||
|
#include <cstdlib>
|
||
|
|
||
7 years ago
|
#define MODULE_NAME "px4"
|
||
|
|
||
8 years ago
|
extern "C" {
|
||
|
|
||
|
${builtin_apps_decl_string}
|
||
|
int shutdown_main(int argc, char *argv[]);
|
||
|
int list_tasks_main(int argc, char *argv[]);
|
||
|
int list_files_main(int argc, char *argv[]);
|
||
|
int list_devices_main(int argc, char *argv[]);
|
||
|
int list_topics_main(int argc, char *argv[]);
|
||
|
int sleep_main(int argc, char *argv[]);
|
||
8 years ago
|
int wait_for_topic(int argc, char *argv[]);
|
||
8 years ago
|
|
||
|
}
|
||
|
|
||
9 years ago
|
extern void px4_show_devices(void);
|
||
|
|
||
|
void init_app_map(apps_map_type &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;
|
||
8 years ago
|
apps["wait_for_topic"] = wait_for_topic;
|
||
9 years ago
|
}
|
||
|
|
||
|
void list_builtins(apps_map_type &apps)
|
||
|
{
|
||
8 years ago
|
printf("Builtin Commands:\n");
|
||
8 years ago
|
for (apps_map_type::iterator it = apps.begin(); it != apps.end(); ++it) {
|
||
8 years ago
|
printf(" %s\n", it->first.c_str());
|
||
8 years ago
|
}
|
||
9 years ago
|
}
|
||
|
|
||
|
int shutdown_main(int argc, char *argv[])
|
||
|
{
|
||
8 years ago
|
printf("Shutting down\n");
|
||
7 years ago
|
system_exit(0);
|
||
9 years ago
|
}
|
||
|
|
||
|
int list_tasks_main(int argc, char *argv[])
|
||
|
{
|
||
|
px4_show_tasks();
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int list_devices_main(int argc, char *argv[])
|
||
|
{
|
||
|
px4_show_devices();
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int list_topics_main(int argc, char *argv[])
|
||
|
{
|
||
|
px4_show_topics();
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int list_files_main(int argc, char *argv[])
|
||
|
{
|
||
|
px4_show_files();
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int sleep_main(int argc, char *argv[])
|
||
|
{
|
||
|
if (argc != 2) {
|
||
|
PX4_WARN( "Usage: sleep <seconds>" );
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
unsigned long usecs = 1000000UL * atol(argv[1]);
|
||
8 years ago
|
printf("Sleeping for %s s; (%lu us).\n", argv[1], usecs);
|
||
7 years ago
|
px4_usleep(usecs);
|
||
9 years ago
|
return 0;
|
||
|
}
|
||
8 years ago
|
|
||
|
#include "uORB/uORB.h"
|
||
|
|
||
8 years ago
|
int wait_for_topic(int argc, char *argv[])
|
||
8 years ago
|
{
|
||
|
if (argc < 2 || argc > 3) {
|
||
8 years ago
|
printf("Usage: wait_for_topic <topic> [timeout_sec]\n");
|
||
8 years ago
|
return 1;
|
||
|
}
|
||
|
|
||
|
struct orb_metadata meta = { .o_name = argv[1],
|
||
|
.o_size = 0,
|
||
|
.o_size_no_padding = 0,
|
||
|
.o_fields = nullptr };
|
||
|
|
||
|
unsigned int timeout = (argc == 3) ? (unsigned int)atoi(argv[2]) : 0;
|
||
|
unsigned int elapsed = 0;
|
||
|
|
||
8 years ago
|
printf("Waiting for topic %s timeout %u\n", argv[1], timeout);
|
||
8 years ago
|
|
||
|
while (orb_exists(&meta, 0) != 0 && (timeout && (elapsed < timeout)))
|
||
|
{
|
||
7 years ago
|
px4_sleep(1);
|
||
8 years ago
|
elapsed += 1;
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|