Pārlūkot izejas kodu

add soft/common.h to stop duplicating structs between builds

struct system_s/location_s/config_s/auto_pause_s, and the value
constants their fields hold, were maintained as separate, hand-synced
copies in soft/main.h (embedded) and gps-test-tool/main.h (PC test
tool) - every field added to one needed a matching edit to the other,
and this session hit that gap repeatedly (missing fields causing build
failures, a stale REJECT_REASON_ALTDIFF, etc). Move the shared
definitions into a new soft/common.h both sides include.

While consolidating, found two real, silent mismatches this had
already caused:
- CONFFLAG_* meant different things on each side: embedded's
  get_flag()/set_flag() (settings.c) treat the value as a bit index
  into System.conf.flags[4], but the PC build's get_flag() treated it
  as an already-shifted bitmask, with its own separately-numbered
  constants that didn't include CONFFLAG_LOGGING_AFTER_BOOT - shifting
  every flag after it out of alignment with embedded's real indices.
  Rewrote the PC build's get_flag()/set_flag() to index
  System.conf.flags the same way as embedded, and dropped the
  redundant config_flags global.
- LOC_VALID/LOC_VALID_NEW were swapped (1/2 vs 2/1) between the two
  copies - harmless only because both sides always compared by name,
  never by raw value.

Also removed gps-test-tool/avr_compat.h, an unused, out-of-date
predecessor of the same idea (nothing included it - confirmed via
grep - so it had drifted independently and silently for a while).
k4be 1 nedēļu atpakaļ
vecāks
revīzija
a8bbc3b3f4

+ 1 - 1
gps-test-tool/Makefile

@@ -27,7 +27,7 @@ $(TEST_MALFORMED): $(TEST_MALFORMED_OBJECTS)
 run-test-malformed: $(TEST_MALFORMED)
 	./$(TEST_MALFORMED) malformed_test.nmea
 
-%.o: %.c avr_compat.h
+%.o: %.c
 	$(CC) $(CFLAGS) -c $< -o $@
 
 clean:

+ 0 - 117
gps-test-tool/avr_compat.h

@@ -1,117 +0,0 @@
-#pragma once
-/*
- * AVR Compatibility Layer for PC compilation
- * Provides AVR types, macros, and functions for x86/x64 hosts
- */
-
-/* Prevent AVR-specific headers from being included */
-#define _AVR_PGMSPACE_H_ 1
-#define _AVR_IO_H_ 1
-#define _AVR_WDT_H_ 1
-#define _AVR_SLEEP_H_ 1
-
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <time.h>
-#include <math.h>
-
-/* AVR type definitions - on PC, these are already correct */
-/* No need to redefine built-in types */
-
-/* PROGMEM/Flash support - on PC everything is in RAM */
-#define PROGMEM
-#define __flash
-#define PSTR(s) (s)
-#define strcpy_P strcpy
-#define strcat_P strcat
-/* xprintf functions are implemented in gpx_wrapper.c and nmea_wrapper.c */
-
-/* FatFS types stub */
-typedef struct {
-    FILE *fp;
-    char filename[256];
-} FIL;
-
-typedef uint32_t DWORD;
-typedef unsigned int UINT;
-
-/* FatFS function stubs */
-#define FA_WRITE 0x02
-#define FA_OPEN_ALWAYS 0x10
-
-static inline unsigned char f_open(FIL *file, const char *path, unsigned char mode) {
-    (void)mode;
-    file->fp = fopen(path, "w");
-    if (file->fp) {
-        strncpy(file->filename, path, sizeof(file->filename) - 1);
-        return 0;
-    }
-    return 1;
-}
-
-static inline unsigned char f_write(FIL *file, const void *buf, unsigned int len, unsigned int *written) {
-    if (!file->fp) return 1;
-    *written = fwrite(buf, 1, len, file->fp);
-    return (*written == len) ? 0 : 1;
-}
-
-static inline unsigned char f_close(FIL *file) {
-    if (file->fp) {
-        fclose(file->fp);
-        file->fp = NULL;
-        return 0;
-    }
-    return 1;
-}
-
-/* Math functions */
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-/* AVR interrupt stubs */
-#define cli()
-#define sei()
-
-/* System structure - simplified for PC testing */
-struct config_s {
-    unsigned char skip_points;
-    unsigned char auto_pause_dist;
-};
-
-struct system_s {
-    struct config_s conf;
-    unsigned long int distance;
-    unsigned long int elevation_gain;
-    unsigned long int elevation_loss;
-    time_t time_start;
-    time_t current_pause_start;
-    time_t pause_time;
-    unsigned tracking_paused:1;
-    unsigned tracking_auto_paused:1;
-};
-
-struct location_s {
-    float lon;
-    float lat;
-    float alt;
-    time_t time;
-};
-
-extern volatile struct system_s System;
-extern struct location_s location;
-extern time_t utc;
-
-/* Settings flags */
-#define CONFFLAG_DISABLE_FILTERS 0x01
-
-extern unsigned char config_flags;
-
-static inline unsigned char get_flag(unsigned char flag) {
-    return (config_flags & flag) ? 1 : 0;
-}
-
-/* Time functions */
-char *get_iso_time(time_t time, unsigned char local);
-void iso_time_to_filename(char *time);

