AP_HAL_SITL: Force the simulated gps time to be on valid intervals for u-blox hardware

This commit is contained in:
Michael du Breuil 2016-02-24 15:36:44 -07:00 committed by Andrew Tridgell
parent b8fc524954
commit 287a3367ad
1 changed files with 3 additions and 1 deletions

View File

@ -162,7 +162,9 @@ static void gps_time(uint16_t *time_week, uint32_t *time_week_ms)
const uint32_t epoch = 86400*(10*365 + (1980-1969)/4 + 1 + 6 - 2) - 15; const uint32_t epoch = 86400*(10*365 + (1980-1969)/4 + 1 + 6 - 2) - 15;
uint32_t epoch_seconds = tv.tv_sec - epoch; uint32_t epoch_seconds = tv.tv_sec - epoch;
*time_week = epoch_seconds / (86400*7UL); *time_week = epoch_seconds / (86400*7UL);
*time_week_ms = (epoch_seconds % (86400*7UL))*1000 + tv.tv_usec/1000; uint32_t t_ms = tv.tv_usec / 1000;
// round time to nearest 200ms
*time_week_ms = (epoch_seconds % (86400*7UL))*1000 + ((t_ms/200) * 200);
} }
/* /*