mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 01:18:29 -04:00
HAL_Linux: Add set_system_clock
This commit is contained in:
parent
d679831c75
commit
974f243c7e
@ -5,6 +5,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
@ -50,4 +51,13 @@ void LinuxUtil::_toneAlarm_timer_tick(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinuxUtil::set_system_clock(uint64_t time_utc_usec)
|
||||||
|
{
|
||||||
|
timespec ts;
|
||||||
|
ts.tv_sec = time_utc_usec/1.0e6;
|
||||||
|
ts.tv_nsec = (time_utc_usec % 1000000) * 1000;
|
||||||
|
clock_settime(CLOCK_REALTIME, &ts);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
#endif // CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||||
|
@ -26,6 +26,11 @@ public:
|
|||||||
|
|
||||||
void _toneAlarm_timer_tick();
|
void _toneAlarm_timer_tick();
|
||||||
|
|
||||||
|
/*
|
||||||
|
set system clock in UTC microseconds
|
||||||
|
*/
|
||||||
|
void set_system_clock(uint64_t time_utc_usec);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Linux::ToneAlarm _toneAlarm;
|
static Linux::ToneAlarm _toneAlarm;
|
||||||
int saved_argc;
|
int saved_argc;
|
||||||
|
Loading…
Reference in New Issue
Block a user