From fc6849afb9407ed913199b39a19fcbdd0f540d09 Mon Sep 17 00:00:00 2001 From: tarxvf Date: Mon, 4 Jul 2022 23:21:32 -0400 Subject: [PATCH] Fixed linux RTC driver to make it return UTC time instead of local one --- openrtx/include/interfaces/rtc.h | 4 ++-- platform/mcu/x86_64/drivers/rtc.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openrtx/include/interfaces/rtc.h b/openrtx/include/interfaces/rtc.h index ae4baca1..874d5321 100644 --- a/openrtx/include/interfaces/rtc.h +++ b/openrtx/include/interfaces/rtc.h @@ -43,7 +43,7 @@ void rtc_terminate(); /** * Set RTC time and calendar registers to a given value. - * @param t: struct of type curTime_t, whose content is used to initialise both + * @param t: struct of type datetime_t, whose content is used to initialise both * clock and calendar registers. */ void rtc_setTime(datetime_t t); @@ -66,7 +66,7 @@ void rtc_setDate(uint8_t date, uint8_t month, uint8_t year); /** * Get current date and time. - * @return structure of type curTime_t with current clock and calendar values. + * @return structure of type datetime_t with current clock and calendar values. */ datetime_t rtc_getTime(); diff --git a/platform/mcu/x86_64/drivers/rtc.c b/platform/mcu/x86_64/drivers/rtc.c index 5f121588..b02e5ddc 100644 --- a/platform/mcu/x86_64/drivers/rtc.c +++ b/platform/mcu/x86_64/drivers/rtc.c @@ -55,7 +55,8 @@ datetime_t rtc_getTime() time_t rawtime; struct tm * timeinfo; time ( &rawtime ); - timeinfo = localtime ( &rawtime ); + timeinfo = gmtime ( &rawtime ); + //radio expects time to be TZ-less, so use gmtime instead of localtime. t.hour = timeinfo->tm_hour; t.minute = timeinfo->tm_min;