+ 5 - 4
gps-test-tool/main.c

@@ -18,7 +18,6 @@
 volatile struct system_s System;
 struct location_s location;
 time_t utc;
-unsigned char config_flags = 0;
 unsigned char FLAGS = 0;
 volatile unsigned char reset_cause = 0; /* no real MCU reset happened; log_boot_record() reports "UNKNOWN" */
 
@@ -105,11 +104,13 @@ int process_nmea_file(const char *input_file, const char *output_gpx,
         return 1;
     }
 
-    /* Configure filters */
-    config_flags = (filters_enabled ? 0 : CONFFLAG_DISABLE_FILTERS) | CONFFLAG_AUTO_PAUSE;
-
     /* Reset system state */
     reset_system();
+
+    /* Configure filters */
+    set_flag(CONFFLAG_DISABLE_FILTERS, !filters_enabled);
+    set_flag(CONFFLAG_AUTO_PAUSE, 1);
+
     gps_powered_on();
     log_boot_record();
 

+ 25 - 110
gps-test-tool/main.h

@@ -163,113 +163,17 @@
 #define VI_LVH          3.4
 #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
-#define REJECT_REASON_ALTDIFF    3
-
-/* 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_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 points_paused;
-    unsigned long int points_skipped;
-    unsigned long int points_accepted;
-    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 dgps:1; /* GGA reports a DGPS-quality fix - the receiver's own doing, not CONFFLAG_ENABLE_SBAS (our SBAS-search request) */
-    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;
 
 /* Global variables */
@@ -277,11 +181,22 @@ extern volatile struct system_s System;
 extern struct location_s location;
 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
@@ -294,8 +209,8 @@ static inline unsigned char tracking_is_paused(void) {
 }
 
 /* Kept in sync with soft/main.c's pause_time_start()/pause_time_end()/
- * get_pause_time(): call *_start()/*_end() exactly once, at the moment a
- * pause actually begins/ends (not deferred to the next accepted point,
+ * 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) {

+ 0 - 1
gps-test-tool/test_malformed.c

@@ -24,7 +24,6 @@
 volatile struct system_s System;
 struct location_s location;
 time_t utc;
-unsigned char config_flags = 0;
 unsigned char FLAGS = 0;
 volatile unsigned char reset_cause = 0;
 FILE *debug_output = NULL;

+ 2 - 8
soft/autopause.h

@@ -1,13 +1,7 @@
 #pragma once
 
-struct auto_pause_s {
-	unsigned char point_counter;
-	unsigned long int prev_distance;
-	unsigned char speed_counter;
-	struct location_s pause_anchor; /* running average position while paused */
-	unsigned int anchor_sample_count;
-	unsigned char resume_high_history; /* bit history: was the anchor-distance/speed resume condition met */
-};
+/* struct auto_pause_s is in common.h - shared byte-for-byte with the PC test
+ * tool, since this module compiles unmodified into both. */
 
 extern struct auto_pause_s auto_pause;
 

+ 157 - 0
soft/common.h

