From: Keith Packard Date: Sun, 14 Feb 2010 00:42:27 +0000 (-0800) Subject: Log GPS data on pad after boost detect. X-Git-Tag: debian/0.6+85+g82fdbfe~7 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=876e9a10b9096ead85fbe08ec9a6a0329cf7cbd4 Log GPS data on pad after boost detect. 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 --- diff --git a/src/ao.h b/src/ao.h index 2c6eb2b9..d6be2223 100644 --- 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; diff --git a/src/ao_flight.c b/src/ao_flight.c index e0fd97f2..980c16be 100644 --- a/src/ao_flight.c +++ b/src/ao_flight.c @@ -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; } diff --git a/src/ao_gps_report.c b/src/ao_gps_report.c index e3e27523..cceb79ff 100644 --- a/src/ao_gps_report.c +++ b/src/ao_gps_report.c @@ -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)) diff --git a/src/ao_gps_sirf.c b/src/ao_gps_sirf.c index 64b66c95..a6167e6b 100644 --- a/src/ao_gps_sirf.c +++ b/src/ao_gps_sirf.c @@ -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; diff --git a/src/ao_gps_skytraq.c b/src/ao_gps_skytraq.c index 0dd45c0c..ae8c7ef7 100644 --- a/src/ao_gps_skytraq.c +++ b/src/ao_gps_skytraq.c @@ -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); diff --git a/src/ao_gps_test.c b/src/ao_gps_test.c index fddfedfd..cdcc6f4c 100644 --- a/src/ao_gps_test.c +++ b/src/ao_gps_test.c @@ -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" diff --git a/src/ao_gps_test_skytraq.c b/src/ao_gps_test_skytraq.c index ccf96378..7fa10eaa 100644 --- a/src/ao_gps_test_skytraq.c +++ b/src/ao_gps_test_skytraq.c @@ -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"