From b2ad3f5fbd4744ee817cdac68fe54d03ab69888d Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 11 Feb 2016 18:02:46 +0100 Subject: [PATCH] POSIX: get px4_poll right Like this the timeouts are going through instead of hanging everything. --- src/drivers/device/vdev_posix.cpp | 2 +- src/platforms/qurt/px4_layer/px4_qurt_tasks.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/drivers/device/vdev_posix.cpp b/src/drivers/device/vdev_posix.cpp index 2f8f8fb024..7d4a7ce338 100644 --- a/src/drivers/device/vdev_posix.cpp +++ b/src/drivers/device/vdev_posix.cpp @@ -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); diff --git a/src/platforms/qurt/px4_layer/px4_qurt_tasks.cpp b/src/platforms/qurt/px4_layer/px4_qurt_tasks.cpp index b603a2ed5a..1edcfc9eab 100644 --- a/src/platforms/qurt/px4_layer/px4_qurt_tasks.cpp +++ b/src/platforms/qurt/px4_layer/px4_qurt_tasks.cpp @@ -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);