From d6749bf24792bb41ca700cf4b8e5e1ac1a63cbf0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 17 Jul 2009 21:30:53 -0700 Subject: [PATCH 1/1] Add AO_GPS_RUNNING state. 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 --- src/ao.h | 1 + src/ao_gps.c | 2 +- src/ao_gps_print.c | 9 ++++++--- src/ao_gps_test.c | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ao.h b/src/ao.h index 2e582577..85b7825f 100644 --- 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_RUNNING (1 << 5) struct ao_gps_data { uint8_t hour; diff --git a/src/ao_gps.c b/src/ao_gps.c index 811ac2a8..32a44fb1 100644 --- a/src/ao_gps.c +++ b/src/ao_gps.c @@ -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.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; diff --git a/src/ao_gps_print.c b/src/ao_gps_print.c index 5ad8d022..49041af6 100644 --- a/src/ao_gps_print.c +++ b/src/ao_gps_print.c @@ -82,11 +82,14 @@ ao_gps_print(__xdata struct ao_gps_data *gps_data) __reentrant 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); - } else { + } else if (gps_data->flags & AO_GPS_RUNNING) { printf(" unlocked\n"); + } else { + printf (" not-connected\n"); } } diff --git a/src/ao_gps_test.c b/src/ao_gps_test.c index 0ed51d16..fb9b0d10 100644 --- a/src/ao_gps_test.c +++ b/src/ao_gps_test.c @@ -26,6 +26,7 @@ #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; -- 2.30.2