mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 00:11:37 +08:00
Fixes for qurt build
Added missing functions that were added for other targets but not for qurt. Added workaround for missing sem_timedwait(). This may have a performance impact until a sem_timedwait is supported. std::to_string is not supported by the hexagon compiler Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
committed by
Lorenz Meier
parent
1edd9d5a9a
commit
5bc2019fd5
+1
-1
Submodule src/lib/matrix updated: cc1658db15...b9d6cac199
@@ -3209,7 +3209,7 @@ void answer_command(struct vehicle_command_s &cmd, unsigned result,
|
|||||||
void *commander_low_prio_loop(void *arg)
|
void *commander_low_prio_loop(void *arg)
|
||||||
{
|
{
|
||||||
/* Set thread name */
|
/* Set thread name */
|
||||||
px4_prctl(PR_SET_NAME, "commander_low_prio", getpid());
|
px4_prctl(PR_SET_NAME, "commander_low_prio", px4_getpid());
|
||||||
|
|
||||||
/* Subscribe to command topic */
|
/* Subscribe to command topic */
|
||||||
int cmd_sub = orb_subscribe(ORB_ID(vehicle_command));
|
int cmd_sub = orb_subscribe(ORB_ID(vehicle_command));
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
*
|
*
|
||||||
* RC calibration check
|
* RC calibration check
|
||||||
*/
|
*/
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ static void hrt_unlock(void)
|
|||||||
px4_sem_post(&_hrt_lock);
|
px4_sem_post(&_hrt_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__) && defined(__MACH__)
|
#if (defined(__APPLE__) && defined(__MACH__)) || defined(__PX4_QURT)
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#define CLOCK_REALTIME 0
|
#define CLOCK_REALTIME 0
|
||||||
|
|||||||
@@ -177,8 +177,7 @@ __END_DECLS
|
|||||||
#define MAX_RAND 32767
|
#define MAX_RAND 32767
|
||||||
|
|
||||||
#if defined(__PX4_QURT)
|
#if defined(__PX4_QURT)
|
||||||
#define M_PI 3.14159265358979323846
|
#include "dspal_math.h"
|
||||||
#define M_PI_2 1.57079632679489661923
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|||||||
@@ -77,11 +77,16 @@ typedef sem_t px4_sem_t;
|
|||||||
|
|
||||||
#define px4_sem_init sem_init
|
#define px4_sem_init sem_init
|
||||||
#define px4_sem_wait sem_wait
|
#define px4_sem_wait sem_wait
|
||||||
#define px4_sem_timedwait sem_timedwait
|
|
||||||
#define px4_sem_post sem_post
|
#define px4_sem_post sem_post
|
||||||
#define px4_sem_getvalue sem_getvalue
|
#define px4_sem_getvalue sem_getvalue
|
||||||
#define px4_sem_destroy sem_destroy
|
#define px4_sem_destroy sem_destroy
|
||||||
|
|
||||||
|
#ifdef __PX4_QURT
|
||||||
|
__EXPORT int px4_sem_timedwait(px4_sem_t *sem, const struct timespec *abstime);
|
||||||
|
#else
|
||||||
|
#define px4_sem_timedwait sem_timedwait
|
||||||
|
#endif
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -35,11 +35,14 @@
|
|||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
__EXPORT extern uint64_t hrt_absolute_time(void);
|
||||||
|
|
||||||
//void qurt_log(int level, const char *file, int line, const char *format, ...);
|
//void qurt_log(int level, const char *file, int line, const char *format, ...);
|
||||||
|
|
||||||
// declaration to make the compiler happy. This symbol is part of the adsp static image.
|
// declaration to make the compiler happy. This symbol is part of the adsp static image.
|
||||||
|
|||||||
@@ -63,8 +63,36 @@ static void hrt_call_reschedule(void);
|
|||||||
static sem_t _hrt_lock;
|
static sem_t _hrt_lock;
|
||||||
static struct work_s _hrt_work;
|
static struct work_s _hrt_work;
|
||||||
|
|
||||||
static void
|
#include <time.h>
|
||||||
hrt_call_invoke(void);
|
#include <sys/time.h>
|
||||||
|
#define CLOCK_REALTIME 0
|
||||||
|
|
||||||
|
#ifndef CLOCK_MONOTONIC
|
||||||
|
#define CLOCK_MONOTONIC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int px4_clock_gettime(clockid_t clk_id, struct timespec *tp)
|
||||||
|
{
|
||||||
|
struct timeval now;
|
||||||
|
int rv = gettimeofday(&now, NULL);
|
||||||
|
|
||||||
|
if (rv) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
tp->tv_sec = now.tv_sec;
|
||||||
|
tp->tv_nsec = now.tv_usec * 1000;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int px4_clock_settime(clockid_t clk_id, struct timespec *tp)
|
||||||
|
{
|
||||||
|
/* do nothing right now */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void hrt_call_invoke(void);
|
||||||
|
|
||||||
static void hrt_lock(void)
|
static void hrt_lock(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,7 +37,10 @@
|
|||||||
* Implementation of existing task API for Linux
|
* Implementation of existing task API for Linux
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <px4_log.h>
|
#include "px4_log.h"
|
||||||
|
#include "px4_posix.h"
|
||||||
|
#include "px4_workqueue.h"
|
||||||
|
#include "hrt_work.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -318,7 +321,7 @@ void px4_show_tasks()
|
|||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
int px4_getpid()
|
unsigned long px4_getpid()
|
||||||
{
|
{
|
||||||
pthread_t pid = pthread_self();
|
pthread_t pid = pthread_self();
|
||||||
//
|
//
|
||||||
@@ -333,7 +336,7 @@ int px4_getpid()
|
|||||||
}
|
}
|
||||||
|
|
||||||
PX4_ERR("px4_getpid() called from unknown thread context!");
|
PX4_ERR("px4_getpid() called from unknown thread context!");
|
||||||
return -EINVAL;
|
return ~0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -350,5 +353,44 @@ const char *getprogname()
|
|||||||
|
|
||||||
return "Unknown App";
|
return "Unknown App";
|
||||||
}
|
}
|
||||||
__END_DECLS
|
|
||||||
|
|
||||||
|
static void timer_cb(void *data)
|
||||||
|
{
|
||||||
|
px4_sem_t *sem = reinterpret_cast<px4_sem_t *>(data);
|
||||||
|
|
||||||
|
sem_post(sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
int px4_sem_timedwait(px4_sem_t *sem, const struct timespec *ts)
|
||||||
|
{
|
||||||
|
void *result;
|
||||||
|
work_s _hpwork = {};
|
||||||
|
|
||||||
|
// Create a timer to unblock
|
||||||
|
uint32_t timeout = ts->tv_sec*1000000+ (ts->tv_nsec/1000);
|
||||||
|
hrt_work_queue(&_hpwork, (worker_t)&timer_cb, (void *)sem, timeout);
|
||||||
|
sem_wait(sem);
|
||||||
|
hrt_work_cancel(&_hpwork);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int px4_prctl(int option, const char *arg2, unsigned pid)
|
||||||
|
{
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
switch (option) {
|
||||||
|
case PR_SET_NAME:
|
||||||
|
// set the threads name - Not supported
|
||||||
|
// rv = pthread_setname_np(pthread_self(), arg2);
|
||||||
|
rv = -1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
rv = -1;
|
||||||
|
PX4_WARN("FAILED SETTING TASK NAME");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
__END_DECLS
|
||||||
|
|||||||
Reference in New Issue
Block a user