@@ -0,0 +1,157 @@
+#pragma once
+
+/* Needs time_t already defined (embedded: stime.h's typedef; PC: <time.h>) -
+ * include this only after whichever of those this build already includes. */
+
+/*
+ * Definitions shared byte-for-byte between the embedded build (soft/) and
+ * the PC test tool (gps-test-tool/): struct layouts that cross the boundary
+ * between translation units compiled for each side (System/location/
+ * auto_pause, all real logic - gpx.c/nmea.c/syslog.c/autopause.c compile
+ * unmodified into both), and the value constants those structs' fields hold.
+ *
+ * Kept deliberately minimal: this is not "the" shared header, just the part
+ * that must never drift, because a mismatch here is a silent ABI mismatch
+ * between translation units rather than a compile error. Includes, pin/
+ * hardware definitions, and anything embedded-only or PC-only stay in each
+ * side's own main.h.
+ */
+
+/* System.location_valid values */
+#define LOC_INVALID	0
+#define LOC_VALID	1
+#define LOC_VALID_NEW	2
+
+/* System.fix_type values (from GSA) */
+#define FIX_TYPE_UNKNOWN	0
+#define FIX_TYPE_2D		2
+#define FIX_TYPE_3D		3
+
+/* GNSS modes (System.conf.gnss_mode) */
+#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
+
+/* UART log mode values (System.conf.uart_log_mode) */
+#define UART_LOG_MODE_MIXED	0	/* NMEA and system log interleaved (default) */
+#define UART_LOG_MODE_NMEA	1	/* NMEA only */
+#define UART_LOG_MODE_SYSTEM	2	/* system log only */
+
+/* Reasons a candidate point can be rejected before being written (see
+ * soft/syslog.h's reject_reason_names[], indexed by these) */
+#define REJECT_REASON_KALMAN	0	/* Kalman-filtered position error too large */
+#define REJECT_REASON_DISTDIFF	1	/* distance jump inconsistent with recent history */
+#define REJECT_REASON_MINDIST	2	/* too small a position change since last saved point */
+#define REJECT_REASON_ALTDIFF	3	/* altitude jump inconsistent with recent history */
+
+/* System.conf.flags bit indices, read/set via get_flag(index)/set_flag(index,
+ * val) - both sides index the same way (a bit position within a flags byte
+ * array), not a pre-shifted bitmask, so these constants and the get_flag()
+ * call sites are interchangeable between builds. */
+#define CONFFLAG_DISABLE_FILTERS	0
+#define CONFFLAG_ENABLE_SBAS		1
+#define CONFFLAG_LOGGING_AFTER_BOOT	2
+#define CONFFLAG_AUTO_PAUSE		3
+#define CONFFLAG_RESET_ON_NEW_FILE	4
+#define CONFFLAG_VERBOSE_LOG		5
+
+#define CONFFLAG_LAST			5
+
+struct config_s {
+	union {
+		unsigned char conf_u8[16];
+		struct {
+			unsigned char gnss_mode;	// 0
+			unsigned char skip_points;	// 1
+			unsigned char auto_pause_time;	// 2
+			unsigned char auto_pause_dist;	// 3
+			unsigned char min_sats;		// 4
+			unsigned char auto_pause_speed;	// 5
+			unsigned char uart_log_mode;	// 6
+		};
+	};
+	unsigned char flags[4];
+};
+
+struct location_s {
+	float lon;
+	float lat;
+	float alt;
+	time_t time;
+};
+
+#ifndef PC_BUILD
+/* Real hardware-timer-backed countdowns (set_timer()/timer_expired() in
+ * soft/main.h), driven by an ISR via atomic_set_uint()/atomic_get_uint().
+ * Embedded-only: the PC build's set_timer()/timer_expired() are plain no-op
+ * functions that never reference System.timers, so struct system_s doesn't
+ * carry it there - dead weight, and a stray cli()/sei() dependency, for a
+ * build with no such ISR. */
+struct timers {
+	unsigned int owire;
+	unsigned int beep;
+	unsigned int recv_timeout;
+	unsigned int status_log;
+	unsigned int lcd;
+	unsigned int backlight;
+};
+#endif
+
+struct system_s {
+#ifndef PC_BUILD
+	struct timers timers;
+#endif
+	struct config_s conf;
+	unsigned long int distance; // cm
+	unsigned long int elevation_gain; // dm (decimeters, 0.1m resolution); filtered (dead-band+smoothed)
+	unsigned long int elevation_loss; // dm; filtered (dead-band+smoothed)
+	unsigned long int elevation_gain_raw; // dm; unfiltered, for log comparison only
+	unsigned long int elevation_loss_raw; // dm; unfiltered, for log comparison only
+	unsigned long int alt_max; // dm; highest smoothed altitude seen this session
+	unsigned long int speed_accum_x100; // sum of instantaneous NMEA speed samples (km/h * 100) while not paused
+	unsigned long int speed_sample_count; // number of samples in speed_accum_x100
+	unsigned long int points_written; // count of accepted/written track points this session
+	unsigned long int rejected_count; // count of rejected candidate points this session (unsigned long: a poor-fix session can reject far more than 65535 times)
+	unsigned long int points_paused; // count of candidate points seen while tracking_is_paused(), this session
+	unsigned long int points_skipped; // count of candidate points dropped by the skip_points warm-up (after boot or a fix gap), this session
+	unsigned long int points_accepted; // count of candidate points that passed every reject check, this session; with filters enabled, points_accepted - points_written*AVG_COUNT is "averaged out, not yet flushed".
+		// points_paused + points_skipped + rejected_count + points_accepted may fall a couple short of the true candidate-point total: the sliding window used for the distance/altitude spike checks needs a couple of points to refill after each reset (boot, or a fix gap) before it can even decide reject-vs-accept, and those few points aren't tallied anywhere.
+	unsigned int hdop_x100; // HDOP * 100, from GSA
+	unsigned char fix_type; // FIX_TYPE_* from GSA
+	unsigned char speed; // km/h
+	time_t time_start;
+	time_t current_pause_start;
+	time_t pause_time;
+	float bat_volt;
+	float bat_volt_min; // lowest battery voltage seen this session
+	float temperature;
+	unsigned temperature_ok:1;
+	unsigned satellites_used:5;
+	unsigned location_valid:2;
+	unsigned dgps:1; /* GGA reports a DGPS-quality fix - the receiver's own doing, not CONFFLAG_ENABLE_SBAS (our SBAS-search request) */
+	unsigned gps_initialized:2;
+	unsigned gps_only:1;
+	unsigned keypress:1;
+	unsigned tracking_paused:1;
+	unsigned tracking_auto_paused:1;
+	unsigned open_new_file:1;
+	unsigned sat_count_low:1;
+	unsigned int global_error;
+	unsigned char status;
+	unsigned char display_state;
+	unsigned char working_mode;
+};
+
+/* Auto-pause state (soft/autopause.c, compiled unmodified into both builds -
+ * see soft/autopause.h). */
+struct auto_pause_s {
+	unsigned char point_counter;
+	unsigned long int prev_distance;
+	unsigned char speed_counter;
+	struct location_s pause_anchor; /* running average position while paused */
+	unsigned int anchor_sample_count;
+	unsigned char resume_high_history; /* bit history: was the anchor-distance/speed resume condition met */
+};

