mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-09 03:02:36 +08:00
POSIX SIM: Reset the HRT on system boot
This commit is contained in:
@@ -40,6 +40,8 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
extern "C" __EXPORT hrt_abstime hrt_reset(void);
|
||||
|
||||
#define SEND_INTERVAL 20
|
||||
#define UDP_PORT 14560
|
||||
#define PIXHAWK_DEVICE "/dev/ttyACM0"
|
||||
@@ -406,6 +408,8 @@ void Simulator::pollForMAVLinkMessages(bool publish)
|
||||
}
|
||||
PX4_WARN("Found initial message, pret = %d",pret);
|
||||
_initialized = true;
|
||||
// reset system time
|
||||
(void)hrt_reset();
|
||||
|
||||
if (fds[0].revents & POLLIN) {
|
||||
len = recvfrom(_fd, _buf, sizeof(_buf), 0, (struct sockaddr *)&_srcaddr, &_addrlen);
|
||||
|
||||
@@ -66,6 +66,8 @@ static hrt_abstime px4_timestart = 0;
|
||||
static void
|
||||
hrt_call_invoke(void);
|
||||
|
||||
__EXPORT hrt_abstime hrt_reset(void);
|
||||
|
||||
static void hrt_lock(void)
|
||||
{
|
||||
//printf("hrt_lock\n");
|
||||
@@ -128,6 +130,12 @@ hrt_abstime hrt_absolute_time(void)
|
||||
return ts_to_abstime(&ts) - px4_timestart;
|
||||
}
|
||||
|
||||
__EXPORT hrt_abstime hrt_reset(void)
|
||||
{
|
||||
px4_timestart = 0;
|
||||
return hrt_absolute_time();
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a timespec to absolute time.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user