Log GPS data on pad after boost detect.
authorKeith Packard <keithp@keithp.com>
Sun, 14 Feb 2010 00:42:27 +0000 (16:42 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 14 Feb 2010 00:42:27 +0000 (16:42 -0800)
This wakes up the two GPS reporting tasks and gets them to report out
any existing GPS data to the log file. To make sure the timestamps in
that GPS data are accurate, this also records GPS time on receipt of
the GPS data instead of when that is logged.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao.h
src/ao_flight.c
src/ao_gps_report.c
src/ao_gps_sirf.c
src/ao_gps_skytraq.c
src/ao_gps_test.c
src/ao_gps_test_skytraq.c

index 2c6eb2b91180d254818ca2553849a0b2cde95a90..d6be2223a33251fd6eb27291555c3c3e0a6ba119 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -731,6 +731,8 @@ ao_serial_init(void);
 #define AO_GPS_RUNNING         (1 << 5)
 #define AO_GPS_DATE_VALID      (1 << 6)
 
+extern __xdata uint16_t ao_gps_tick;
+
 struct ao_gps_data {
        uint8_t                 year;
        uint8_t                 month;
index e0fd97f2464b901a61649037e61a9848e46b819e..980c16be555f67ca389ff0982690689f894bd99c 100644 (file)
@@ -289,6 +289,10 @@ ao_flight(void)
                                /* disable RDF beacon */
                                ao_rdf_set(0);
 
+                               /* Record current GPS position by waking up GPS log tasks */
+                               ao_wakeup(&ao_gps_data);
+                               ao_wakeup(&ao_gps_tracking_data);
+
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
                                break;
                        }
index e3e275238bd7f54c2c8b2fabe1e232345a536be4..cceb79ffeb82be0b03e72b73f53b3ca2cdb2db5c 100644 (file)
@@ -33,7 +33,7 @@ ao_gps_report(void)
                if (!(gps_data.flags & AO_GPS_VALID))
                        continue;
 
-               gps_log.tick = ao_time();
+               gps_log.tick = ao_gps_tick;
                gps_log.type = AO_LOG_GPS_TIME;
                gps_log.u.gps_time.hour = gps_data.hour;
                gps_log.u.gps_time.minute = gps_data.minute;
@@ -71,13 +71,13 @@ ao_gps_tracking_report(void)
        for (;;) {
                ao_sleep(&ao_gps_tracking_data);
                ao_mutex_get(&ao_gps_mutex);
+               gps_log.tick = ao_gps_tick;
                memcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (struct ao_gps_tracking_data));
                ao_mutex_put(&ao_gps_mutex);
 
                if (!(n = gps_tracking_data.channels))
                        continue;
 
-               gps_log.tick = ao_time();
                gps_log.type = AO_LOG_GPS_SAT;
                for (c = 0; c < n; c++)
                        if ((gps_log.u.gps_sat.svid = gps_tracking_data.sats[c].svid))
index 64b66c95ce4af7f9fe16df6636e155d4b0035d22..a6167e6b8f21ab1fcabe16d2781129aa9089512a 100644 (file)
@@ -20,6 +20,7 @@
 #endif
 
 __xdata uint8_t ao_gps_mutex;
+__xdata uint16_t ao_gps_tick;
 __xdata struct ao_gps_data     ao_gps_data;
 __xdata struct ao_gps_tracking_data    ao_gps_tracking_data;
 
@@ -390,6 +391,7 @@ ao_gps(void) __reentrant
                switch (i) {
                case 41:
                        ao_mutex_get(&ao_gps_mutex);
+                       ao_gps_tick = ao_time();
                        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;
index 0dd45c0c7f9a57659f88cf488393b4582545e1f7..ae8c7ef7cafb1980d5cb08ffd541eac66d2f596c 100644 (file)
@@ -28,9 +28,11 @@ static __xdata char ao_gps_char;
 static __xdata uint8_t ao_gps_cksum;
 static __xdata uint8_t ao_gps_error;
 
+__xdata uint16_t ao_gps_tick;
 __xdata struct ao_gps_data     ao_gps_data;
 __xdata struct ao_gps_tracking_data    ao_gps_tracking_data;
 
+static __xdata uint16_t                                ao_gps_next_tick;
 static __xdata struct ao_gps_data              ao_gps_next;
 static __xdata uint8_t                         ao_gps_date_flags;
 static __xdata struct ao_gps_tracking_data     ao_gps_tracking_next;
@@ -248,6 +250,7 @@ ao_gps(void) __reentrant
                         *         *66          checksum
                         */
 
+                       ao_gps_next_tick = ao_time();
                        ao_gps_next.flags = AO_GPS_RUNNING | ao_gps_date_flags;
                        ao_gps_next.hour = ao_gps_decimal(2);
                        ao_gps_next.minute = ao_gps_decimal(2);
@@ -297,6 +300,7 @@ ao_gps(void) __reentrant
                                ao_gps_error = 1;
                        if (!ao_gps_error) {
                                ao_mutex_get(&ao_gps_mutex);
+                               ao_gps_tick = ao_gps_next_tick;
                                memcpy(&ao_gps_data, &ao_gps_next, sizeof (struct ao_gps_data));
                                ao_mutex_put(&ao_gps_mutex);
                                ao_wakeup(&ao_gps_data);
index fddfedfd075afe8ae70680803691f010b572aaf2..cdcc6f4c375ce0fbb14eb454f2c2f235810ae3bb 100644 (file)
@@ -400,6 +400,8 @@ ao_serial_set_speed(uint8_t speed)
        tcflush(fd, TCIFLUSH);
 }
 
+#define ao_time() 0
+
 #include "ao_gps_print.c"
 #include "ao_gps_sirf.c"
 
index ccf963785d74b44adaf4c7da06a1f7d491a14d37..7fa10eaaf7bb1818f2e0b1dbed5f1e5097620b6b 100644 (file)
@@ -408,6 +408,8 @@ ao_serial_set_speed(uint8_t speed)
        tcflush(fd, TCIFLUSH);
 }
 
+#define ao_time() 0
+
 #include "ao_gps_print.c"
 #include "ao_gps_skytraq.c"