mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
src/platforms: move remaining source files to platforms/common
This commit is contained in:
121
platforms/common/apps.cpp.in
Normal file
121
platforms/common/apps.cpp.in
Normal file
@@ -0,0 +1,121 @@
|
||||
/* definitions of builtin command list - automatically generated, do not edit */
|
||||
#include "px4_time.h"
|
||||
#include "px4_posix.h"
|
||||
#include "px4_log.h"
|
||||
|
||||
#include "apps.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#define MODULE_NAME "px4"
|
||||
|
||||
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[]);
|
||||
int wait_for_topic(int argc, char *argv[]);
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
apps["wait_for_topic"] = wait_for_topic;
|
||||
}
|
||||
|
||||
void list_builtins(apps_map_type &apps)
|
||||
{
|
||||
printf("Builtin Commands:\n");
|
||||
for (apps_map_type::iterator it = apps.begin(); it != apps.end(); ++it) {
|
||||
printf(" %s\n", it->first.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
int shutdown_main(int argc, char *argv[])
|
||||
{
|
||||
printf("Shutting down\n");
|
||||
system_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]);
|
||||
printf("Sleeping for %s s; (%lu us).\n", argv[1], usecs);
|
||||
px4_usleep(usecs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "uORB/uORB.h"
|
||||
|
||||
int wait_for_topic(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2 || argc > 3) {
|
||||
printf("Usage: wait_for_topic <topic> [timeout_sec]\n");
|
||||
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;
|
||||
|
||||
printf("Waiting for topic %s timeout %u\n", argv[1], timeout);
|
||||
|
||||
while (orb_exists(&meta, 0) != 0 && (timeout && (elapsed < timeout)))
|
||||
{
|
||||
px4_sleep(1);
|
||||
elapsed += 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
16
platforms/common/apps.h.in
Normal file
16
platforms/common/apps.h.in
Normal file
@@ -0,0 +1,16 @@
|
||||
/* declarations of builtin command list - automatically generated, do not edit */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "px4_tasks.h" // px4_main_t
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
// Maps an app name to it's function.
|
||||
typedef std::map<std::string, px4_main_t> apps_map_type;
|
||||
|
||||
// Initialize an apps map.
|
||||
__EXPORT void init_app_map(apps_map_type &apps);
|
||||
|
||||
// List an apps map.
|
||||
__EXPORT void list_builtins(apps_map_type &apps);
|
||||
3
platforms/common/empty.c
Normal file
3
platforms/common/empty.c
Normal file
@@ -0,0 +1,3 @@
|
||||
/*
|
||||
* This is an empty C source file, used when building default firmware configurations.
|
||||
*/
|
||||
Reference in New Issue
Block a user