Add AO_GPS_RUNNING state.
authorKeith Packard <keithp@keithp.com>
Sat, 18 Jul 2009 04:30:53 +0000 (21:30 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 18 Jul 2009 04:32:17 +0000 (21:32 -0700)
This tracks whether the GPS receiver has ever sent a valid report to the
flight computer, allowing the user to tell whether the GPS receiver is
working at all.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao.h
src/ao_gps.c
src/ao_gps_print.c
src/ao_gps_test.c

index 2e5825777acc69272e85694e4f7476a3b5f883fc..85b7825f759fdd73fd3473250933aaee92fa5200 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -678,6 +678,7 @@ ao_serial_init(void);
 #define AO_GPS_NUM_SAT_SHIFT   (0)
 
 #define AO_GPS_VALID           (1 << 4)
 #define AO_GPS_NUM_SAT_SHIFT   (0)
 
 #define AO_GPS_VALID           (1 << 4)
+#define AO_GPS_RUNNING         (1 << 5)
 
 struct ao_gps_data {
        uint8_t                 hour;
 
 struct ao_gps_data {
        uint8_t                 hour;
index 811ac2a8aae0aee4f1a3c0643da7c61e3aa34ff7..32a44fb1b24ca8f52c56e132b403633ec5fb3923 100644 (file)
@@ -332,7 +332,7 @@ ao_gps(void) __reentrant
                        ao_gps_data.hour = ao_sirf_data.utc_hour;
                        ao_gps_data.minute = ao_sirf_data.utc_minute;
                        ao_gps_data.second = ao_sirf_data.utc_second / 1000;
                        ao_gps_data.hour = ao_sirf_data.utc_hour;
                        ao_gps_data.minute = ao_sirf_data.utc_minute;
                        ao_gps_data.second = ao_sirf_data.utc_second / 1000;
-                       ao_gps_data.flags = (ao_sirf_data.num_sv << AO_GPS_NUM_SAT_SHIFT) & AO_GPS_NUM_SAT_MASK;
+                       ao_gps_data.flags = ((ao_sirf_data.num_sv << AO_GPS_NUM_SAT_SHIFT) & AO_GPS_NUM_SAT_MASK) | AO_GPS_RUNNING;
                        if ((ao_sirf_data.nav_type & NAV_TYPE_GPS_FIX_TYPE_MASK) >= NAV_TYPE_4_SV_KF)
                                ao_gps_data.flags |= AO_GPS_VALID;
                        ao_gps_data.latitude = ao_sirf_data.lat;
                        if ((ao_sirf_data.nav_type & NAV_TYPE_GPS_FIX_TYPE_MASK) >= NAV_TYPE_4_SV_KF)
                                ao_gps_data.flags |= AO_GPS_VALID;
                        ao_gps_data.latitude = ao_sirf_data.lat;
index 5ad8d0228d3f1143ce1af2562548a9f18a5d8296..49041af6f452c5c188531e9d8e6ebd1602136bed 100644 (file)
@@ -82,11 +82,14 @@ ao_gps_print(__xdata struct ao_gps_data *gps_data) __reentrant
                       climb_sign,
                       climb / 100,
                       climb % 100);
                       climb_sign,
                       climb / 100,
                       climb % 100);
-               printf(" %d.%d(hdop) %5d(herr) %5d(verr)\n",
-                      gps_data->hdop,
+               printf(" %d.%d(hdop) %5u(herr) %5u(verr)\n",
+                      gps_data->hdop / 5,
+                      (gps_data->hdop * 2) % 10,
                       gps_data->h_error,
                       gps_data->v_error);
                       gps_data->h_error,
                       gps_data->v_error);
-       } else {
+       } else if (gps_data->flags & AO_GPS_RUNNING) {
                printf(" unlocked\n");
                printf(" unlocked\n");
+       } else {
+               printf (" not-connected\n");
        }
 }
        }
 }
index 0ed51d163cf06d9e79031448e77a8f188ef030d6..fb9b0d10f12d438f1b860f634799ff123278aa6c 100644 (file)
@@ -26,6 +26,7 @@
 #define AO_GPS_NUM_SAT_SHIFT   (0)
 
 #define AO_GPS_VALID           (1 << 4)
 #define AO_GPS_NUM_SAT_SHIFT   (0)
 
 #define AO_GPS_VALID           (1 << 4)
+#define AO_GPS_RUNNING         (1 << 5)
 
 struct ao_gps_data {
        uint8_t                 hour;
 
 struct ao_gps_data {
        uint8_t                 hour;