From f850dbdc45537ce9c18241ae5581be2538bc1a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Izzo?= Date: Mon, 15 Feb 2021 09:26:13 +0100 Subject: [PATCH] Add GPS RTC time synchronization, remove debug prints --- openrtx/src/gps.c | 2 +- openrtx/src/threads.c | 35 ++++------------------------------- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/openrtx/src/gps.c b/openrtx/src/gps.c index 56da713a..e64b6e2f 100644 --- a/openrtx/src/gps.c +++ b/openrtx/src/gps.c @@ -36,7 +36,7 @@ void gps_taskFunc(char *line, int len, gps_t *state) state->longitude = minmea_tocoord(&frame.longitude); state->timestamp.hour = frame.time.hours; state->timestamp.minute = frame.time.minutes; - state->timestamp.second = frame.time.seconds; + state->timestamp.second = frame.time.seconds - 1; state->timestamp.day = 0; state->timestamp.date = frame.date.day; state->timestamp.month = frame.date.month; diff --git a/openrtx/src/threads.c b/openrtx/src/threads.c index 8f36f806..5db343b7 100644 --- a/openrtx/src/threads.c +++ b/openrtx/src/threads.c @@ -321,39 +321,12 @@ static void gps_task(void *arg) // GPS readout is blocking, no need to delay here gps_taskFunc(line, len, &state.gps_data); + // Synchronize RTC with GPS UTC clock + if(state.settings.gps_set_time) + rtc_setTime(state.gps_data.timestamp); + // Unlock state mutex OSMutexPost(&state_mutex, OS_OPT_POST_NONE, &os_err); - - // Debug prints - //printf("Timestamp: %d:%d:%d %d/%d/%d\n\r", - // state.gps_data.timestamp.hour, - // state.gps_data.timestamp.minute, - // state.gps_data.timestamp.second, - // state.gps_data.timestamp.date, - // state.gps_data.timestamp.month, - // state.gps_data.timestamp.year); - //printf("Fix quality: %d - %d\n\r", - // state.gps_data.fix_quality, - // state.gps_data.fix_type); - //printf("Satellites tracked: %d/%d\n\r", - // state.gps_data.satellites_tracked, - // state.gps_data.satellites_in_view); - //for(int i = 0; i < state.gps_data.satellites_in_view; i++) - //{ - // printf("%d - elevation: %d azimuth: %d snr: %d\n\r", - // state.gps_data.satellites[i].id, - // state.gps_data.satellites[i].elevation, - // state.gps_data.satellites[i].azimuth, - // state.gps_data.satellites[i].snr); - //} - //printf("Coordinates: %f %f\n\r", - // state.gps_data.latitude, - // state.gps_data.longitude); - //printf("Speed: %f km/h TMGM: %f deg TMGT: %f deg\n\r", - // state.gps_data.speed, - // state.gps_data.tmg_mag, - // state.gps_data.tmg_true); - //printf("\n\r\n\r"); } } }