mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 08:03:33 +08:00
Manually integrated Jim's changes from integrate2_jim branch
Signed-off-by: Jim Wilson <jywilson99@hotmail.com> Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
committed by
Julian Oes
parent
a1a615b907
commit
caa94d58a6
@@ -87,7 +87,7 @@ static void hrt_unlock(void)
|
||||
px4_sem_post(&_hrt_lock);
|
||||
}
|
||||
|
||||
#if (defined(__APPLE__) && defined(__MACH__)) || defined(__PX4_QURT)
|
||||
#if (defined(__APPLE__) && defined(__MACH__))
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#define CLOCK_REALTIME 0
|
||||
@@ -111,12 +111,14 @@ int px4_clock_gettime(clockid_t clk_id, struct timespec *tp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int px4_clock_settime(clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
/* do nothing right now */
|
||||
return 0;
|
||||
}
|
||||
#elif defined(__QURT)
|
||||
|
||||
#include "dspal_time.h"
|
||||
|
||||
int px4_clock_gettime(clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
return clock_gettime(clk_id, tp);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -41,12 +41,16 @@
|
||||
|
||||
#include <px4_defines.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#if defined(__PX4_QURT)
|
||||
#include <dspal_types.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* Semaphore handling */
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ typedef int px4_task_t;
|
||||
#define SCHED_PRIORITY_MIN sched_get_priority_min(SCHED_FIFO)
|
||||
#define SCHED_PRIORITY_DEFAULT (((sched_get_priority_max(SCHED_FIFO) - sched_get_priority_min(SCHED_FIFO)) / 2) + sched_get_priority_min(SCHED_FIFO))
|
||||
#elif defined(__PX4_QURT)
|
||||
#define SCHED_PRIORITY_MAX 0
|
||||
#define SCHED_PRIORITY_MAX 255
|
||||
#define SCHED_PRIORITY_MIN 0
|
||||
#define SCHED_PRIORITY_DEFAULT 0
|
||||
#define SCHED_PRIORITY_DEFAULT 20
|
||||
#else
|
||||
#error "No target OS defined"
|
||||
#endif
|
||||
|
||||
@@ -34,24 +34,13 @@
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
static void do_dlopen()
|
||||
{
|
||||
}
|
||||
|
||||
int dlinit(int a, char **b)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
char *builtin[] = {"libgcc.so", "libc.so"};
|
||||
|
||||
printf("In DSPAL main\n");
|
||||
dlinit(2, builtin);
|
||||
// This code is never run. It is used solely to test linking in the
|
||||
// TravisCI build test
|
||||
|
||||
do_dlopen();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +174,7 @@ __END_DECLS
|
||||
|
||||
const char *get_commands()
|
||||
{
|
||||
PX4_INFO("attempting to open the ADSP command file: %s", COMMANDS_ADSP_FILE);
|
||||
int fd = open(COMMANDS_ADSP_FILE, O_RDONLY);
|
||||
|
||||
if (fd > 0) {
|
||||
|
||||
@@ -112,6 +112,9 @@ px4_systemreset(bool to_bootloader)
|
||||
px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int stack_size, px4_main_t entry,
|
||||
char *const argv[])
|
||||
{
|
||||
struct sched_param param;
|
||||
pthread_attr_t attr;
|
||||
pthread_t task;
|
||||
int rv;
|
||||
int argc = 0;
|
||||
int i;
|
||||
@@ -121,9 +124,7 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
|
||||
char *p = (char *)argv;
|
||||
|
||||
PX4_DEBUG("Creating %s\n", name);
|
||||
pthread_t task;
|
||||
pthread_attr_t attr;
|
||||
struct sched_param param;
|
||||
PX4_DEBUG("attr address: 0x%X, param address: 0x%X", &attr, ¶m);
|
||||
|
||||
// Calculate argc
|
||||
while (p != (char *)0) {
|
||||
@@ -138,7 +139,7 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
|
||||
}
|
||||
|
||||
structsize = sizeof(pthdata_t) + (argc + 1) * sizeof(char *);
|
||||
pthdata_t *taskdata;
|
||||
pthdata_t *taskdata = nullptr;
|
||||
|
||||
// not safe to pass stack data to the thread creation
|
||||
taskdata = (pthdata_t *)malloc(structsize + len);
|
||||
@@ -164,7 +165,10 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
|
||||
return (rv < 0) ? rv : -rv;
|
||||
}
|
||||
|
||||
rv = pthread_attr_getschedparam(&attr, ¶m);
|
||||
PX4_DEBUG("stack address after pthread_attr_init: 0x%X", attr.stackaddr);
|
||||
PX4_DEBUG("attr address: 0x%X, param address: 0x%X", &attr, ¶m);
|
||||
rv = pthread_attr_getschedparam(&attr, ¶m);
|
||||
PX4_DEBUG("stack address after pthread_attr_getschedparam: 0x%X", attr.stackaddr);
|
||||
|
||||
if (rv != 0) {
|
||||
PX4_WARN("px4_task_spawn_cmd: failed to get thread sched param");
|
||||
@@ -189,28 +193,27 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
|
||||
#endif
|
||||
size_t fixed_stacksize = -1;
|
||||
pthread_attr_getstacksize(&attr, &fixed_stacksize);
|
||||
PX4_WARN("stack size: %d passed stacksize(%d)", fixed_stacksize, stack_size);
|
||||
PX4_INFO("stack size: %d passed stacksize(%d)", fixed_stacksize, stack_size);
|
||||
fixed_stacksize = 8 * 1024;
|
||||
fixed_stacksize = (fixed_stacksize < (size_t)stack_size) ? (size_t)stack_size : fixed_stacksize;
|
||||
|
||||
PX4_WARN("setting the thread[%s] stack size to[%d]", name, fixed_stacksize);
|
||||
PX4_INFO("setting the thread[%s] stack size to[%d]", name, fixed_stacksize);
|
||||
pthread_attr_setstacksize(&attr, fixed_stacksize);
|
||||
//pthread_attr_setstacksize(&attr, stack_size);
|
||||
|
||||
|
||||
PX4_DEBUG("stack address after pthread_attr_setstacksize: 0x%X", attr.stackaddr);
|
||||
param.sched_priority = priority;
|
||||
|
||||
rv = pthread_attr_setschedparam(&attr, ¶m);
|
||||
|
||||
if (rv != 0) {
|
||||
PX4_WARN("px4_task_spawn_cmd: failed to set sched param");
|
||||
PX4_ERR("px4_task_spawn_cmd: failed to set sched param");
|
||||
return (rv < 0) ? rv : -rv;
|
||||
}
|
||||
|
||||
rv = pthread_create(&task, &attr, &entry_adapter, (void *) taskdata);
|
||||
|
||||
if (rv != 0) {
|
||||
|
||||
PX4_ERR("px4_task_spawn_cmd: pthread_create failed, error: %d", rv);
|
||||
return (rv < 0) ? rv : -rv;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,6 @@
|
||||
#include <shmem.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
|
||||
#define SHMEM_DEBUG
|
||||
|
||||
int mem_fd;
|
||||
unsigned char *map_base, *virt_addr;
|
||||
struct shmem_info *shmem_info_p;
|
||||
@@ -180,11 +178,13 @@ void update_to_shmem(param_t param, union param_value_u value)
|
||||
|
||||
#ifdef SHMEM_DEBUG
|
||||
|
||||
if (param_type(param) == PARAM_TYPE_INT32)
|
||||
{PX4_INFO("Set value %d for param %s to shmem, set adsp index %d:%d\n", value.i, param_name(param), byte_changed, bit_changed);}
|
||||
if (param_type(param) == PARAM_TYPE_INT32) {
|
||||
PX4_INFO("Set value %d for param %s to shmem, set adsp index %d:%d\n", value.i, param_name(param), byte_changed, bit_changed);
|
||||
}
|
||||
|
||||
else if (param_type(param) == PARAM_TYPE_FLOAT)
|
||||
{PX4_INFO("Set value %f for param %s to shmem, set adsp index %d:%d\n", value.f, param_name(param), byte_changed, bit_changed);}
|
||||
else if (param_type(param) == PARAM_TYPE_FLOAT) {
|
||||
PX4_INFO("Set value %f for param %s to shmem, set adsp index %d:%d\n", value.f, param_name(param), byte_changed, bit_changed);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -231,11 +231,13 @@ static void update_value_from_shmem(param_t param, union param_value_u *value)
|
||||
|
||||
#ifdef SHMEM_DEBUG
|
||||
|
||||
if (param_type(param) == PARAM_TYPE_INT32)
|
||||
{PX4_INFO("Got value %d for param %s from shmem, cleared krait index %d:%d\n", value->i, param_name(param), byte_changed, bit_changed);}
|
||||
if (param_type(param) == PARAM_TYPE_INT32) {
|
||||
PX4_INFO("Got value %d for param %s from shmem, cleared krait index %d:%d\n", value->i, param_name(param), byte_changed, bit_changed);
|
||||
}
|
||||
|
||||
else if (param_type(param) == PARAM_TYPE_FLOAT)
|
||||
{PX4_INFO("Got value %f for param %s from shmem, cleared krait index %d:%d\n", value->f, param_name(param), byte_changed, bit_changed);}
|
||||
else if (param_type(param) == PARAM_TYPE_FLOAT) {
|
||||
PX4_INFO("Got value %f for param %s from shmem, cleared krait index %d:%d\n", value->f, param_name(param), byte_changed, bit_changed);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user