mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-04 00:40:35 +08:00
QuRT: toolchain changes
Reworking toolchain and main.cpp for QuRT to a final link can be done and the apps.h file is autogenerated. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -53,7 +53,7 @@ static int update_interval = 1;
|
||||
static void timer_expired(void *arg)
|
||||
{
|
||||
static int i = 0;
|
||||
printf("Test\n");
|
||||
PX4_INFO("Test\n");
|
||||
if (i < 5) {
|
||||
i++;
|
||||
hrt_call_after(&t1, update_interval, timer_expired, (void *)0);
|
||||
@@ -67,24 +67,24 @@ int HRTTest::main()
|
||||
hrt_abstime t = hrt_absolute_time();
|
||||
usleep(1000000);
|
||||
hrt_abstime elt = hrt_elapsed_time(&t);
|
||||
printf("Elapsed time %llu in 1 sec (usleep)\n", (unsigned long long)elt);
|
||||
printf("Start time %llu\n", (unsigned long long)t);
|
||||
PX4_INFO("Elapsed time %llu in 1 sec (usleep)\n", (unsigned long long)elt);
|
||||
PX4_INFO("Start time %llu\n", (unsigned long long)t);
|
||||
|
||||
t = hrt_absolute_time();
|
||||
sleep(1);
|
||||
elt = hrt_elapsed_time(&t);
|
||||
printf("Elapsed time %llu in 1 sec (sleep)\n", (unsigned long long)elt);
|
||||
printf("Start time %llu\n", (unsigned long long)t);
|
||||
PX4_INFO("Elapsed time %llu in 1 sec (sleep)\n", (unsigned long long)elt);
|
||||
PX4_INFO("Start time %llu\n", (unsigned long long)t);
|
||||
|
||||
memset(&t1, 0, sizeof(t1));
|
||||
|
||||
printf("HRT_CALL %d\n", hrt_called(&t1));
|
||||
PX4_INFO("HRT_CALL %d\n", hrt_called(&t1));
|
||||
|
||||
hrt_call_after(&t1, update_interval, timer_expired, (void *)0);
|
||||
sleep(2);
|
||||
printf("HRT_CALL - %d\n", hrt_called(&t1));
|
||||
PX4_INFO("HRT_CALL - %d\n", hrt_called(&t1));
|
||||
hrt_cancel(&t1);
|
||||
printf("HRT_CALL + %d\n", hrt_called(&t1));
|
||||
PX4_INFO("HRT_CALL + %d\n", hrt_called(&t1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -49,14 +49,14 @@ extern "C" __EXPORT int hrttest_main(int argc, char *argv[]);
|
||||
int hrttest_main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2) {
|
||||
printf("usage: hrttest_main {start|stop|status}\n");
|
||||
PX4_WARN("usage: hrttest_main {start|stop|status}\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "start")) {
|
||||
|
||||
if (HRTTest::appState.isRunning()) {
|
||||
printf("already running\n");
|
||||
PX4_INFO("already running\n");
|
||||
/* this is not an error */
|
||||
return 0;
|
||||
}
|
||||
@@ -78,15 +78,15 @@ int hrttest_main(int argc, char *argv[])
|
||||
|
||||
if (!strcmp(argv[1], "status")) {
|
||||
if (HRTTest::appState.isRunning()) {
|
||||
printf("is running\n");
|
||||
PX4_INFO("is running\n");
|
||||
|
||||
} else {
|
||||
printf("not started\n");
|
||||
PX4_INFO("not started\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("usage: hrttest_main {start|stop|status}\n");
|
||||
PX4_WARN("usage: hrttest_main {start|stop|status}\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -37,12 +37,9 @@
|
||||
* @author Mark Charlebois <charlebm@gmail.com>
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <hexagon_standalone.h>
|
||||
//#include <hexagon_standalone.h>
|
||||
|
||||
//using namespace std;
|
||||
|
||||
@@ -52,7 +49,6 @@
|
||||
#include "px4_middleware.h"
|
||||
|
||||
static const char *commands =
|
||||
"x\n"
|
||||
"hello start"
|
||||
#if 0
|
||||
"uorb start\n"
|
||||
@@ -79,15 +75,15 @@ static const char *commands =
|
||||
static void run_cmd(const vector<string> &appargs) {
|
||||
// command is appargs[0]
|
||||
string command = appargs[0];
|
||||
printf("Looking for %s\n", command.c_str());
|
||||
//printf("Looking for %s\n", command.c_str());
|
||||
if (apps.find(command) != apps.end()) {
|
||||
const char *arg[2+1];
|
||||
|
||||
unsigned int i = 0;
|
||||
printf("size = %d\n", appargs.size());
|
||||
//printf("size = %d\n", appargs.size());
|
||||
while (i < appargs.size() && appargs[i].c_str()[0] != '\0') {
|
||||
arg[i] = (char *)appargs[i].c_str();
|
||||
printf(" arg = '%s'\n", arg[i]);
|
||||
//printf(" arg = '%s'\n", arg[i]);
|
||||
++i;
|
||||
}
|
||||
arg[i] = (char *)0;
|
||||
@@ -97,7 +93,7 @@ static void run_cmd(const vector<string> &appargs) {
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Invalid command" << endl;
|
||||
//cout << "Invalid command" << endl;
|
||||
list_builtins();
|
||||
}
|
||||
}
|
||||
@@ -159,8 +155,10 @@ extern void init_once(void);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("In main\n");
|
||||
px4::init_once();
|
||||
px4::init(argc, argv, "mainapp");
|
||||
process_commands(commands);
|
||||
for (;;) {}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,15 @@
|
||||
# NuttX / uORB adapter library
|
||||
#
|
||||
|
||||
SRCDIR=$(dir $(MODULE_MK))
|
||||
|
||||
apps.h: $(PX4_BASE)/Tools/qurt_apps.py
|
||||
$(PX4_BASE)/Tools/qurt_apps.py > $@
|
||||
|
||||
# Force creation of apps.h
|
||||
main_.cpp: $(SRCDIR)/../main.cpp apps.h
|
||||
cp $(SRCDIR)/../main.cpp $@
|
||||
|
||||
SRCS = \
|
||||
px4_qurt_impl.cpp \
|
||||
px4_qurt_tasks.cpp \
|
||||
@@ -49,6 +58,7 @@ SRCS = \
|
||||
sq_addlast.c \
|
||||
sq_remfirst.c \
|
||||
sq_addafter.c \
|
||||
dq_rem.c
|
||||
dq_rem.c \
|
||||
main_.cpp
|
||||
|
||||
MAXOPTIMIZATION = -Os
|
||||
|
||||
@@ -46,7 +46,9 @@
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <semaphore.h>
|
||||
#include "systemlib/param/param.h"
|
||||
#include <hexagon_standalone.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
@@ -58,6 +60,14 @@ unsigned int sleep(unsigned int sec) { return 0; }
|
||||
|
||||
extern void hrt_init(void);
|
||||
|
||||
void qurt_log(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
printf(fmt, args);
|
||||
printf("n");
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
|
||||
extern struct wqueue_s gwork[NWORKERS];
|
||||
@@ -71,12 +81,7 @@ void init_once(void)
|
||||
{
|
||||
work_queues_init();
|
||||
hrt_init();
|
||||
}
|
||||
|
||||
void init(int argc, char *argv[], const char *app_name)
|
||||
{
|
||||
printf("App name: %s\n", app_name);
|
||||
|
||||
|
||||
// Create high priority worker thread
|
||||
g_work[HPWORK].pid = px4_task_spawn_cmd("wkr_high",
|
||||
SCHED_DEFAULT,
|
||||
@@ -95,6 +100,11 @@ void init(int argc, char *argv[], const char *app_name)
|
||||
|
||||
}
|
||||
|
||||
void init(int argc, char *argv[], const char *app_name)
|
||||
{
|
||||
PX4_DEBUG("App name: %s\n", app_name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Retrieve from the data manager store */
|
||||
@@ -131,12 +141,3 @@ size_t strnlen(const char *s, size_t maxlen)
|
||||
return i;
|
||||
}
|
||||
|
||||
void qurt_log(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user