From 0ba2caaf61428ce2e517fc5b17cb444810ef38ee Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Mar 2022 16:53:05 +0200 Subject: [PATCH] set the time in the code directly now --- linux/devices/GPSHyperionLinuxController.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index a811fbc5..7ebff478 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -9,6 +9,7 @@ #include #endif #include +#include GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId, bool debugHyperionGps) @@ -172,6 +173,8 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { timeval time = {}; time.tv_sec = gpsSet.unixSeconds.value; time.tv_usec = gps->fix.time.tv_nsec / 1000; + // Update the system time here for now. NTP seems to be unable to do so for whatever reason + settimeofday(&time, nullptr); Clock::TimeOfDay_t timeOfDay = {}; Clock::convertTimevalToTimeOfDay(&time, &timeOfDay); gpsSet.year = timeOfDay.year; @@ -192,6 +195,9 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { std::cout << "Longitude: " << gps->fix.longitude << std::endl; std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl; std::cout << "Speed(m/s): " << gps->fix.speed << std::endl; + std::time_t t = std::time(nullptr); + std::tm tm = *std::gmtime(&t); + std::cout << "C Time: " << std::put_time(&tm, "%c") << std::endl; } } #endif