Selaa lähdekoodia

gps-test-tool: fix mktime() applying local TZ to UTC NMEA timestamps

libc's mktime() treats struct tm as local time, but NMEA RMC time
fields are UTC. On a machine with a non-UTC TZ this silently shifted
every timestamp derived from utc (GPX <time>, debug/syslog lines) by
the local offset. Redirect to timegm() (ignores TZ) to match the
embedded build's own UTC-only stime.S mktime().
k4be 1 viikko sitten
vanhempi
commit
5a76b3c919
1 muutettua tiedostoa jossa 7 lisäystä ja 0 poistoa
  1. 7 0
      gps-test-tool/main.h

+ 7 - 0
gps-test-tool/main.h

@@ -126,6 +126,12 @@
     #define M_PI 3.14159265358979323846
     #endif
 
+    /* NMEA time fields are UTC. The embedded build's stime.S mktime() is a
+     * UTC-only conversion (no TZ/DST concept), but libc's mktime() treats
+     * struct tm as local time and applies TZ - redirect to timegm() (POSIX/
+     * glibc/BSD extension, ignores TZ) so the PC build matches. */
+    #define mktime timegm
+
 #else
     /* ========== EMBEDDED BUILD CONFIGURATION ========== */
 
@@ -168,6 +174,7 @@
 #define REJECT_REASON_KALMAN     0
 #define REJECT_REASON_DISTDIFF   1
 #define REJECT_REASON_MINDIST    2
+#define REJECT_REASON_ALTDIFF    3
 
 /* UART log mode (see soft/settings.h) */
 #define UART_LOG_MODE_MIXED     0