POSIX: get px4_poll right

Like this the timeouts are going through instead of hanging everything.
This commit is contained in:
Julian Oes 2016-02-11 18:02:46 +01:00
parent 9e77f554d2
commit b2ad3f5fbd
2 changed files with 6 additions and 2 deletions

View File

@ -314,7 +314,7 @@ extern "C" {
// Get the current time
struct timespec ts;
px4_clock_gettime(CLOCK_REALTIME, &ts);
px4_clock_gettime(CLOCK_MONOTONIC, &ts);
// Calculate an absolute time in the future
const unsigned billion = (1000 * 1000 * 1000);

View File

@ -371,8 +371,12 @@ int px4_sem_timedwait(px4_sem_t *sem, const struct timespec *ts)
{
work_s _hpwork = {};
// Get the current time.
struct timespec ts_now;
px4_clock_gettime(CLOCK_MONOTONIC, &ts_now);
// We get an absolute time but want to calculate a timeout in us.
hrt_abstime timeout_us = ts_to_abstime((struct timespec *)ts) - hrt_absolute_time();
hrt_abstime timeout_us = ts_to_abstime((struct timespec *)ts) - ts_to_abstime(&ts_now);
// Create a timer to unblock.
hrt_work_queue(&_hpwork, (worker_t)&timer_cb, (void *)sem, timeout_us);