mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-25 16:03:33 +08:00
Replacing usleep with px4_usleep
This is a step towards isolating time from the system.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
/* definitions of builtin command list - automatically generated, do not edit */
|
||||
#include "px4_time.h"
|
||||
#include "px4_posix.h"
|
||||
#include "px4_log.h"
|
||||
|
||||
@@ -86,7 +87,7 @@ int sleep_main(int argc, char *argv[])
|
||||
|
||||
unsigned long usecs = 1000000UL * atol(argv[1]);
|
||||
printf("Sleeping for %s s; (%lu us).\n", argv[1], usecs);
|
||||
usleep(usecs);
|
||||
px4_usleep(usecs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ static void hrt_work_process()
|
||||
|
||||
/* might sleep less if a signal received and new item was queued */
|
||||
//PX4_INFO("Sleeping for %u usec", next);
|
||||
usleep(next);
|
||||
px4_usleep(next);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -182,7 +182,7 @@ static void work_process(struct wqueue_s *wqueue, int lock_id)
|
||||
*/
|
||||
work_unlock(lock_id);
|
||||
|
||||
usleep(next);
|
||||
px4_usleep(next);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <px4_time.h>
|
||||
#include <px4_log.h>
|
||||
#include <px4_tasks.h>
|
||||
#include <systemlib/px4_macros.h>
|
||||
@@ -236,7 +237,7 @@ public:
|
||||
|
||||
do {
|
||||
unlock_module();
|
||||
usleep(20000); // 20 ms
|
||||
px4_usleep(20000); // 20 ms
|
||||
lock_module();
|
||||
|
||||
if (++i > 100 && _task_id != -1) { // wait at most 2 sec
|
||||
@@ -369,7 +370,7 @@ protected:
|
||||
|
||||
do {
|
||||
/* Wait up to 1s. */
|
||||
usleep(2500);
|
||||
px4_usleep(2500);
|
||||
|
||||
} while (!_object && ++i < 400);
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#pragma once
|
||||
|
||||
/* includes for all platforms */
|
||||
#include "px4_time.h"
|
||||
#include "px4_subscriber.h"
|
||||
#include "px4_publisher.h"
|
||||
#include "px4_middleware.h"
|
||||
@@ -274,7 +275,7 @@ public:
|
||||
|
||||
/* Only continue in the loop if the nodehandle has subscriptions */
|
||||
if (_sub_min_interval == nullptr) {
|
||||
usleep(timeout_ms * 1000);
|
||||
px4_usleep(timeout_ms * 1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,4 +34,6 @@ __END_DECLS
|
||||
#define px4_clock_gettime clock_gettime
|
||||
#define px4_clock_settime clock_settime
|
||||
|
||||
#define px4_usleep system_usleep
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user