|
@@ -2,17 +2,21 @@
|
|
|
* GPS Test Tool - PC Application
|
|
* GPS Test Tool - PC Application
|
|
|
*
|
|
*
|
|
|
* Tests GPS filtering and GPX generation using actual embedded code
|
|
* Tests GPS filtering and GPX generation using actual embedded code
|
|
|
- * Usage: ./gps-test-tool <input.nmea>
|
|
|
|
|
|
|
+ * Usage: ./gps-test-tool [options] <input.nmea>
|
|
|
*
|
|
*
|
|
|
- * Generates:
|
|
|
|
|
|
|
+ * Generates (default mode):
|
|
|
* - output_filtered.gpx
|
|
* - output_filtered.gpx
|
|
|
* - output_unfiltered.gpx
|
|
* - output_unfiltered.gpx
|
|
|
* - debug_filtered.txt
|
|
* - debug_filtered.txt
|
|
|
* - debug_unfiltered.txt
|
|
* - debug_unfiltered.txt
|
|
|
|
|
+ *
|
|
|
|
|
+ * With -o, does a single run with the given settings instead (used by
|
|
|
|
|
+ * gps-test-tool-gui).
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
#define PC_BUILD
|
|
#define PC_BUILD
|
|
|
#include "main.h"
|
|
#include "main.h"
|
|
|
|
|
+#include <getopt.h>
|
|
|
|
|
|
|
|
/* Global variables expected by project code */
|
|
/* Global variables expected by project code */
|
|
|
volatile struct system_s System;
|
|
volatile struct system_s System;
|
|
@@ -63,17 +67,26 @@ void iso_time_to_filename(char *time) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* Settings applied by reset_system(); command-line options override these. */
|
|
|
|
|
+static unsigned char opt_skip_points = 0; /* Don't skip points for testing */
|
|
|
|
|
+/* Match soft/settings.c's defaults_u8, so this tool's auto-pause behavior
|
|
|
|
|
+ * matches an out-of-the-box device. */
|
|
|
|
|
+static unsigned char opt_auto_pause_time = 30;
|
|
|
|
|
+static unsigned char opt_auto_pause_dist = 10;
|
|
|
|
|
+static unsigned char opt_auto_pause_speed = 3;
|
|
|
|
|
+static unsigned char opt_min_sats = 4; /* Require at least 4 satellites */
|
|
|
|
|
+static unsigned char opt_auto_pause = 1;
|
|
|
|
|
+static unsigned char opt_verbose_log = 0;
|
|
|
|
|
+
|
|
|
/* Reset system state */
|
|
/* Reset system state */
|
|
|
void reset_system(void) {
|
|
void reset_system(void) {
|
|
|
memset((void*)&System, 0, sizeof(System));
|
|
memset((void*)&System, 0, sizeof(System));
|
|
|
memset(&location, 0, sizeof(location));
|
|
memset(&location, 0, sizeof(location));
|
|
|
- System.conf.skip_points = 0; /* Don't skip points for testing */
|
|
|
|
|
- /* Match soft/settings.c's defaults_u8, so this tool's auto-pause behavior
|
|
|
|
|
- * (enabled below) matches an out-of-the-box device. */
|
|
|
|
|
- System.conf.auto_pause_time = 30;
|
|
|
|
|
- System.conf.auto_pause_dist = 10;
|
|
|
|
|
- System.conf.auto_pause_speed = 3;
|
|
|
|
|
- System.conf.min_sats = 4; /* Require at least 4 satellites */
|
|
|
|
|
|
|
+ System.conf.skip_points = opt_skip_points;
|
|
|
|
|
+ System.conf.auto_pause_time = opt_auto_pause_time;
|
|
|
|
|
+ System.conf.auto_pause_dist = opt_auto_pause_dist;
|
|
|
|
|
+ System.conf.auto_pause_speed = opt_auto_pause_speed;
|
|
|
|
|
+ System.conf.min_sats = opt_min_sats;
|
|
|
System.tracking_paused = 0;
|
|
System.tracking_paused = 0;
|
|
|
System.tracking_auto_paused = 0;
|
|
System.tracking_auto_paused = 0;
|
|
|
System.bat_volt = 4.0f; /* no real ADC here; keeps the status line's v=/bat%= fields sane */
|
|
System.bat_volt = 4.0f; /* no real ADC here; keeps the status line's v=/bat%= fields sane */
|
|
@@ -109,7 +122,8 @@ int process_nmea_file(const char *input_file, const char *output_gpx,
|
|
|
|
|
|
|
|
/* Configure filters */
|
|
/* Configure filters */
|
|
|
set_flag(CONFFLAG_DISABLE_FILTERS, !filters_enabled);
|
|
set_flag(CONFFLAG_DISABLE_FILTERS, !filters_enabled);
|
|
|
- set_flag(CONFFLAG_AUTO_PAUSE, 1);
|
|
|
|
|
|
|
+ set_flag(CONFFLAG_AUTO_PAUSE, opt_auto_pause);
|
|
|
|
|
+ set_flag(CONFFLAG_VERBOSE_LOG, opt_verbose_log);
|
|
|
|
|
|
|
|
gps_powered_on();
|
|
gps_powered_on();
|
|
|
log_boot_record();
|
|
log_boot_record();
|
|
@@ -260,25 +274,72 @@ int process_nmea_file(const char *input_file, const char *output_gpx,
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-int main(int argc, char *argv[]) {
|
|
|
|
|
- int ret;
|
|
|
|
|
|
|
+static void usage(const char *name) {
|
|
|
|
|
+ fprintf(stderr, "Usage: %s [options] <input.nmea>\n", name);
|
|
|
|
|
+ fprintf(stderr, "\nWithout -o, generates:\n");
|
|
|
|
|
+ fprintf(stderr, " - output_filtered.gpx\n");
|
|
|
|
|
+ fprintf(stderr, " - output_unfiltered.gpx\n");
|
|
|
|
|
+ fprintf(stderr, " - debug_filtered.txt\n");
|
|
|
|
|
+ fprintf(stderr, " - debug_unfiltered.txt\n");
|
|
|
|
|
+ fprintf(stderr, "\nOptions:\n");
|
|
|
|
|
+ fprintf(stderr, " -o FILE single run: write GPX to FILE only\n");
|
|
|
|
|
+ fprintf(stderr, " -l FILE single run: write debug output to FILE (default: none)\n");
|
|
|
|
|
+ fprintf(stderr, " -n single run: disable filters\n");
|
|
|
|
|
+ fprintf(stderr, " -A disable auto-pause\n");
|
|
|
|
|
+ fprintf(stderr, " -t SEC auto-pause time (default %u)\n", opt_auto_pause_time);
|
|
|
|
|
+ fprintf(stderr, " -d M auto-pause distance (default %u)\n", opt_auto_pause_dist);
|
|
|
|
|
+ fprintf(stderr, " -s KMH auto-pause speed (default %u)\n", opt_auto_pause_speed);
|
|
|
|
|
+ fprintf(stderr, " -k N skip points after fix (default %u)\n", opt_skip_points);
|
|
|
|
|
+ fprintf(stderr, " -m N minimum satellites (default %u)\n", opt_min_sats);
|
|
|
|
|
+ fprintf(stderr, " -v verbose log\n");
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- printf("GPS Test Tool v1.0\n");
|
|
|
|
|
- printf("==================\n\n");
|
|
|
|
|
|
|
+/* Parse a 0..255 setting value; returns 0 on success. */
|
|
|
|
|
+static int parse_u8(const char *str, unsigned char *val) {
|
|
|
|
|
+ char *end;
|
|
|
|
|
+ long v = strtol(str, &end, 10);
|
|
|
|
|
+ if (!*str || *end || v < 0 || v > 255)
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ *val = v;
|
|
|
|
|
+ return 0;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- if (argc != 2) {
|
|
|
|
|
- fprintf(stderr, "Usage: %s <input.nmea>\n", argv[0]);
|
|
|
|
|
- fprintf(stderr, "\nGenerates:\n");
|
|
|
|
|
- fprintf(stderr, " - output_filtered.gpx\n");
|
|
|
|
|
- fprintf(stderr, " - output_unfiltered.gpx\n");
|
|
|
|
|
- fprintf(stderr, " - debug_filtered.txt\n");
|
|
|
|
|
- fprintf(stderr, " - debug_unfiltered.txt\n");
|
|
|
|
|
|
|
+int main(int argc, char *argv[]) {
|
|
|
|
|
+ int ret, c, bad = 0;
|
|
|
|
|
+ const char *single_gpx = NULL;
|
|
|
|
|
+ const char *single_debug = "/dev/null";
|
|
|
|
|
+ int single_filters = 1;
|
|
|
|
|
+
|
|
|
|
|
+ while ((c = getopt(argc, argv, "o:l:nAt:d:s:k:m:v")) != -1) {
|
|
|
|
|
+ switch (c) {
|
|
|
|
|
+ case 'o': single_gpx = optarg; break;
|
|
|
|
|
+ case 'l': single_debug = optarg; break;
|
|
|
|
|
+ case 'n': single_filters = 0; break;
|
|
|
|
|
+ case 'A': opt_auto_pause = 0; break;
|
|
|
|
|
+ case 't': bad |= parse_u8(optarg, &opt_auto_pause_time); break;
|
|
|
|
|
+ case 'd': bad |= parse_u8(optarg, &opt_auto_pause_dist); break;
|
|
|
|
|
+ case 's': bad |= parse_u8(optarg, &opt_auto_pause_speed); break;
|
|
|
|
|
+ case 'k': bad |= parse_u8(optarg, &opt_skip_points); break;
|
|
|
|
|
+ case 'm': bad |= parse_u8(optarg, &opt_min_sats); break;
|
|
|
|
|
+ case 'v': opt_verbose_log = 1; break;
|
|
|
|
|
+ default: bad = 1; break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (bad || optind != argc - 1) {
|
|
|
|
|
+ usage(argv[0]);
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (single_gpx)
|
|
|
|
|
+ return process_nmea_file(argv[optind], single_gpx, single_debug, single_filters);
|
|
|
|
|
+
|
|
|
|
|
+ printf("GPS Test Tool v1.0\n");
|
|
|
|
|
+ printf("==================\n\n");
|
|
|
|
|
+
|
|
|
/* Process with filters enabled */
|
|
/* Process with filters enabled */
|
|
|
printf("Processing with filters ENABLED...\n");
|
|
printf("Processing with filters ENABLED...\n");
|
|
|
- ret = process_nmea_file(argv[1], "output_filtered.gpx",
|
|
|
|
|
|
|
+ ret = process_nmea_file(argv[optind], "output_filtered.gpx",
|
|
|
"debug_filtered.txt", 1);
|
|
"debug_filtered.txt", 1);
|
|
|
if (ret != 0) {
|
|
if (ret != 0) {
|
|
|
fprintf(stderr, "Failed to process with filters enabled\n");
|
|
fprintf(stderr, "Failed to process with filters enabled\n");
|
|
@@ -287,7 +348,7 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
|
|
|
/* Process with filters disabled */
|
|
/* Process with filters disabled */
|
|
|
printf("Processing with filters DISABLED...\n");
|
|
printf("Processing with filters DISABLED...\n");
|
|
|
- ret = process_nmea_file(argv[1], "output_unfiltered.gpx",
|
|
|
|
|
|
|
+ ret = process_nmea_file(argv[optind], "output_unfiltered.gpx",
|
|
|
"debug_unfiltered.txt", 0);
|
|
"debug_unfiltered.txt", 0);
|
|
|
if (ret != 0) {
|
|
if (ret != 0) {
|
|
|
fprintf(stderr, "Failed to process with filters disabled\n");
|
|
fprintf(stderr, "Failed to process with filters disabled\n");
|