Showcase clang-format google style

This commit is contained in:
Matthias Grob
2022-06-30 16:10:40 +02:00
parent 437148f8f3
commit 25ed6b67fb
2694 changed files with 103014 additions and 118862 deletions
+3 -5
View File
@@ -41,8 +41,8 @@
* Included Files
************************************************************/
#include <stddef.h>
#include <queue.h>
#include <stddef.h>
/************************************************************
* Public Functions
@@ -56,8 +56,7 @@
*
************************************************************/
void dq_addlast(dq_entry_t *node, dq_queue_t *queue)
{
void dq_addlast(dq_entry_t *node, dq_queue_t *queue) {
node->flink = NULL;
node->blink = queue->tail;
@@ -67,7 +66,6 @@ void dq_addlast(dq_entry_t *node, dq_queue_t *queue)
} else {
queue->tail->flink = node;
queue->tail = node;
queue->tail = node;
}
}
+2 -4
View File
@@ -41,8 +41,8 @@
* Included Files
************************************************************/
#include <stddef.h>
#include <queue.h>
#include <stddef.h>
/************************************************************
* Public Functions
@@ -56,8 +56,7 @@
*
************************************************************/
void dq_rem(dq_entry_t *node, dq_queue_t *queue)
{
void dq_rem(dq_entry_t *node, dq_queue_t *queue) {
dq_entry_t *prev = node->blink;
dq_entry_t *next = node->flink;
@@ -78,4 +77,3 @@ void dq_rem(dq_entry_t *node, dq_queue_t *queue)
node->flink = NULL;
node->blink = NULL;
}
+2 -4
View File
@@ -41,8 +41,8 @@
* Included Files
************************************************************/
#include <stddef.h>
#include <queue.h>
#include <stddef.h>
/************************************************************
* Public Functions
@@ -56,8 +56,7 @@
*
************************************************************/
dq_entry_t *dq_remfirst(dq_queue_t *queue)
{
dq_entry_t *dq_remfirst(dq_queue_t *queue) {
dq_entry_t *ret = queue->head;
if (ret) {
@@ -78,4 +77,3 @@ dq_entry_t *dq_remfirst(dq_queue_t *queue)
return ret;
}
+16 -19
View File
@@ -37,19 +37,18 @@
* Included Files
****************************************************************************/
#include <px4_platform_common/px4_config.h>
#include <drivers/drv_hrt.h>
#include <px4_platform_common/defines.h>
#include <px4_platform_common/workqueue.h>
#include <px4_platform_common/posix.h>
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/tasks.h>
#include <px4_platform_common/workqueue.h>
#include <queue.h>
#include <semaphore.h>
#include <signal.h>
#include <stdint.h>
#include <queue.h>
#include <stdio.h>
#include <semaphore.h>
#include <drivers/drv_hrt.h>
#include <px4_platform_common/workqueue.h>
#include <px4_platform_common/posix.h>
#include "hrt_work.h"
/****************************************************************************
@@ -104,15 +103,14 @@
*
****************************************************************************/
int hrt_work_queue(struct work_s *work, worker_t worker, void *arg, uint32_t delay)
{
int hrt_work_queue(struct work_s *work, worker_t worker, void *arg, uint32_t delay) {
struct wqueue_s *wqueue = &g_hrt_work;
/* First, initialize the work structure */
work->worker = worker; /* Work callback */
work->arg = arg; /* Callback argument */
work->delay = delay; /* Delay until work performed */
work->worker = worker; /* Work callback */
work->arg = arg; /* Callback argument */
work->delay = delay; /* Delay until work performed */
/* Now, time-tag that entry and put it in the work queue. This must be
* done with interrupts disabled. This permits this function to be called
@@ -120,21 +118,20 @@ int hrt_work_queue(struct work_s *work, worker_t worker, void *arg, uint32_t del
*/
hrt_work_lock();
work->qtime = hrt_absolute_time(); /* Time work queued */
//PX4_INFO("hrt work_queue adding work delay=%u time=%lu", delay, work->qtime);
work->qtime = hrt_absolute_time(); /* Time work queued */
// PX4_INFO("hrt work_queue adding work delay=%u time=%lu", delay, work->qtime);
dq_addlast(&work->dq, &wqueue->q);
if (px4_getpid() != wqueue->pid) { /* only need to wake up if called from a different thread */
#ifdef __PX4_QURT
px4_task_kill(wqueue->pid, SIGALRM); /* Wake up the worker thread */
px4_task_kill(wqueue->pid, SIGALRM); /* Wake up the worker thread */
#else
//wqueue->pid == own task? -> don't signal
px4_task_kill(wqueue->pid, SIGCONT); /* Wake up the worker thread */
// wqueue->pid == own task? -> don't signal
px4_task_kill(wqueue->pid, SIGCONT); /* Wake up the worker thread */
#endif
}
hrt_work_unlock();
return PX4_OK;
}
+25 -37
View File
@@ -38,21 +38,21 @@
* Included Files
****************************************************************************/
#include <px4_platform_common/px4_config.h>
#include <drivers/drv_hrt.h>
#include <px4_platform_common/defines.h>
#include <px4_platform_common/posix.h>
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/tasks.h>
#include <px4_platform_common/time.h>
#include <stdint.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <queue.h>
#include <px4_platform_common/workqueue.h>
#include <drivers/drv_hrt.h>
#include "hrt_work.h"
#include <queue.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "hrt_work.h"
/****************************************************************************
* Pre-processor Definitions
@@ -94,10 +94,7 @@ static void _sighandler(int sig_num);
* None
*
****************************************************************************/
static void _sighandler(int sig_num)
{
PX4_DEBUG("RECEIVED SIGNAL %d", sig_num);
}
static void _sighandler(int sig_num) { PX4_DEBUG("RECEIVED SIGNAL %d", sig_num); }
/****************************************************************************
* Name: work_process
@@ -113,11 +110,10 @@ static void _sighandler(int sig_num)
*
****************************************************************************/
static void hrt_work_process()
{
static void hrt_work_process() {
struct wqueue_s *wqueue = &g_hrt_work;
volatile struct work_s *work;
worker_t worker;
worker_t worker;
void *arg;
uint64_t elapsed;
uint32_t remaining;
@@ -128,7 +124,7 @@ static void hrt_work_process()
pthread_setname_np("HRT");
#else
// The Linux headers do not actually contain this
//rv = pthread_setname_np(pthread_self(), "HRT");
// rv = pthread_setname_np(pthread_self(), "HRT");
#endif
/* Then process queued work. We need to keep interrupts disabled while
@@ -136,11 +132,11 @@ static void hrt_work_process()
*/
/* Default to sleeping for 1 sec */
next = 1000000;
next = 1000000;
hrt_work_lock();
work = (struct work_s *)wqueue->q.head;
work = (struct work_s *)wqueue->q.head;
while (work) {
/* Is this work ready? It is ready if there is no delay or if
@@ -151,19 +147,19 @@ static void hrt_work_process()
elapsed = hrt_absolute_time() - work->qtime;
//PX4_INFO("hrt work_process: in usec elapsed=%lu delay=%u work=%p", elapsed, work->delay, work);
// PX4_INFO("hrt work_process: in usec elapsed=%lu delay=%u work=%p", elapsed, work->delay, work);
if (elapsed >= work->delay) {
/* Remove the ready-to-execute work from the list */
(void)dq_rem((dq_entry_t *)&work->dq, &wqueue->q);
//PX4_INFO("Dequeued work=%p", work);
// PX4_INFO("Dequeued work=%p", work);
/* Extract the work description from the entry (in case the work
* instance by the re-used after it has been de-queued).
*/
worker = work->worker;
arg = work->arg;
arg = work->arg;
/* Mark the work as no longer being queued */
@@ -188,7 +184,7 @@ static void hrt_work_process()
*/
hrt_work_lock();
work = (struct work_s *)wqueue->q.head;
work = (struct work_s *)wqueue->q.head;
} else {
/* This one is not ready.. will it be ready before the next
@@ -198,7 +194,7 @@ static void hrt_work_process()
/* Here: elapsed < work->delay */
remaining = work->delay - elapsed;
//PX4_INFO("remaining=%u delay=%u elapsed=%lu", remaining, work->delay, elapsed);
// PX4_INFO("remaining=%u delay=%u elapsed=%lu", remaining, work->delay, elapsed);
if (remaining < next) {
/* Yes.. Then schedule to wake up when the work is ready */
@@ -208,7 +204,7 @@ static void hrt_work_process()
/* Then try the next in the list. */
work = (struct work_s *)work->dq.flink;
//PX4_INFO("next %u work %p", next, work);
// PX4_INFO("next %u work %p", next, work);
}
}
@@ -218,7 +214,7 @@ static void hrt_work_process()
hrt_work_unlock();
/* might sleep less if a signal received and new item was queued */
//PX4_INFO("Sleeping for %u usec", next);
// PX4_INFO("Sleeping for %u usec", next);
px4_usleep(next);
}
@@ -247,8 +243,7 @@ static void hrt_work_process()
*
****************************************************************************/
static int work_hrtthread(int argc, char *argv[])
{
static int work_hrtthread(int argc, char *argv[]) {
/* Loop forever */
for (;;) {
@@ -273,24 +268,17 @@ static int work_hrtthread(int argc, char *argv[])
* Public Functions
****************************************************************************/
void hrt_work_queue_init(void)
{
void hrt_work_queue_init(void) {
px4_sem_init(&_hrt_work_lock, 0, 1);
memset(&g_hrt_work, 0, sizeof(g_hrt_work));
// Create high priority worker thread
g_hrt_work.pid = px4_task_spawn_cmd("wkr_hrt",
SCHED_DEFAULT,
SCHED_PRIORITY_MAX,
2000,
work_hrtthread,
g_hrt_work.pid = px4_task_spawn_cmd("wkr_hrt", SCHED_DEFAULT, SCHED_PRIORITY_MAX, 2000, work_hrtthread,
(char *const *)NULL);
#ifdef __PX4_QURT
signal(SIGALRM, _sighandler);
#else
signal(SIGCONT, _sighandler);
#endif
}
@@ -37,8 +37,8 @@
* Included Files
****************************************************************************/
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/defines.h>
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/workqueue.h>
#include "hrt_work.h"
@@ -80,11 +80,10 @@
*
****************************************************************************/
void hrt_work_cancel(struct work_s *work)
{
void hrt_work_cancel(struct work_s *work) {
struct wqueue_s *wqueue = &g_hrt_work;
//DEBUGASSERT(work != NULL && (unsigned)qid < NWORKERS);
// DEBUGASSERT(work != NULL && (unsigned)qid < NWORKERS);
/* Cancelling the work is simply a matter of removing the work structure
* from the work queue. This must be done with interrupts disabled because
@@ -96,8 +95,8 @@ void hrt_work_cancel(struct work_s *work)
if (work->worker != NULL) {
/* A little test of the integrity of the work queue */
//DEBUGASSERT(work->dq.flink ||(dq_entry_t *)work == wqueue->q.tail);
//DEBUGASSERT(work->dq.blink ||(dq_entry_t *)work == wqueue->q.head);
// DEBUGASSERT(work->dq.flink ||(dq_entry_t *)work == wqueue->q.tail);
// DEBUGASSERT(work->dq.blink ||(dq_entry_t *)work == wqueue->q.head);
/* Remove the entry from the work queue and make sure that it is
* mark as availalbe (i.e., the worker field is nullified).
+5 -11
View File
@@ -38,8 +38,7 @@
#include <queue.h>
#include <stddef.h>
void sq_rem(sq_entry_t *node, sq_queue_t *queue)
{
void sq_rem(sq_entry_t *node, sq_queue_t *queue) {
if (queue->head && node) {
if (node == queue->head) {
queue->head = node->flink;
@@ -51,9 +50,8 @@ void sq_rem(sq_entry_t *node, sq_queue_t *queue)
} else {
sq_entry_t *prev;
for (prev = (sq_entry_t *)queue->head;
prev && prev->flink != node;
prev = prev->flink) {}
for (prev = (sq_entry_t *)queue->head; prev && prev->flink != node; prev = prev->flink) {
}
if (prev) {
sq_remafter(prev, queue);
@@ -62,8 +60,7 @@ void sq_rem(sq_entry_t *node, sq_queue_t *queue)
}
}
sq_entry_t *sq_remafter(sq_entry_t *node, sq_queue_t *queue)
{
sq_entry_t *sq_remafter(sq_entry_t *node, sq_queue_t *queue) {
sq_entry_t *ret = node->flink;
if (queue->head && ret) {
@@ -81,8 +78,7 @@ sq_entry_t *sq_remafter(sq_entry_t *node, sq_queue_t *queue)
return ret;
}
void sq_addfirst(sq_entry_t *node, sq_queue_t *queue)
{
void sq_addfirst(sq_entry_t *node, sq_queue_t *queue) {
node->flink = queue->head;
if (!queue->head) {
@@ -91,5 +87,3 @@ void sq_addfirst(sq_entry_t *node, sq_queue_t *queue)
queue->head = node;
}
+1 -3
View File
@@ -56,9 +56,7 @@
*
************************************************************/
void sq_addafter(sq_entry_t *prev, sq_entry_t *node,
sq_queue_t *queue)
{
void sq_addafter(sq_entry_t *prev, sq_entry_t *node, sq_queue_t *queue) {
if (!queue->head || prev == queue->tail) {
sq_addlast(node, queue);
+3 -5
View File
@@ -41,8 +41,8 @@
* Included Files
************************************************************/
#include <stddef.h>
#include <queue.h>
#include <stddef.h>
/************************************************************
* Public Functions
@@ -56,8 +56,7 @@
* the 'queue'
************************************************************/
void sq_addlast(sq_entry_t *node, sq_queue_t *queue)
{
void sq_addlast(sq_entry_t *node, sq_queue_t *queue) {
node->flink = NULL;
if (!queue->head) {
@@ -66,7 +65,6 @@ void sq_addlast(sq_entry_t *node, sq_queue_t *queue)
} else {
queue->tail->flink = node;
queue->tail = node;
queue->tail = node;
}
}
+2 -4
View File
@@ -41,8 +41,8 @@
* Included Files
************************************************************/
#include <stddef.h>
#include <queue.h>
#include <stddef.h>
/************************************************************
* Public Functions
@@ -57,8 +57,7 @@
*
************************************************************/
sq_entry_t *sq_remfirst(sq_queue_t *queue)
{
sq_entry_t *sq_remfirst(sq_queue_t *queue) {
sq_entry_t *ret = queue->head;
if (ret) {
@@ -73,4 +72,3 @@ sq_entry_t *sq_remfirst(sq_queue_t *queue)
return ret;
}
+7 -7
View File
@@ -37,10 +37,11 @@
* Included Files
****************************************************************************/
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/defines.h>
#include <queue.h>
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/workqueue.h>
#include <queue.h>
#include "work_lock.h"
#ifdef CONFIG_SCHED_WORKQUEUE
@@ -86,11 +87,10 @@
*
****************************************************************************/
int work_cancel(int qid, struct work_s *work)
{
int work_cancel(int qid, struct work_s *work) {
struct wqueue_s *wqueue = &g_work[qid];
//DEBUGASSERT(work != NULL && (unsigned)qid < NWORKERS);
// DEBUGASSERT(work != NULL && (unsigned)qid < NWORKERS);
/* Cancelling the work is simply a matter of removing the work structure
* from the work queue. This must be done with interrupts disabled because
@@ -102,8 +102,8 @@ int work_cancel(int qid, struct work_s *work)
if (work->worker != NULL) {
/* A little test of the integrity of the work queue */
//DEBUGASSERT(work->dq.flink ||(dq_entry_t *)work == wqueue->q.tail);
//DEBUGASSERT(work->dq.blink ||(dq_entry_t *)work == wqueue->q.head);
// DEBUGASSERT(work->dq.flink ||(dq_entry_t *)work == wqueue->q.tail);
// DEBUGASSERT(work->dq.blink ||(dq_entry_t *)work == wqueue->q.head);
/* Remove the entry from the work queue and make sure that it is
* mark as availalbe (i.e., the worker field is nullified).
+4 -10
View File
@@ -30,20 +30,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#include "work_lock.h"
#include <px4_platform_common/log.h>
#include <px4_platform_common/posix.h>
#include <stdio.h>
#include "work_lock.h"
extern px4_sem_t _work_lock[];
void work_lock(int id)
{
px4_sem_wait(&_work_lock[id]);
}
void work_lock(int id) { px4_sem_wait(&_work_lock[id]); }
void work_unlock(int id)
{
px4_sem_post(&_work_lock[id]);
}
void work_unlock(int id) { px4_sem_post(&_work_lock[id]); }
+1 -2
View File
@@ -34,10 +34,9 @@
#ifndef _work_lock_h_
#define _work_lock_h_
//#pragma once
void work_lock(int id);
void work_unlock(int id);
#endif // _work_lock_h_
#endif // _work_lock_h_
+13 -14
View File
@@ -37,16 +37,16 @@
* Included Files
****************************************************************************/
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/defines.h>
#include <px4_platform_common/workqueue.h>
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/tasks.h>
#include <px4_platform_common/workqueue.h>
#include <queue.h>
#include <semaphore.h>
#include <signal.h>
#include <stdint.h>
#include <queue.h>
#include <stdio.h>
#include <semaphore.h>
#include "work_lock.h"
#ifdef CONFIG_SCHED_WORKQUEUE
@@ -104,17 +104,16 @@
*
****************************************************************************/
int work_queue(int qid, struct work_s *work, worker_t worker, void *arg, uint32_t delay)
{
int work_queue(int qid, struct work_s *work, worker_t worker, void *arg, uint32_t delay) {
struct wqueue_s *wqueue = &g_work[qid];
//DEBUGASSERT(work != NULL && (unsigned)qid < NWORKERS);
// DEBUGASSERT(work != NULL && (unsigned)qid < NWORKERS);
/* First, initialize the work structure */
work->worker = worker; /* Work callback */
work->arg = arg; /* Callback argument */
work->delay = delay; /* Delay until work performed */
work->worker = worker; /* Work callback */
work->arg = arg; /* Callback argument */
work->delay = delay; /* Delay until work performed */
/* Now, time-tag that entry and put it in the work queue. This must be
* done with interrupts disabled. This permits this function to be called
@@ -122,13 +121,13 @@ int work_queue(int qid, struct work_s *work, worker_t worker, void *arg, uint32_
*/
work_lock(qid);
work->qtime = clock_systimer(); /* Time work queued */
work->qtime = clock_systimer(); /* Time work queued */
dq_addlast((dq_entry_t *)work, &wqueue->q);
#ifdef __PX4_QURT
px4_task_kill(wqueue->pid, SIGALRM); /* Wake up the worker thread */
px4_task_kill(wqueue->pid, SIGALRM); /* Wake up the worker thread */
#else
px4_task_kill(wqueue->pid, SIGCONT); /* Wake up the worker thread */
px4_task_kill(wqueue->pid, SIGCONT); /* Wake up the worker thread */
#endif
work_unlock(qid);
+22 -36
View File
@@ -37,18 +37,19 @@
* Included Files
****************************************************************************/
#include <px4_platform_common/px4_config.h>
#include <drivers/drv_hrt.h>
#include <pthread.h>
#include <px4_platform_common/defines.h>
#include <px4_platform_common/posix.h>
#include <px4_platform_common/time.h>
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/tasks.h>
#include <px4_platform_common/time.h>
#include <px4_platform_common/workqueue.h>
#include <queue.h>
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include <queue.h>
#include <pthread.h>
#include <drivers/drv_hrt.h>
#include "work_lock.h"
#ifdef CONFIG_SCHED_WORKQUEUE
@@ -91,10 +92,9 @@ px4_sem_t _work_lock[NWORKERS];
*
****************************************************************************/
static void work_process(struct wqueue_s *wqueue, int lock_id)
{
static void work_process(struct wqueue_s *wqueue, int lock_id) {
volatile struct work_s *work;
worker_t worker;
worker_t worker;
void *arg;
uint64_t elapsed;
uint32_t remaining;
@@ -104,11 +104,11 @@ static void work_process(struct wqueue_s *wqueue, int lock_id)
* we process items in the work list.
*/
next = CONFIG_SCHED_WORKPERIOD;
next = CONFIG_SCHED_WORKPERIOD;
work_lock(lock_id);
work = (struct work_s *)wqueue->q.head;
work = (struct work_s *)wqueue->q.head;
while (work) {
/* Is this work ready? It is ready if there is no delay or if
@@ -119,7 +119,7 @@ static void work_process(struct wqueue_s *wqueue, int lock_id)
elapsed = USEC2TICK(clock_systimer() - work->qtime);
//printf("work_process: in ticks elapsed=%lu delay=%u\n", elapsed, work->delay);
// printf("work_process: in ticks elapsed=%lu delay=%u\n", elapsed, work->delay);
if (elapsed >= work->delay) {
/* Remove the ready-to-execute work from the list */
@@ -130,7 +130,7 @@ static void work_process(struct wqueue_s *wqueue, int lock_id)
*/
worker = work->worker;
arg = work->arg;
arg = work->arg;
/* Mark the work as no longer being queued */
@@ -155,7 +155,7 @@ static void work_process(struct wqueue_s *wqueue, int lock_id)
*/
work_lock(lock_id);
work = (struct work_s *)wqueue->q.head;
work = (struct work_s *)wqueue->q.head;
} else {
/* This one is not ready.. will it be ready before the next
@@ -188,8 +188,7 @@ static void work_process(struct wqueue_s *wqueue, int lock_id)
/****************************************************************************
* Public Functions
****************************************************************************/
void work_queues_init(void)
{
void work_queues_init(void) {
px4_sem_init(&_work_lock[HPWORK], 0, 1);
px4_sem_init(&_work_lock[LPWORK], 0, 1);
#ifdef CONFIG_SCHED_USRWORK
@@ -197,21 +196,12 @@ void work_queues_init(void)
#endif
// Create high priority worker thread
g_work[HPWORK].pid = px4_task_spawn_cmd("hpwork",
SCHED_DEFAULT,
SCHED_PRIORITY_MAX - 1,
2000,
work_hpthread,
g_work[HPWORK].pid = px4_task_spawn_cmd("hpwork", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 1, 2000, work_hpthread,
(char *const *)NULL);
// Create low priority worker thread
g_work[LPWORK].pid = px4_task_spawn_cmd("lpwork",
SCHED_DEFAULT,
SCHED_PRIORITY_MIN,
2000,
work_lpthread,
g_work[LPWORK].pid = px4_task_spawn_cmd("lpwork", SCHED_DEFAULT, SCHED_PRIORITY_MIN, 2000, work_lpthread,
(char *const *)NULL);
}
/****************************************************************************
@@ -247,8 +237,7 @@ void work_queues_init(void)
#ifdef CONFIG_SCHED_HPWORK
int work_hpthread(int argc, char *argv[])
{
int work_hpthread(int argc, char *argv[]) {
/* Loop forever */
for (;;) {
@@ -275,8 +264,7 @@ int work_hpthread(int argc, char *argv[])
#ifdef CONFIG_SCHED_LPWORK
int work_lpthread(int argc, char *argv[])
{
int work_lpthread(int argc, char *argv[]) {
/* Loop forever */
for (;;) {
@@ -287,7 +275,7 @@ int work_lpthread(int argc, char *argv[])
* the IDLE thread (at a very, very low priority).
*/
//sched_garbagecollection();
// sched_garbagecollection();
/* Then process queued work. We need to keep interrupts disabled while
* we process items in the work list.
@@ -304,8 +292,7 @@ int work_lpthread(int argc, char *argv[])
#ifdef CONFIG_SCHED_USRWORK
int work_usrthread(int argc, char *argv[])
{
int work_usrthread(int argc, char *argv[]) {
/* Loop forever */
int rv;
@@ -329,9 +316,8 @@ int work_usrthread(int argc, char *argv[])
#endif /* CONFIG_SCHED_USRWORK */
uint32_t clock_systimer()
{
//printf("clock_systimer: %0lx\n", hrt_absolute_time());
uint32_t clock_systimer() {
// printf("clock_systimer: %0lx\n", hrt_absolute_time());
return (0x00000000ffffffff & hrt_absolute_time());
}
#endif /* CONFIG_SCHED_WORKQUEUE */
@@ -37,14 +37,13 @@
*
* @author Mark Charlebois <charlebm@gmail.com>
*/
#include "wqueue_test.h"
#include <px4_platform_common/log.h>
#include <px4_platform_common/app.h>
#include <px4_platform_common/log.h>
#include <stdio.h>
int PX4_MAIN(int argc, char **argv)
{
#include "wqueue_test.h"
int PX4_MAIN(int argc, char **argv) {
px4::init(argc, argv, "wqueue_test");
PX4_INFO("wqueue hello\n");
@@ -37,41 +37,34 @@
* @author Thomas Gubler <thomasgubler@gmail.com>
* @author Mark Charlebois <mcharleb@gmail.com>
*/
#include "wqueue_test.h"
#include <px4_platform_common/app.h>
#include <px4_platform_common/log.h>
#include <px4_platform_common/tasks.h>
#include <sched.h>
#include <stdio.h>
#include <string.h>
#include <sched.h>
static int daemon_task; /* Handle of deamon task / thread */
#include "wqueue_test.h"
//using namespace px4;
static int daemon_task; /* Handle of deamon task / thread */
// using namespace px4;
extern "C" __EXPORT int wqueue_test_main(int argc, char *argv[]);
int wqueue_test_main(int argc, char *argv[])
{
int wqueue_test_main(int argc, char *argv[]) {
if (argc < 2) {
PX4_INFO("usage: wqueue_test {start|stop|status}\n");
return 1;
}
if (!strcmp(argv[1], "start")) {
if (WQueueTest::appState.isRunning()) {
PX4_INFO("already running\n");
/* this is not an error */
return 0;
}
daemon_task = px4_task_spawn_cmd("wqueue",
SCHED_DEFAULT,
SCHED_PRIORITY_MAX - 5,
2000,
PX4_MAIN,
daemon_task = px4_task_spawn_cmd("wqueue", SCHED_DEFAULT, SCHED_PRIORITY_MAX - 5, 2000, PX4_MAIN,
(argv) ? (char *const *)&argv[2] : (char *const *)nullptr);
return 0;
@@ -43,27 +43,24 @@
#include <px4_platform_common/time.h>
#include <px4_platform_common/workqueue.h>
#include <unistd.h>
#include <stdio.h>
#include <unistd.h>
px4::AppState WQueueTest::appState;
void WQueueTest::hp_worker_cb(void *p)
{
void WQueueTest::hp_worker_cb(void *p) {
WQueueTest *wqep = (WQueueTest *)p;
wqep->do_hp_work();
}
void WQueueTest::lp_worker_cb(void *p)
{
void WQueueTest::lp_worker_cb(void *p) {
WQueueTest *wqep = (WQueueTest *)p;
wqep->do_lp_work();
}
void WQueueTest::do_lp_work()
{
void WQueueTest::do_lp_work() {
static int iter = 0;
printf("done lp work\n");
@@ -76,8 +73,7 @@ void WQueueTest::do_lp_work()
work_queue(LPWORK, &_lpwork, (worker_t)&lp_worker_cb, this, 1000);
}
void WQueueTest::do_hp_work()
{
void WQueueTest::do_hp_work() {
static int iter = 0;
printf("done hp work\n");
@@ -91,18 +87,15 @@ void WQueueTest::do_hp_work()
work_queue(HPWORK, &_hpwork, (worker_t)&hp_worker_cb, this, 1000);
}
int WQueueTest::main()
{
int WQueueTest::main() {
appState.setRunning(true);
//Put work on HP work queue
// Put work on HP work queue
work_queue(HPWORK, &_hpwork, (worker_t)&hp_worker_cb, this, 1000);
//Put work on LP work queue
// Put work on LP work queue
work_queue(LPWORK, &_lpwork, (worker_t)&lp_worker_cb, this, 1000);
// Wait for work to finsh
while (!appState.exitRequested() && !(_hpwork_done && _lpwork_done)) {
printf(" Sleeping for 2 sec...\n");
@@ -43,8 +43,7 @@
#include <px4_platform_common/workqueue.h>
#include <string.h>
class WQueueTest
{
class WQueueTest {
public:
WQueueTest() = default;
~WQueueTest() = default;
@@ -59,8 +58,8 @@ private:
void do_lp_work(void);
void do_hp_work(void);
bool _lpwork_done {false};
bool _hpwork_done {false};
work_s _lpwork {};
work_s _hpwork {};
bool _lpwork_done{false};
bool _hpwork_done{false};
work_s _lpwork{};
work_s _hpwork{};
};