mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 13:41:35 +08:00
QuRT: src/platform/qurt changes
Changes to support QuRT intrgration with DSPAL and move from simulator to real HW. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include <px4_tasks.h>
|
||||
#include <px4_time.h>
|
||||
#include <px4_posix.h>
|
||||
#include <px4_defines.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
@@ -50,6 +51,7 @@ using namespace std;
|
||||
|
||||
extern void init_app_map(map<string,px4_main_t> &apps);
|
||||
extern void list_builtins(map<string,px4_main_t> &apps);
|
||||
static px4_task_t g_dspal_task = -1;
|
||||
|
||||
__BEGIN_DECLS
|
||||
// The commands to run are specified in a target file: commands_<target>.c
|
||||
@@ -65,14 +67,16 @@ static void run_cmd(map<string,px4_main_t> &apps, const vector<string> &appargs)
|
||||
unsigned int i = 0;
|
||||
while (i < appargs.size() && appargs[i].c_str()[0] != '\0') {
|
||||
arg[i] = (char *)appargs[i].c_str();
|
||||
//printf(" arg = '%s'\n", arg[i]);
|
||||
PX4_WARN(" arg = '%s'\n", arg[i]);
|
||||
++i;
|
||||
}
|
||||
arg[i] = (char *)0;
|
||||
//PX4_DEBUG_PRINTF(i);
|
||||
apps[command](i,(char **)arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
PX4_WARN("NOT FOUND.");
|
||||
list_builtins(apps);
|
||||
}
|
||||
}
|
||||
@@ -91,10 +95,16 @@ static void process_commands(map<string,px4_main_t> &apps, const char *cmds)
|
||||
int i=0;
|
||||
const char *b = cmds;
|
||||
bool found_first_char = false;
|
||||
char arg[20];
|
||||
char arg[256];
|
||||
|
||||
// This is added because it is a parameter used by commander, yet created by mavlink. Since mavlink is not
|
||||
// running on QURT, we need to manually define it so it is available to commander. "2" is for quadrotor.
|
||||
|
||||
PARAM_DEFINE_INT32(MAV_TYPE,2);
|
||||
|
||||
// Eat leading whitespace
|
||||
eat_whitespace(b, i);
|
||||
|
||||
|
||||
for(;;) {
|
||||
// End of command line
|
||||
@@ -105,7 +115,10 @@ static void process_commands(map<string,px4_main_t> &apps, const char *cmds)
|
||||
|
||||
// If we have a command to run
|
||||
if (appargs.size() > 0) {
|
||||
run_cmd(apps, appargs);
|
||||
PX4_WARN("Processing command: %s",appargs[0].c_str());
|
||||
for(int ai=1;ai<(int)appargs.size();ai++)
|
||||
PX4_WARN(" > arg: %s",appargs[ai].c_str());
|
||||
run_cmd(apps, appargs);
|
||||
}
|
||||
appargs.clear();
|
||||
if (b[i] == '\n') {
|
||||
@@ -133,17 +146,63 @@ extern void init_once(void);
|
||||
};
|
||||
|
||||
__BEGIN_DECLS
|
||||
void dspal_entry()
|
||||
{
|
||||
const char *argv[2] = { "dspal_client", NULL };
|
||||
int argc = 1;
|
||||
extern int dspal_main(int argc, char *argv[]);
|
||||
__END_DECLS
|
||||
|
||||
printf("In main\n");
|
||||
|
||||
int dspal_entry( int argc, char* argv[] )
|
||||
{
|
||||
//const char *argv[2] = { "dspal_client", NULL };
|
||||
//int argc = 1;
|
||||
|
||||
PX4_INFO("In main\n");
|
||||
map<string,px4_main_t> apps;
|
||||
init_app_map(apps);
|
||||
px4::init_once();
|
||||
px4::init(argc, (char **)argv, "mainapp");
|
||||
process_commands(apps, get_commands());
|
||||
for (;;) { sleep(100000); }
|
||||
for( ;; )
|
||||
{
|
||||
volatile int x = 0;
|
||||
++x;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void usage()
|
||||
{
|
||||
PX4_WARN("Usage: dspal {start |stop}");
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
int dspal_main(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
if (argc == 2 && strcmp(argv[1], "start") == 0) {
|
||||
g_dspal_task = px4_task_spawn_cmd("dspal",
|
||||
SCHED_DEFAULT,
|
||||
SCHED_PRIORITY_MAX - 5,
|
||||
1500,
|
||||
dspal_entry,
|
||||
argv);
|
||||
|
||||
}
|
||||
else if (argc == 2 && strcmp(argv[1], "stop") == 0) {
|
||||
if (g_dspal_task < 0) {
|
||||
PX4_WARN("start up thread not running");
|
||||
}
|
||||
else {
|
||||
px4_task_delete(g_dspal_task);
|
||||
g_dspal_task = -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
__END_DECLS
|
||||
|
||||
Reference in New Issue
Block a user