|
@@ -126,6 +126,12 @@
|
|
|
#define M_PI 3.14159265358979323846
|
|
#define M_PI 3.14159265358979323846
|
|
|
#endif
|
|
#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
|
|
#else
|
|
|
/* ========== EMBEDDED BUILD CONFIGURATION ========== */
|
|
/* ========== EMBEDDED BUILD CONFIGURATION ========== */
|
|
|
|
|
|
|
@@ -157,109 +163,17 @@
|
|
|
#define VI_LVH 3.4
|
|
#define VI_LVH 3.4
|
|
|
#define VI_MULT (3.3 / 6.6 / 2.495 * 1024)
|
|
#define VI_MULT (3.3 / 6.6 / 2.495 * 1024)
|
|
|
|
|
|
|
|
-/* Configuration flags */
|
|
|
|
|
-#define CONFFLAG_DISABLE_FILTERS 0x01
|
|
|
|
|
-#define CONFFLAG_ENABLE_SBAS 0x02
|
|
|
|
|
-#define CONFFLAG_AUTO_PAUSE 0x04
|
|
|
|
|
-#define CONFFLAG_VERBOSE_LOG 0x08
|
|
|
|
|
-#define CONFFLAG_RESET_ON_NEW_FILE 0x10
|
|
|
|
|
-
|
|
|
|
|
-/* Reject reasons (see soft/syslog.h) */
|
|
|
|
|
-#define REJECT_REASON_KALMAN 0
|
|
|
|
|
-#define REJECT_REASON_DISTDIFF 1
|
|
|
|
|
-#define REJECT_REASON_MINDIST 2
|
|
|
|
|
-
|
|
|
|
|
-/* UART log mode (see soft/settings.h) */
|
|
|
|
|
-#define UART_LOG_MODE_MIXED 0
|
|
|
|
|
-#define UART_LOG_MODE_NMEA 1
|
|
|
|
|
-#define UART_LOG_MODE_SYSTEM 2
|
|
|
|
|
-
|
|
|
|
|
-/* Fix type (see soft/main.h) */
|
|
|
|
|
-#define FIX_TYPE_UNKNOWN 0
|
|
|
|
|
-#define FIX_TYPE_2D 2
|
|
|
|
|
-#define FIX_TYPE_3D 3
|
|
|
|
|
-
|
|
|
|
|
-/* GNSS modes */
|
|
|
|
|
-#define GNSS_MODE_GPS_GLONASS_GALILEO 0
|
|
|
|
|
-#define GNSS_MODE_GPS 1
|
|
|
|
|
-#define GNSS_MODE_GPS_GALILEO 2
|
|
|
|
|
-#define GNSS_MODE_GALILEO 3
|
|
|
|
|
-#define GNSS_MODE_GPS_BEIDOU 4
|
|
|
|
|
-#define GNSS_MODE_BEIDOU 5
|
|
|
|
|
-
|
|
|
|
|
-/* GPS initialization states */
|
|
|
|
|
|
|
+/* GPS initialization states (PC-build value only - GPS_INIT_INITIALIZED
|
|
|
|
|
+ * doesn't exist here, this tool has no real GPS module init sequence) */
|
|
|
#define GPS_INIT_NOT_INITIALIZED 0
|
|
#define GPS_INIT_NOT_INITIALIZED 0
|
|
|
#define GPS_INIT_QUERY_SENT 1
|
|
#define GPS_INIT_QUERY_SENT 1
|
|
|
|
|
|
|
|
-/* Location validity states */
|
|
|
|
|
-#define LOC_INVALID 0
|
|
|
|
|
-#define LOC_VALID_NEW 1
|
|
|
|
|
-#define LOC_VALID 2
|
|
|
|
|
-
|
|
|
|
|
-/* Configuration structure */
|
|
|
|
|
-struct config_s {
|
|
|
|
|
- unsigned char skip_points;
|
|
|
|
|
- unsigned char auto_pause_dist;
|
|
|
|
|
- unsigned char auto_pause_time;
|
|
|
|
|
- unsigned char auto_pause_speed;
|
|
|
|
|
- unsigned char gnss_mode;
|
|
|
|
|
- unsigned char min_sat;
|
|
|
|
|
- unsigned char min_sats; /* Alias for compatibility */
|
|
|
|
|
- unsigned char uart_log_mode;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-/* System structure */
|
|
|
|
|
-struct system_s {
|
|
|
|
|
- struct config_s conf;
|
|
|
|
|
- unsigned long int distance; /* cm */
|
|
|
|
|
- unsigned long int elevation_gain; /* dm (decimeters, 0.1m resolution); filtered */
|
|
|
|
|
- unsigned long int elevation_loss; /* dm; filtered */
|
|
|
|
|
- unsigned long int elevation_gain_raw; /* dm; unfiltered, for comparison only */
|
|
|
|
|
- unsigned long int elevation_loss_raw; /* dm; unfiltered, for comparison only */
|
|
|
|
|
- unsigned long int alt_max; /* dm; highest smoothed altitude seen */
|
|
|
|
|
- unsigned long int points_written;
|
|
|
|
|
- unsigned long int rejected_count;
|
|
|
|
|
- unsigned long int speed_accum_x100;
|
|
|
|
|
- unsigned long int speed_sample_count;
|
|
|
|
|
- unsigned int hdop_x100;
|
|
|
|
|
- unsigned char fix_type;
|
|
|
|
|
- unsigned char speed; /* km/h */
|
|
|
|
|
- float bat_volt;
|
|
|
|
|
- float bat_volt_min;
|
|
|
|
|
- float temperature;
|
|
|
|
|
- unsigned char temperature_ok;
|
|
|
|
|
- time_t time_start;
|
|
|
|
|
- time_t current_pause_start;
|
|
|
|
|
- time_t pause_time;
|
|
|
|
|
- unsigned tracking_paused:1;
|
|
|
|
|
- unsigned tracking_auto_paused:1;
|
|
|
|
|
- unsigned gps_initialized:2;
|
|
|
|
|
- unsigned gps_only:1;
|
|
|
|
|
- unsigned keypress:1;
|
|
|
|
|
- unsigned location_valid:2;
|
|
|
|
|
- unsigned sat_count_low:1;
|
|
|
|
|
- unsigned sbas:1;
|
|
|
|
|
- unsigned satellites_used:5;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-/* Location structure */
|
|
|
|
|
-struct location_s {
|
|
|
|
|
- float lon;
|
|
|
|
|
- float lat;
|
|
|
|
|
- float alt;
|
|
|
|
|
- time_t time;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-/* Must match soft/autopause.h exactly: soft/autopause.c is compiled into
|
|
|
|
|
- * this tool too (see autopause_wrapper.c). */
|
|
|
|
|
-struct auto_pause_s {
|
|
|
|
|
- unsigned char point_counter;
|
|
|
|
|
- unsigned long int prev_distance;
|
|
|
|
|
- unsigned char speed_counter;
|
|
|
|
|
- struct location_s pause_anchor;
|
|
|
|
|
- unsigned int anchor_sample_count;
|
|
|
|
|
- unsigned char resume_high_history;
|
|
|
|
|
-};
|
|
|
|
|
|
|
+/* struct system_s/location_s/config_s/auto_pause_s and the value constants
|
|
|
|
|
+ * their fields hold are in soft/common.h - shared byte-for-byte with the
|
|
|
|
|
+ * embedded build, since gpx.c/nmea.c/syslog.c/autopause.c (soft/) compile
|
|
|
|
|
+ * unmodified into this tool too (see the *_wrapper.c files). */
|
|
|
|
|
+#include "../soft/common.h"
|
|
|
|
|
+
|
|
|
extern struct auto_pause_s auto_pause;
|
|
extern struct auto_pause_s auto_pause;
|
|
|
|
|
|
|
|
/* Global variables */
|
|
/* Global variables */
|
|
@@ -267,11 +181,22 @@ extern volatile struct system_s System;
|
|
|
extern struct location_s location;
|
|
extern struct location_s location;
|
|
|
extern time_t utc;
|
|
extern time_t utc;
|
|
|
|
|
|
|
|
-/* Configuration flags */
|
|
|
|
|
-extern unsigned char config_flags;
|
|
|
|
|
|
|
+/* Kept in sync with soft/settings.c's get_flag()/set_flag(): System.conf.flags
|
|
|
|
|
+ * is part of struct config_s in common.h, and CONFFLAG_* there is a bit
|
|
|
|
|
+ * index (not a pre-shifted mask), so this must index the same way - not the
|
|
|
|
|
+ * config_flags-bitmask scheme this used to have, which numbered its flags
|
|
|
|
|
+ * differently (and didn't have all of them), a silent mismatch from
|
|
|
|
|
+ * embedded's real indices that a shared header can't paper over unless both
|
|
|
|
|
+ * sides actually agree on what a CONFFLAG_* value means. */
|
|
|
|
|
+static inline unsigned char get_flag(unsigned char index) {
|
|
|
|
|
+ return System.conf.flags[index/8] & (1 << (index % 8));
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
-static inline unsigned char get_flag(unsigned char flag) {
|
|
|
|
|
- return (config_flags & flag) ? 1 : 0;
|
|
|
|
|
|
|
+static inline void set_flag(unsigned char index, unsigned char val) {
|
|
|
|
|
+ if (val)
|
|
|
|
|
+ System.conf.flags[index/8] |= (1 << (index % 8));
|
|
|
|
|
+ else
|
|
|
|
|
+ System.conf.flags[index/8] &= ~(1 << (index % 8));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* soft/main.c's helpers, reimplemented here: soft/main.c itself isn't part
|
|
/* soft/main.c's helpers, reimplemented here: soft/main.c itself isn't part
|
|
@@ -283,11 +208,33 @@ static inline unsigned char tracking_is_paused(void) {
|
|
|
return System.tracking_paused || System.tracking_auto_paused;
|
|
return System.tracking_paused || System.tracking_auto_paused;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* Kept in sync with soft/main.c's pause_time_start()/pause_time_end()/
|
|
|
|
|
+ * get_pause_time(): call the start/end function exactly once, at the moment
|
|
|
|
|
+ * a pause actually begins/ends (not deferred to the next accepted point,
|
|
|
|
|
+ * which may never come before the pause ends, or may come from a much
|
|
|
|
|
+ * later, unrelated pause) - see soft/main.c for the full rationale. */
|
|
|
|
|
+static inline void pause_time_start(void) {
|
|
|
|
|
+ System.current_pause_start = utc;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static inline void pause_time_end(void) {
|
|
|
|
|
+ if (System.current_pause_start && System.current_pause_start >= System.time_start)
|
|
|
|
|
+ System.pause_time += utc - System.current_pause_start;
|
|
|
|
|
+ System.current_pause_start = 0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Kept in sync with soft/main.c's fix_gap_detected() - see there for the
|
|
|
|
|
+ * full rationale. */
|
|
|
|
|
+static inline unsigned char fix_gap_detected(time_t point_time) {
|
|
|
|
|
+ static time_t last_point_time = 0;
|
|
|
|
|
+ unsigned char gap = last_point_time && point_time - last_point_time > 3;
|
|
|
|
|
+ last_point_time = point_time;
|
|
|
|
|
+ return gap;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static inline time_t get_pause_time(void) {
|
|
static inline time_t get_pause_time(void) {
|
|
|
time_t res = System.pause_time;
|
|
time_t res = System.pause_time;
|
|
|
- if (System.current_pause_start < System.time_start)
|
|
|
|
|
- System.current_pause_start = System.time_start;
|
|
|
|
|
- if (is_paused() && System.current_pause_start)
|
|
|
|
|
|
|
+ if (is_paused() && System.current_pause_start && System.current_pause_start >= System.time_start)
|
|
|
res += utc - System.current_pause_start;
|
|
res += utc - System.current_pause_start;
|
|
|
return res;
|
|
return res;
|
|
|
}
|
|
}
|
|
@@ -335,7 +282,7 @@ void log_boot_record(void);
|
|
|
void log_status_line(void);
|
|
void log_status_line(void);
|
|
|
void log_fix_event(void);
|
|
void log_fix_event(void);
|
|
|
void log_fix_lost(void);
|
|
void log_fix_lost(void);
|
|
|
-void log_sbas_transition(void);
|
|
|
|
|
|
|
+void log_dgps_transition(void);
|
|
|
void log_session_summary(unsigned char final);
|
|
void log_session_summary(unsigned char final);
|
|
|
void log_pause_event(unsigned char started);
|
|
void log_pause_event(unsigned char started);
|
|
|
void gps_powered_on(void);
|
|
void gps_powered_on(void);
|
|
@@ -345,6 +292,7 @@ void gps_powered_on(void);
|
|
|
* of what this tool's output looks like. It calls beep(), which is
|
|
* of what this tool's output looks like. It calls beep(), which is
|
|
|
* meaningless on PC and stubbed out here. */
|
|
* meaningless on PC and stubbed out here. */
|
|
|
void auto_pause_process(void);
|
|
void auto_pause_process(void);
|
|
|
|
|
+void auto_pause_reset_gap(void);
|
|
|
unsigned char gps_fix_trustworthy(void);
|
|
unsigned char gps_fix_trustworthy(void);
|
|
|
static inline void beep(unsigned int len, unsigned char cnt) { (void)len; (void)cnt; }
|
|
static inline void beep(unsigned int len, unsigned char cnt) { (void)len; (void)cnt; }
|
|
|
|
|
|