+ 7 - 69
soft/main.h

@@ -21,6 +21,13 @@
 
 /* Project includes - basic headers without struct dependencies */
 #include "stime.h"
+
+/* struct system_s/location_s/config_s/auto_pause_s and the value constants
+ * their fields hold are in common.h - shared byte-for-byte with the PC test
+ * tool, since gpx.c/nmea.c/syslog.c/autopause.c compile unmodified into both.
+ * Needs time_t (stime.h, just above) already defined. */
+#include "common.h"
+
 #include "expander.h"
 #include "settings.h"
 #include "ff.h"
@@ -151,11 +158,6 @@
 #define K_RIGHT	_BV(0)
 #define K_POWER	_BV(4)
 
-/* System.location_valid values */
-#define LOC_INVALID	0
-#define LOC_VALID	1
-#define LOC_VALID_NEW	2
-
 /* System.gps_initialized values */
 #define GPS_INIT_NOT_INITIALIZED	0
 #define GPS_INIT_QUERY_SENT			1
@@ -163,70 +165,6 @@
 
 #define ms(x) (x/10)
 
-struct timers {
-	unsigned int owire;
-	unsigned int beep;
-	unsigned int recv_timeout;
-	unsigned int status_log;
-	unsigned int lcd;
-	unsigned int backlight;
-};
-
-/* System.fix_type values (from GSA) */
-#define FIX_TYPE_UNKNOWN	0
-#define FIX_TYPE_2D			2
-#define FIX_TYPE_3D			3
-
-struct system_s {
-	struct timers timers;
-	struct config_s conf;
-	unsigned int global_error;
-	unsigned char status;
-	float bat_volt;
-	float temperature;
-	unsigned char display_state;
-	unsigned char keypress;
-	unsigned char working_mode;
-	unsigned long int distance; // cm
-	unsigned long int elevation_gain; // dm (decimeters, 0.1m resolution); filtered (dead-band+smoothed)
-	unsigned long int elevation_loss; // dm; filtered (dead-band+smoothed)
-	unsigned long int elevation_gain_raw; // dm; unfiltered, for log comparison only
-	unsigned long int elevation_loss_raw; // dm; unfiltered, for log comparison only
-	unsigned long int alt_max; // dm; highest smoothed altitude seen this session
-	unsigned long int speed_accum_x100; // sum of instantaneous NMEA speed samples (km/h * 100) while not paused
-	unsigned long int speed_sample_count; // number of samples in speed_accum_x100
-	unsigned long int points_written; // count of accepted/written track points this session
-	unsigned long int rejected_count; // count of rejected candidate points this session (unsigned long: a poor-fix session can reject far more than 65535 times)
-	unsigned long int points_paused; // count of candidate points seen while tracking_is_paused(), this session
-	unsigned long int points_skipped; // count of candidate points dropped by the skip_points warm-up (after boot or a fix gap), this session
-	unsigned long int points_accepted; // count of candidate points that passed every reject check, this session; with filters enabled, points_accepted - points_written*AVG_COUNT is "averaged out, not yet flushed".
-		// points_paused + points_skipped + rejected_count + points_accepted may fall a couple short of the true candidate-point total: the sliding window used for the distance/altitude spike checks needs a couple of points to refill after each reset (boot, or a fix gap) before it can even decide reject-vs-accept, and those few points aren't tallied anywhere.
-	unsigned int hdop_x100; // HDOP * 100, from GSA
-	unsigned char fix_type; // FIX_TYPE_* from GSA
-	unsigned char speed; // km/h
-	time_t time_start;
-	time_t current_pause_start;
-	time_t pause_time;
-	float bat_volt_min; // lowest battery voltage seen this session
-	unsigned temperature_ok:1;
-	unsigned satellites_used:5;
-	unsigned location_valid:2;
-	unsigned dgps:1; /* GGA reports a DGPS-quality fix - the receiver's own doing, not CONFFLAG_ENABLE_SBAS (our SBAS-search request) */
-	unsigned gps_initialized:2;
-	unsigned gps_only:1;
-	unsigned tracking_paused:1;
-	unsigned tracking_auto_paused:1;
-	unsigned open_new_file:1;
-	unsigned sat_count_low:1;
-};
-
-struct location_s {
-	float lon;
-	float lat;
-	float alt;
-	time_t time;
-};
-
 extern volatile struct system_s System;
 extern struct location_s location;
 extern time_t utc;

