mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 03:43:35 +08:00
POSIX: Critical fix for vdev_posix
Last fix for vdev_posix.cpp introduced a sleep from within a HRT work item callback which blocks the HRT queue. The code in uORBDevices_posix.cpp that handles message throttling was commented out for posix. The code was re-enabled and now seems to work. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -54,24 +54,10 @@ using namespace device;
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
struct timerData {
|
|
||||||
sem_t &sem;
|
|
||||||
struct timespec &ts;
|
|
||||||
|
|
||||||
timerData(sem_t &s, struct timespec &t) : sem(s), ts(t) {}
|
|
||||||
~timerData() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void timer_cb(void *data)
|
static void timer_cb(void *data)
|
||||||
{
|
{
|
||||||
struct timerData *td = (struct timerData *)data;
|
sem_t *p_sem = (sem_t *)data;
|
||||||
|
sem_post(p_sem);
|
||||||
if (td->ts.tv_sec) {
|
|
||||||
sleep(td->ts.tv_sec);
|
|
||||||
}
|
|
||||||
usleep(td->ts.tv_nsec/1000);
|
|
||||||
sem_post(&(td->sem));
|
|
||||||
|
|
||||||
PX4_DEBUG("timer_handler: Timer expired");
|
PX4_DEBUG("timer_handler: Timer expired");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +197,6 @@ int px4_poll(px4_pollfd_struct_t *fds, nfds_t nfds, int timeout)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
int ret;
|
int ret;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct timespec ts;
|
|
||||||
|
|
||||||
PX4_DEBUG("Called px4_poll timeout = %d", timeout);
|
PX4_DEBUG("Called px4_poll timeout = %d", timeout);
|
||||||
sem_init(&sem, 0, 0);
|
sem_init(&sem, 0, 0);
|
||||||
@@ -242,8 +227,7 @@ int px4_poll(px4_pollfd_struct_t *fds, nfds_t nfds, int timeout)
|
|||||||
// Use a work queue task
|
// Use a work queue task
|
||||||
work_s _hpwork;
|
work_s _hpwork;
|
||||||
|
|
||||||
struct timerData td(sem, ts);
|
hrt_work_queue(&_hpwork, (worker_t)&timer_cb, (void *)&sem, 1000*timeout);
|
||||||
hrt_work_queue(&_hpwork, (worker_t)&timer_cb, (void *)&td, 1000*timeout);
|
|
||||||
sem_wait(&sem);
|
sem_wait(&sem);
|
||||||
|
|
||||||
// Make sure timer thread is killed before sem goes
|
// Make sure timer thread is killed before sem goes
|
||||||
|
|||||||
@@ -421,10 +421,6 @@ uORB::DeviceNode::appears_updated(SubscriberData *sd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME - the calls to hrt_called and hrt_call_after seem not to work in the
|
|
||||||
// POSIX build
|
|
||||||
#ifndef __PX4_POSIX
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the interval timer is still running, the topic should not
|
* If the interval timer is still running, the topic should not
|
||||||
* appear updated, even though at this point we know that it has.
|
* appear updated, even though at this point we know that it has.
|
||||||
@@ -445,7 +441,6 @@ uORB::DeviceNode::appears_updated(SubscriberData *sd)
|
|||||||
sd->update_interval,
|
sd->update_interval,
|
||||||
&uORB::DeviceNode::update_deferred_trampoline,
|
&uORB::DeviceNode::update_deferred_trampoline,
|
||||||
(void *)this);
|
(void *)this);
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remember that we have told the subscriber that there is data.
|
* Remember that we have told the subscriber that there is data.
|
||||||
|
|||||||
Reference in New Issue
Block a user