aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-09-09 19:55:05 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-09-09 19:55:05 +0200
commit73e1e41de7861fd5dce6dc83984385e3e4617b82 (patch)
tree967e53f65e95cf27370a0fcf1ed1031def41d812 /src
parent0b815d3656bf17d757169a830ebd14705f37eb46 (diff)
downloadglutte-o-matic-73e1e41de7861fd5dce6dc83984385e3e4617b82.tar.gz
glutte-o-matic-73e1e41de7861fd5dce6dc83984385e3e4617b82.tar.bz2
glutte-o-matic-73e1e41de7861fd5dce6dc83984385e3e4617b82.zip
Parse GNGGA and print number of SV
Diffstat (limited to 'src')
-rw-r--r--src/common/includes/GPS/gps.h9
-rw-r--r--src/common/src/Core/common.c3
-rw-r--r--src/common/src/Core/main.c8
-rw-r--r--src/common/src/GPS/gps.c18
4 files changed, 27 insertions, 11 deletions
diff --git a/src/common/includes/GPS/gps.h b/src/common/includes/GPS/gps.h
index ec5ec77..8a2118f 100644
--- a/src/common/includes/GPS/gps.h
+++ b/src/common/includes/GPS/gps.h
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2015 Matthias P. Braendli
+ * Copyright (c) 2016 Matthias P. Braendli
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -40,6 +40,7 @@ void gps_init(void);
// Return 1 of the GPS is receiving time
int gps_locked(void);
-// Get current time from GPS
-// Returns 1 if time is valid, 0 otherwise
-int gps_utctime(struct tm *timeutc);
+// Get current time from GPS and number of satellite vehicles
+// used for fix.
+// Returns 1 if data is valid, 0 otherwise
+int gps_utctime(struct tm *timeutc, int *num_sv_used);
diff --git a/src/common/src/Core/common.c b/src/common/src/Core/common.c
index 8b0dddb..b980985 100644
--- a/src/common/src/Core/common.c
+++ b/src/common/src/Core/common.c
@@ -126,7 +126,8 @@ static int is_dst(const struct tm *time) {
int local_time(struct tm *time) {
const int local_time_offset=1; // hours
- int valid = gps_utctime(time);
+ int num_sv_used = 0;
+ int valid = gps_utctime(time, &num_sv_used);
if (valid) {
time->tm_hour += local_time_offset;
diff --git a/src/common/src/Core/main.c b/src/common/src/Core/main.c
index 551ec61..236fd1e 100644
--- a/src/common/src/Core/main.c
+++ b/src/common/src/Core/main.c
@@ -385,12 +385,14 @@ static void gps_monit_task(void __attribute__ ((unused))*pvParameters) {
}
}
- gps_utctime(&gps_time);
+ int num_sv_used = 0;
+ gps_utctime(&gps_time, &num_sv_used);
if (time.tm_sec % 30 == 0 && t_gps_print_latch == 0) {
- usart_debug("T_GPS %04d-%02d-%02d %02d:%02d:%02d\r\n",
+ usart_debug("T_GPS %04d-%02d-%02d %02d:%02d:%02d %d SV tracked\r\n",
gps_time.tm_year, gps_time.tm_mon, gps_time.tm_mday,
- gps_time.tm_hour, gps_time.tm_min, gps_time.tm_sec);
+ gps_time.tm_hour, gps_time.tm_min, gps_time.tm_sec,
+ num_sv_used);
char * mode;
diff --git a/src/common/src/GPS/gps.c b/src/common/src/GPS/gps.c
index 19b2d8d..bc4f549 100644
--- a/src/common/src/GPS/gps.c
+++ b/src/common/src/GPS/gps.c
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2015 Matthias P. Braendli
+ * Copyright (c) 2016 Matthias P. Braendli
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -34,7 +34,8 @@
TickType_t gps_timeutc_last_updated = 0;
static struct tm gps_timeutc;
-static int gps_timeutc_valid;
+static int gps_num_sv_used;
+static int gps_timeutc_valid; // Validity flag for both gps_timeutc and gps_num_sv_used
const TickType_t gps_data_validity_timeout = GPS_MS_TIMEOUT / portTICK_PERIOD_MS;
@@ -43,7 +44,8 @@ static void gps_task(void *pvParameters);
SemaphoreHandle_t timeutc_semaphore;
// Get current time from GPS
-int gps_utctime(struct tm *timeutc) {
+int gps_utctime(struct tm *timeutc, int *num_sv_used)
+{
int valid = 0;
xSemaphoreTake(timeutc_semaphore, portMAX_DELAY);
@@ -54,6 +56,7 @@ int gps_utctime(struct tm *timeutc) {
timeutc->tm_hour = gps_timeutc.tm_hour;
timeutc->tm_min = gps_timeutc.tm_min;
timeutc->tm_sec = gps_timeutc.tm_sec;
+ *num_sv_used = gps_num_sv_used;
valid = gps_timeutc_valid;
}
@@ -113,6 +116,15 @@ static void gps_task(void __attribute__ ((unused))*pvParameters) {
}
}
} break;
+ case MINMEA_SENTENCE_GGA:
+ {
+ struct minmea_sentence_gga frame;
+ if (minmea_parse_gga(&frame, rxbuf)) {
+ xSemaphoreTake(timeutc_semaphore, portMAX_DELAY);
+ gps_num_sv_used = frame.satellites_tracked;
+ xSemaphoreGive(timeutc_semaphore);
+ }
+ } break;
default:
break;
}