summaryrefslogtreecommitdiff
path: root/gpsutils.c
diff options
context:
space:
mode:
authorJon Schlueter <jon.schlueter@gmail.com>2010-10-06 16:32:09 -0400
committerJon Schlueter <jon.schlueter@gmail.com>2010-10-06 16:42:08 -0400
commit40c9fc2d7e5475e9e247db4ddeffaa926baf436f (patch)
tree857f4d87308e99f6be09b546b17fa6c86bd89cbe /gpsutils.c
parent3df4a6c2245f2adafc812eb3f343225f4b3a21bc (diff)
downloadgpsd-40c9fc2d7e5475e9e247db4ddeffaa926baf436f.tar.gz
gpsutil.c: fill_dop bug if sats < 4
bug present where it would try to invert matrix with out enough data... added guard to prevent trying to calculate dop's if we don't have 4 sats with current code.
Diffstat (limited to 'gpsutils.c')
-rw-r--r--gpsutils.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/gpsutils.c b/gpsutils.c
index 6b94de0e..1bf200ed 100644
--- a/gpsutils.c
+++ b/gpsutils.c
@@ -466,6 +466,8 @@ gps_mask_t fill_dop(const struct gps_data_t * gpsdata, struct dop_t * dop)
double xdop, ydop, hdop, vdop, pdop, tdop, gdop;
int i, j, k, n;
+ memset(satpos, 0, sizeof(satpos));
+
#ifdef __UNUSED__
gpsd_report(LOG_INF, "Satellite picture:\n");
for (k = 0; k < MAXCHANNELS; k++) {
@@ -488,6 +490,16 @@ gps_mask_t fill_dop(const struct gps_data_t * gpsdata, struct dop_t * dop)
n++;
}
+ /* If we don't have 4 satellites then we don't have enough information to calculate DOPS */
+ if (n < 4) {
+ gpsd_report(LOG_DATA + 2, "Not enough Satellites available %d < 4:\n",
+ n);
+ return 0; /* Is this correct return code here? or should it be ERROR_IS */
+ }
+
+ memset(prod, 0, sizeof(prod));
+ memset(inv, 0, sizeof(inv));
+
#ifdef __UNUSED__
gpsd_report(LOG_INF, "Line-of-sight matrix:\n");
for (k = 0; k < n; k++) {