HAL_Linux: Add set_system_clock

This commit is contained in:
Víctor Mayoral Vilches 2015-01-19 18:30:18 +01:00 committed by Andrew Tridgell
parent d679831c75
commit 974f243c7e
2 changed files with 15 additions and 0 deletions

View File

@ -5,6 +5,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
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

View File

@ -26,6 +26,11 @@ public:
void _toneAlarm_timer_tick();
/*
set system clock in UTC microseconds
*/
void set_system_clock(uint64_t time_utc_usec);
private:
static Linux::ToneAlarm _toneAlarm;
int saved_argc;