2016-10-21 10:54:48 -03:00
|
|
|
/* definitions of builtin command list - automatically generated, do not edit */
|
|
|
|
#include "px4_posix.h"
|
|
|
|
#include "px4_log.h"
|
|
|
|
|
|
|
|
#include "apps.h"
|
|
|
|
|
2016-10-28 21:22:04 -03:00
|
|
|
#include <cstdio>
|
2016-10-21 10:54:48 -03:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
2016-10-27 14:20:07 -03:00
|
|
|
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[]);
|
2017-01-05 17:11:31 -04:00
|
|
|
int wait_for_topic(int argc, char *argv[]);
|
2016-10-27 14:20:07 -03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-10-21 10:54:48 -03:00
|
|
|
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;
|
2017-01-05 17:11:31 -04:00
|
|
|
apps["wait_for_topic"] = wait_for_topic;
|
2016-10-21 10:54:48 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
void list_builtins(apps_map_type &apps)
|
|
|
|
{
|
2017-01-30 06:26:09 -04:00
|
|
|
printf("Builtin Commands:\n");
|
2017-01-14 16:23:21 -04:00
|
|
|
for (apps_map_type::iterator it = apps.begin(); it != apps.end(); ++it) {
|
2017-01-30 06:26:09 -04:00
|
|
|
printf(" %s\n", it->first.c_str());
|
2017-01-14 16:23:21 -04:00
|
|
|
}
|
2016-10-21 10:54:48 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
int shutdown_main(int argc, char *argv[])
|
|
|
|
{
|
2016-10-28 21:22:04 -03:00
|
|
|
printf("Shutting down\n");
|
2016-10-21 10:54:48 -03:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
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]);
|
2016-10-28 21:22:04 -03:00
|
|
|
printf("Sleeping for %s s; (%lu us).\n", argv[1], usecs);
|
2016-10-21 10:54:48 -03:00
|
|
|
usleep(usecs);
|
|
|
|
return 0;
|
|
|
|
}
|
2017-01-05 17:11:31 -04:00
|
|
|
|
|
|
|
#include "uORB/uORB.h"
|
|
|
|
|
2017-01-05 17:24:31 -04:00
|
|
|
int wait_for_topic(int argc, char *argv[])
|
2017-01-05 17:11:31 -04:00
|
|
|
{
|
|
|
|
if (argc < 2 || argc > 3) {
|
2017-01-09 16:02:30 -04:00
|
|
|
printf("Usage: wait_for_topic <topic> [timeout_sec]\n");
|
2017-01-05 17:11:31 -04:00
|
|
|
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;
|
|
|
|
|
2017-01-09 16:02:30 -04:00
|
|
|
printf("Waiting for topic %s timeout %u\n", argv[1], timeout);
|
2017-01-05 17:11:31 -04:00
|
|
|
|
|
|
|
while (orb_exists(&meta, 0) != 0 && (timeout && (elapsed < timeout)))
|
|
|
|
{
|
|
|
|
sleep(1);
|
|
|
|
elapsed += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|