+ 4 - 37
soft/settings.h

@@ -13,44 +13,11 @@
 
 #define CONF_U8_LAST		6
 
-/* UART log mode values (CONF_U8_UART_LOG_MODE) */
-#define UART_LOG_MODE_MIXED	0	/* NMEA and system log interleaved (default) */
-#define UART_LOG_MODE_NMEA	1	/* NMEA only */
-#define UART_LOG_MODE_SYSTEM	2	/* system log only */
+#define CONFFLAG_LAST		CONFFLAG_VERBOSE_LOG
 
-/* flags list - max 31 */
-#define CONFFLAG_DISABLE_FILTERS	0
-#define CONFFLAG_ENABLE_SBAS		1
-#define CONFFLAG_LOGGING_AFTER_BOOT	2
-#define CONFFLAG_AUTO_PAUSE			3
-#define CONFFLAG_RESET_ON_NEW_FILE	4
-#define CONFFLAG_VERBOSE_LOG		5
-
-#define CONFFLAG_LAST				5
-
-/* 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
-
-struct config_s {
-	union {
-		unsigned char conf_u8[16];
-		struct {
-			unsigned char gnss_mode;	// 0
-			unsigned char skip_points;	// 1
-			unsigned char auto_pause_time;	// 2
-			unsigned char auto_pause_dist;	// 3
-			unsigned char min_sats;		// 4
-			unsigned char auto_pause_speed;	// 5
-			unsigned char uart_log_mode;	// 6
-		};
-	};
-	unsigned char flags[4];
-};
+/* UART_LOG_MODE_*, CONFFLAG_*, GNSS_MODE_*, and struct config_s are in
+ * common.h (included via main.h, before this file - see main.h's include
+ * order) - shared byte-for-byte with the PC test tool. */
 
 extern const __flash unsigned char limits_max_u8[];
 extern const __flash unsigned char limits_min_u8[];