altos: Merge GPS logging into a single function
authorKeith Packard <keithp@keithp.com>
Tue, 15 Oct 2013 05:41:43 +0000 (22:41 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 15 Oct 2013 05:41:43 +0000 (22:41 -0700)
Create a new global, ao_gps_new, which indicates new GPS position and
satellite data.

Use ao_gps_new as the new sleep/wakeup address.

Merge the separate gps position/satellite logging tasks into a single
function which waits for new data and writes out the changed values.

Signed-off-by: Keith Packard <keithp@keithp.com>
13 files changed:
src/core/ao.h
src/core/ao_flight.c
src/core/ao_gps_report.c
src/core/ao_gps_report_mega.c
src/core/ao_gps_report_metrum.c
src/drivers/ao_gps_sirf.c
src/drivers/ao_gps_skytraq.c
src/drivers/ao_gps_ublox.c
src/product/ao_terraui.c
src/teleballoon-v1.1/ao_balloon.c
src/test/ao_gps_test.c
src/test/ao_gps_test_skytraq.c
src/test/ao_gps_test_ublox.c

index e7320327b712fd8ce50f62ae0830ada9af55276d..ea37885e03e4c84987cea74904ee2bbc1f5ae4d5 100644 (file)
@@ -342,6 +342,10 @@ ao_spi_slave(void);
 #define AO_GPS_DATE_VALID      (1 << 6)
 #define AO_GPS_COURSE_VALID    (1 << 7)
 
 #define AO_GPS_DATE_VALID      (1 << 6)
 #define AO_GPS_COURSE_VALID    (1 << 7)
 
+#define AO_GPS_NEW_DATA                1
+#define AO_GPS_NEW_TRACKING    2
+
+extern __xdata uint8_t ao_gps_new;
 extern __pdata uint16_t ao_gps_tick;
 extern __xdata uint8_t ao_gps_mutex;
 extern __xdata struct ao_telemetry_location ao_gps_data;
 extern __pdata uint16_t ao_gps_tick;
 extern __xdata uint8_t ao_gps_mutex;
 extern __xdata struct ao_telemetry_location ao_gps_data;
index 88dc816d25578858aa2c3e8c672cb414b0eb418e..2495a44bafe85553a3facfcb5eac0839c416b73c 100644 (file)
@@ -194,8 +194,8 @@ ao_flight(void)
 
 #if HAS_GPS
                                /* Record current GPS position by waking up GPS log tasks */
 
 #if HAS_GPS
                                /* Record current GPS position by waking up GPS log tasks */
-                               ao_wakeup(&ao_gps_data);
-                               ao_wakeup(&ao_gps_tracking_data);
+                               ao_gps_new = AO_GPS_NEW_DATA | AO_GPS_NEW_TRACKING;
+                               ao_wakeup(&ao_gps_new);
 #endif
 
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
 #endif
 
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
index c52ef6219ed2afa1e0b3e0cdbd6d9e9256f14438..8d15c083c905c2d149d22c1294e61b6bebeac387 100644 (file)
@@ -22,78 +22,68 @@ ao_gps_report(void)
 {
        static __xdata struct ao_log_record             gps_log;
        static __xdata struct ao_telemetry_location     gps_data;
 {
        static __xdata struct ao_log_record             gps_log;
        static __xdata struct ao_telemetry_location     gps_data;
+       static __xdata struct ao_telemetry_satellite    gps_tracking_data;
        uint8_t date_reported = 0;
        uint8_t date_reported = 0;
+       uint8_t new;
 
        for (;;) {
 
        for (;;) {
-               ao_sleep(&ao_gps_data);
                ao_mutex_get(&ao_gps_mutex);
                ao_mutex_get(&ao_gps_mutex);
-               ao_xmemcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
+               while ((new = ao_gps_new) == 0)
+                       ao_sleep(&ao_gps_new);
+               if (new & AO_GPS_NEW_DATA)
+                       ao_xmemcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
+               if (new & AO_GPS_NEW_TRACKING)
+                       ao_xmemcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
+               ao_gps_new = 0;
                ao_mutex_put(&ao_gps_mutex);
 
                ao_mutex_put(&ao_gps_mutex);
 
-               if (!(gps_data.flags & AO_GPS_VALID))
-                       continue;
-
-               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;
-               gps_log.u.gps_time.second = gps_data.second;
-               gps_log.u.gps_time.flags = gps_data.flags;
-               ao_log_data(&gps_log);
-               gps_log.type = AO_LOG_GPS_LAT;
-               gps_log.u.gps_latitude = gps_data.latitude;
-               ao_log_data(&gps_log);
-               gps_log.type = AO_LOG_GPS_LON;
-               gps_log.u.gps_longitude = gps_data.longitude;
-               ao_log_data(&gps_log);
-               gps_log.type = AO_LOG_GPS_ALT;
-               gps_log.u.gps_altitude.altitude = gps_data.altitude;
-               gps_log.u.gps_altitude.unused = 0xffff;
-               ao_log_data(&gps_log);
-               if (!date_reported && (gps_data.flags & AO_GPS_DATE_VALID)) {
-                       gps_log.type = AO_LOG_GPS_DATE;
-                       gps_log.u.gps_date.year = gps_data.year;
-                       gps_log.u.gps_date.month = gps_data.month;
-                       gps_log.u.gps_date.day = gps_data.day;
-                       gps_log.u.gps_date.extra = 0;
-                       date_reported = ao_log_data(&gps_log);
+               if ((new & AO_GPS_NEW_DATA) && (gps_data.flags & AO_GPS_VALID)) {
+                       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;
+                       gps_log.u.gps_time.second = gps_data.second;
+                       gps_log.u.gps_time.flags = gps_data.flags;
+                       ao_log_data(&gps_log);
+                       gps_log.type = AO_LOG_GPS_LAT;
+                       gps_log.u.gps_latitude = gps_data.latitude;
+                       ao_log_data(&gps_log);
+                       gps_log.type = AO_LOG_GPS_LON;
+                       gps_log.u.gps_longitude = gps_data.longitude;
+                       ao_log_data(&gps_log);
+                       gps_log.type = AO_LOG_GPS_ALT;
+                       gps_log.u.gps_altitude.altitude = gps_data.altitude;
+                       gps_log.u.gps_altitude.unused = 0xffff;
+                       ao_log_data(&gps_log);
+                       if (!date_reported && (gps_data.flags & AO_GPS_DATE_VALID)) {
+                               gps_log.type = AO_LOG_GPS_DATE;
+                               gps_log.u.gps_date.year = gps_data.year;
+                               gps_log.u.gps_date.month = gps_data.month;
+                               gps_log.u.gps_date.day = gps_data.day;
+                               gps_log.u.gps_date.extra = 0;
+                               date_reported = ao_log_data(&gps_log);
+                       }
                }
                }
-       }
-}
-
-void
-ao_gps_tracking_report(void)
-{
-       static __xdata struct ao_log_record             gps_log;
-       static __xdata struct ao_telemetry_satellite    gps_tracking_data;
-       uint8_t c, n;
-
-       for (;;) {
-               ao_sleep(&ao_gps_tracking_data);
-               ao_mutex_get(&ao_gps_mutex);
-               gps_log.tick = ao_gps_tick;
-               ao_xmemcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
-               ao_mutex_put(&ao_gps_mutex);
+               if (new & AO_GPS_NEW_TRACKING) {
+                       uint8_t c, n;
 
 
-               if (!(n = gps_tracking_data.channels))
-                       continue;
-
-               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))
-                       {
-                               gps_log.u.gps_sat.c_n = gps_tracking_data.sats[c].c_n_1;
-                               ao_log_data(&gps_log);
+                       if ((n = gps_tracking_data.channels) != 0) {
+                               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))
+                                       {
+                                               gps_log.u.gps_sat.c_n = gps_tracking_data.sats[c].c_n_1;
+                                               ao_log_data(&gps_log);
+                                       }
                        }
                        }
+               }
        }
 }
 
 __xdata struct ao_task ao_gps_report_task;
        }
 }
 
 __xdata struct ao_task ao_gps_report_task;
-__xdata struct ao_task ao_gps_tracking_report_task;
 
 void
 ao_gps_report_init(void)
 {
        ao_add_task(&ao_gps_report_task, ao_gps_report, "gps_report");
 
 void
 ao_gps_report_init(void)
 {
        ao_add_task(&ao_gps_report_task, ao_gps_report, "gps_report");
-       ao_add_task(&ao_gps_tracking_report_task, ao_gps_tracking_report, "gps_tracking_report");
 }
 }
index e3af43079728033740513c6c7dc057c0eb313bec..e2adbfbc90b38563ccfbf0f5dab57b911b077b69 100644 (file)
@@ -23,66 +23,55 @@ ao_gps_report_mega(void)
 {
        static __xdata struct ao_log_mega               gps_log;
        static __xdata struct ao_telemetry_location     gps_data;
 {
        static __xdata struct ao_log_mega               gps_log;
        static __xdata struct ao_telemetry_location     gps_data;
-       uint8_t date_reported = 0;
-
-       for (;;) {
-               ao_sleep(&ao_gps_data);
-               ao_mutex_get(&ao_gps_mutex);
-               ao_xmemcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
-               ao_mutex_put(&ao_gps_mutex);
-
-               if (!(gps_data.flags & AO_GPS_VALID))
-                       continue;
-
-               gps_log.tick = ao_gps_tick;
-               gps_log.type = AO_LOG_GPS_TIME;
-               gps_log.u.gps.latitude = gps_data.latitude;
-               gps_log.u.gps.longitude = gps_data.longitude;
-               gps_log.u.gps.altitude = gps_data.altitude;
-
-               gps_log.u.gps.hour = gps_data.hour;
-               gps_log.u.gps.minute = gps_data.minute;
-               gps_log.u.gps.second = gps_data.second;
-               gps_log.u.gps.flags = gps_data.flags;
-               gps_log.u.gps.year = gps_data.year;
-               gps_log.u.gps.month = gps_data.month;
-               gps_log.u.gps.day = gps_data.day;
-               ao_log_mega(&gps_log);
-       }
-}
-
-void
-ao_gps_tracking_report_mega(void)
-{
-       static __xdata struct ao_log_mega               gps_log;
        static __xdata struct ao_telemetry_satellite    gps_tracking_data;
        static __xdata struct ao_telemetry_satellite    gps_tracking_data;
+       uint8_t date_reported = 0;
+       uint8_t new;
        uint8_t c, n, i;
 
        for (;;) {
        uint8_t c, n, i;
 
        for (;;) {
-               ao_sleep(&ao_gps_tracking_data);
                ao_mutex_get(&ao_gps_mutex);
                ao_mutex_get(&ao_gps_mutex);
-               ao_xmemcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
+               while (!(new = ao_gps_new))
+                       ao_sleep(&ao_gps_new);
+               if (new & AO_GPS_NEW_DATA)
+                       ao_xmemcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
+               if (new & AO_GPS_NEW_TRACKING)
+                       ao_xmemcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
+               ao_gps_new = 0;
                ao_mutex_put(&ao_gps_mutex);
 
                ao_mutex_put(&ao_gps_mutex);
 
-               if (!(n = gps_tracking_data.channels))
-                       continue;
+               if ((new & AO_GPS_NEW_DATA) && (gps_data.flags & AO_GPS_VALID)) {
+                       gps_log.tick = ao_gps_tick;
+                       gps_log.type = AO_LOG_GPS_TIME;
+                       gps_log.u.gps.latitude = gps_data.latitude;
+                       gps_log.u.gps.longitude = gps_data.longitude;
+                       gps_log.u.gps.altitude = gps_data.altitude;
 
 
-               gps_log.type = AO_LOG_GPS_SAT;
-               gps_log.tick = ao_gps_tick;
-               i = 0;
-               for (c = 0; c < n; c++)
-                       if ((gps_log.u.gps_sat.sats[i].svid = gps_tracking_data.sats[c].svid))
-                       {
-                               gps_log.u.gps_sat.sats[i].c_n = gps_tracking_data.sats[c].c_n_1;
-                               i++;
-                       }
-               gps_log.u.gps_sat.channels = i;
-               ao_log_mega(&gps_log);
+                       gps_log.u.gps.hour = gps_data.hour;
+                       gps_log.u.gps.minute = gps_data.minute;
+                       gps_log.u.gps.second = gps_data.second;
+                       gps_log.u.gps.flags = gps_data.flags;
+                       gps_log.u.gps.year = gps_data.year;
+                       gps_log.u.gps.month = gps_data.month;
+                       gps_log.u.gps.day = gps_data.day;
+                       ao_log_mega(&gps_log);
+               }
+               if ((new & AO_GPS_NEW_TRACKING) && (n = gps_tracking_data.channels) != 0) {
+                       gps_log.tick = ao_gps_tick;
+                       gps_log.type = AO_LOG_GPS_SAT;
+                       i = 0;
+                       for (c = 0; c < n; c++)
+                               if ((gps_log.u.gps_sat.sats[i].svid = gps_tracking_data.sats[c].svid))
+                               {
+                                       gps_log.u.gps_sat.sats[i].c_n = gps_tracking_data.sats[c].c_n_1;
+                                       i++;
+                               }
+                       gps_log.u.gps_sat.channels = i;
+                       ao_log_mega(&gps_log);
+               }
        }
 }
 
 __xdata struct ao_task ao_gps_report_mega_task;
        }
 }
 
 __xdata struct ao_task ao_gps_report_mega_task;
-__xdata struct ao_task ao_gps_tracking_report_mega_task;
 
 void
 ao_gps_report_mega_init(void)
 
 void
 ao_gps_report_mega_init(void)
@@ -90,7 +79,4 @@ ao_gps_report_mega_init(void)
        ao_add_task(&ao_gps_report_mega_task,
                    ao_gps_report_mega,
                    "gps_report");
        ao_add_task(&ao_gps_report_mega_task,
                    ao_gps_report_mega,
                    "gps_report");
-       ao_add_task(&ao_gps_tracking_report_mega_task,
-                   ao_gps_tracking_report_mega,
-                   "gps_tracking_report");
 }
 }
index 4fefe223610d50972ec442362c4e177a29e9c76c..b82936dd65bcef7078e0b80bb4e5b752b66583eb 100644 (file)
@@ -23,80 +23,69 @@ ao_gps_report_metrum(void)
 {
        static __xdata struct ao_log_metrum             gps_log;
        static __xdata struct ao_telemetry_location     gps_data;
 {
        static __xdata struct ao_log_metrum             gps_log;
        static __xdata struct ao_telemetry_location     gps_data;
-       uint8_t date_reported = 0;
-
-       for (;;) {
-               ao_sleep(&ao_gps_data);
-               ao_mutex_get(&ao_gps_mutex);
-               ao_xmemcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
-               ao_mutex_put(&ao_gps_mutex);
-
-               if (!(gps_data.flags & AO_GPS_VALID))
-                       continue;
-
-               gps_log.tick = ao_gps_tick;
-               gps_log.type = AO_LOG_GPS_POS;
-               gps_log.u.gps.latitude = gps_data.latitude;
-               gps_log.u.gps.longitude = gps_data.longitude;
-               gps_log.u.gps.altitude = gps_data.altitude;
-               ao_log_metrum(&gps_log);
-
-               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;
-               gps_log.u.gps_time.second = gps_data.second;
-               gps_log.u.gps_time.flags = gps_data.flags;
-               gps_log.u.gps_time.year = gps_data.year;
-               gps_log.u.gps_time.month = gps_data.month;
-               gps_log.u.gps_time.day = gps_data.day;
-               ao_log_metrum(&gps_log);
-       }
-}
-
-void
-ao_gps_tracking_report_metrum(void)
-{
-       static __xdata struct ao_log_metrum             gps_log;
        static __xdata struct ao_telemetry_satellite    gps_tracking_data;
        uint8_t c, n, i, p, valid, packets;
        uint8_t svid;
        static __xdata struct ao_telemetry_satellite    gps_tracking_data;
        uint8_t c, n, i, p, valid, packets;
        uint8_t svid;
+       uint8_t date_reported = 0;
 
        for (;;) {
 
        for (;;) {
-               ao_sleep(&ao_gps_tracking_data);
                ao_mutex_get(&ao_gps_mutex);
                ao_mutex_get(&ao_gps_mutex);
-               ao_xmemcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
+               while (!(new = ao_gps_new))
+                       ao_sleep(&ao_gps_new);
+               if (new & AO_GPS_NEW_DATA)
+                       ao_xmemcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
+               if (new & AO_GPS_NEW_TRACKING)
+                       ao_xmemcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (ao_gps_tracking_data));
+               ao_gps_new = 0;
                ao_mutex_put(&ao_gps_mutex);
 
                ao_mutex_put(&ao_gps_mutex);
 
-               if (!(n = gps_tracking_data.channels))
-                       continue;
+               if ((new & AO_GPS_NEW_DATA) && (gps_data.flags & AO_GPS_VALID)) {
+                       gps_log.tick = ao_gps_tick;
+                       gps_log.type = AO_LOG_GPS_POS;
+                       gps_log.u.gps.latitude = gps_data.latitude;
+                       gps_log.u.gps.longitude = gps_data.longitude;
+                       gps_log.u.gps.altitude = gps_data.altitude;
+                       ao_log_metrum(&gps_log);
 
 
-               gps_log.type = AO_LOG_GPS_SAT;
-               gps_log.tick = ao_gps_tick;
-               i = 0;
-               for (c = 0; c < n; c++) {
-                       svid = gps_tracking_data.sats[c].svid;
-                       if (svid != 0) {
-                               if (i == 4) {
-                                       gps_log.u.gps_sat.channels = i;
-                                       gps_log.u.gps_sat.more = 1;
-                                       ao_log_metrum(&gps_log);
-                                       i = 0;
+                       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;
+                       gps_log.u.gps_time.second = gps_data.second;
+                       gps_log.u.gps_time.flags = gps_data.flags;
+                       gps_log.u.gps_time.year = gps_data.year;
+                       gps_log.u.gps_time.month = gps_data.month;
+                       gps_log.u.gps_time.day = gps_data.day;
+                       ao_log_metrum(&gps_log);
+               }
+
+               if ((new & AO_GPS_NEW_TRACKING) && (n = gps_tracking_data.channels)) {
+                       gps_log.type = AO_LOG_GPS_SAT;
+                       gps_log.tick = ao_gps_tick;
+                       i = 0;
+                       for (c = 0; c < n; c++) {
+                               svid = gps_tracking_data.sats[c].svid;
+                               if (svid != 0) {
+                                       if (i == 4) {
+                                               gps_log.u.gps_sat.channels = i;
+                                               gps_log.u.gps_sat.more = 1;
+                                               ao_log_metrum(&gps_log);
+                                               i = 0;
+                                       }
+                                       gps_log.u.gps_sat.sats[i].svid = svid;
+                                       gps_log.u.gps_sat.sats[i].c_n = gps_tracking_data.sats[c].c_n_1;
+                                       i++;
                                }
                                }
-                               gps_log.u.gps_sat.sats[i].svid = svid;
-                               gps_log.u.gps_sat.sats[i].c_n = gps_tracking_data.sats[c].c_n_1;
-                               i++;
                        }
                        }
-               }
-               if (i) {
-                       gps_log.u.gps_sat.channels = i;
-                       gps_log.u.gps_sat.more = 0;
-                       ao_log_metrum(&gps_log);
+                       if (i) {
+                               gps_log.u.gps_sat.channels = i;
+                               gps_log.u.gps_sat.more = 0;
+                               ao_log_metrum(&gps_log);
+                       }
                }
        }
 }
 
 __xdata struct ao_task ao_gps_report_metrum_task;
                }
        }
 }
 
 __xdata struct ao_task ao_gps_report_metrum_task;
-__xdata struct ao_task ao_gps_tracking_report_metrum_task;
 
 void
 ao_gps_report_metrum_init(void)
 
 void
 ao_gps_report_metrum_init(void)
@@ -104,7 +93,4 @@ ao_gps_report_metrum_init(void)
        ao_add_task(&ao_gps_report_metrum_task,
                    ao_gps_report_metrum,
                    "gps_report");
        ao_add_task(&ao_gps_report_metrum_task,
                    ao_gps_report_metrum,
                    "gps_report");
-       ao_add_task(&ao_gps_tracking_report_metrum_task,
-                   ao_gps_tracking_report_metrum,
-                   "gps_tracking_report");
 }
 }
index 91fc948b466fa18935fd5d3b6d34f5f65ce4cc83..d89435b9c635f46891ae62ca948a5378e4a7238a 100644 (file)
@@ -19,6 +19,7 @@
 #include "ao.h"
 #endif
 
 #include "ao.h"
 #endif
 
+__xdata uint8_t ao_gps_new;
 __xdata uint8_t ao_gps_mutex;
 __pdata uint16_t ao_gps_tick;
 __xdata struct ao_telemetry_location   ao_gps_data;
 __xdata uint8_t ao_gps_mutex;
 __pdata uint16_t ao_gps_tick;
 __xdata struct ao_telemetry_location   ao_gps_data;
@@ -422,8 +423,9 @@ ao_gps(void) __reentrant
                        else
                                ao_gps_data.v_error = ao_sirf_data.v_error / 100;
 #endif
                        else
                                ao_gps_data.v_error = ao_sirf_data.v_error / 100;
 #endif
+                       ao_gps_new |= AO_GPS_NEW_DATA;
                        ao_mutex_put(&ao_gps_mutex);
                        ao_mutex_put(&ao_gps_mutex);
-                       ao_wakeup(&ao_gps_data);
+                       ao_wakeup(&ao_gps_new);
                        break;
                case 4:
                        ao_mutex_get(&ao_gps_mutex);
                        break;
                case 4:
                        ao_mutex_get(&ao_gps_mutex);
@@ -432,8 +434,9 @@ ao_gps(void) __reentrant
                                ao_gps_tracking_data.sats[i].svid = ao_sirf_tracker_data.sats[i].svid;
                                ao_gps_tracking_data.sats[i].c_n_1 = ao_sirf_tracker_data.sats[i].c_n_1;
                        }
                                ao_gps_tracking_data.sats[i].svid = ao_sirf_tracker_data.sats[i].svid;
                                ao_gps_tracking_data.sats[i].c_n_1 = ao_sirf_tracker_data.sats[i].c_n_1;
                        }
+                       ao_gps_new |= AO_GPS_NEW_TRACKING;
                        ao_mutex_put(&ao_gps_mutex);
                        ao_mutex_put(&ao_gps_mutex);
-                       ao_wakeup(&ao_gps_tracking_data);
+                       ao_wakeup(&ao_gps_new);
                        break;
                }
        }
                        break;
                }
        }
index 9a9dff75725f8dc315400fddded7b3aa26c1095b..944a37f9b38400a05ccc3d2a437f332141af8a79 100644 (file)
@@ -32,6 +32,7 @@
 #define ao_gps_set_speed       ao_serial1_set_speed
 #endif
 
 #define ao_gps_set_speed       ao_serial1_set_speed
 #endif
 
+__xdata uint8_t ao_gps_new;
 __xdata uint8_t ao_gps_mutex;
 static __data char ao_gps_char;
 static __data uint8_t ao_gps_cksum;
 __xdata uint8_t ao_gps_mutex;
 static __data char ao_gps_char;
 static __data uint8_t ao_gps_cksum;
@@ -293,10 +294,11 @@ ao_nmea_gga(void)
 
        if (!ao_gps_error) {
                ao_mutex_get(&ao_gps_mutex);
 
        if (!ao_gps_error) {
                ao_mutex_get(&ao_gps_mutex);
+               ao_gps_new |= AO_GPS_NEW_DATA;
                ao_gps_tick = ao_gps_next_tick;
                ao_xmemcpy(&ao_gps_data, PDATA_TO_XDATA(&ao_gps_next), sizeof (ao_gps_data));
                ao_mutex_put(&ao_gps_mutex);
                ao_gps_tick = ao_gps_next_tick;
                ao_xmemcpy(&ao_gps_data, PDATA_TO_XDATA(&ao_gps_next), sizeof (ao_gps_data));
                ao_mutex_put(&ao_gps_mutex);
-               ao_wakeup(&ao_gps_data);
+               ao_wakeup(&ao_gps_new);
        }
 }
 
        }
 }
 
@@ -352,9 +354,10 @@ ao_nmea_gsv(void)
                ao_gps_tracking_next.channels = 0;
        else if (done) {
                ao_mutex_get(&ao_gps_mutex);
                ao_gps_tracking_next.channels = 0;
        else if (done) {
                ao_mutex_get(&ao_gps_mutex);
+               ao_gps_new |= AO_GPS_NEW_TRACKING;
                ao_xmemcpy(&ao_gps_tracking_data, PDATA_TO_XDATA(&ao_gps_tracking_next), sizeof(ao_gps_tracking_data));
                ao_mutex_put(&ao_gps_mutex);
                ao_xmemcpy(&ao_gps_tracking_data, PDATA_TO_XDATA(&ao_gps_tracking_next), sizeof(ao_gps_tracking_data));
                ao_mutex_put(&ao_gps_mutex);
-               ao_wakeup(&ao_gps_tracking_data);
+               ao_wakeup(&ao_gps_new);
        }
 }
 
        }
 }
 
index e91683485a6c5a36166e04d715e816feea66f9ed..3582d6e0a0fdaa457f5d652f926faa73f9f57c58 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <stdarg.h>
 
 
 #include <stdarg.h>
 
+__xdata uint8_t ao_gps_new;
 __xdata uint8_t ao_gps_mutex;
 __pdata uint16_t ao_gps_tick;
 __xdata struct ao_telemetry_location   ao_gps_data;
 __xdata uint8_t ao_gps_mutex;
 __pdata uint16_t ao_gps_tick;
 __xdata struct ao_telemetry_location   ao_gps_data;
@@ -760,8 +761,8 @@ ao_gps(void) __reentrant
                                }
 
                                ao_mutex_put(&ao_gps_mutex);
                                }
 
                                ao_mutex_put(&ao_gps_mutex);
-                               ao_wakeup(&ao_gps_data);
-                               ao_wakeup(&ao_gps_tracking_data);
+                               ao_gps_new = AO_GPS_NEW_DATA | AO_GPS_NEW_TRACKING;
+                               ao_wakeup(&ao_gps_new);
                                break;
                        }
                        break;
                                break;
                        }
                        break;
index 1866eb0c1183af7ac4bff51387eaca4c2ec6c31a..8fd97033d6533329bd25af5d0e5ee3bb453f36ff 100644 (file)
@@ -629,7 +629,7 @@ ao_terragps(void)
 
        for (;;) {
                while (ao_gps_tick == gps_tick)
 
        for (;;) {
                while (ao_gps_tick == gps_tick)
-                       ao_sleep(&ao_gps_data);
+                       ao_sleep(&ao_gps_new);
                gps_tick = ao_gps_tick;
                ao_gps_progress = (ao_gps_progress + 1) & 3;
        }
                gps_tick = ao_gps_tick;
                ao_gps_progress = (ao_gps_progress + 1) & 3;
        }
index e89726552dce132bddaf0c4f09f6a45471c0b12a..12752d1f8d3655f252ba2ba62dc6c29b63d99802 100644 (file)
@@ -105,8 +105,8 @@ ao_flight(void)
 
 #if HAS_GPS
                                /* Record current GPS position by waking up GPS log tasks */
 
 #if HAS_GPS
                                /* Record current GPS position by waking up GPS log tasks */
-                               ao_wakeup(&ao_gps_data);
-                               ao_wakeup(&ao_gps_tracking_data);
+                               ao_gps_new = AO_GPS_NEW_DATA | AO_GPS_NEW_TRACKING;
+                               ao_wakeup(&ao_gps_new);
 #endif
 
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
 #endif
 
                                ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
index 3844a3265452f623d5065f48e31b6061cdabe002..b6cc9ba73614c31698a0c797d8a582ca0d8a9f1d 100644 (file)
@@ -427,11 +427,18 @@ void
 ao_dump_state(void *wchan)
 {
        int     i;
 ao_dump_state(void *wchan)
 {
        int     i;
-       if (wchan == &ao_gps_data)
+
+       if (wchan != &ao_gps_new)
+               return;
+       
+       if (ao_gps_new & AO_GPS_NEW_DATA) {
                ao_gps_print(&ao_gps_data);
                ao_gps_print(&ao_gps_data);
-       else
+               putchar('\n');
+       }
+       if (ao_gps_new & AO_GPS_NEW_TRACKING) {
                ao_gps_tracking_print(&ao_gps_tracking_data);
                ao_gps_tracking_print(&ao_gps_tracking_data);
-       putchar('\n');
+               putchar('\n');
+       }
        return;
        printf ("%02d:%02d:%02d",
                ao_gps_data.hour, ao_gps_data.minute,
        return;
        printf ("%02d:%02d:%02d",
                ao_gps_data.hour, ao_gps_data.minute,
index 89cbd7677beebe4e140dc1d26eddfb60ef71852d..bf2ab5b83274fbf645a47305282a63c0bd78e3b8 100644 (file)
@@ -443,7 +443,7 @@ uint8_t     ao_task_minimize_latency;
 void
 ao_dump_state(void *wchan)
 {
 void
 ao_dump_state(void *wchan)
 {
-       if (wchan == &ao_gps_data)
+       if (wchan == &ao_gps_new)
                ao_gps_show();
 }
 
                ao_gps_show();
 }
 
index a0e04cb6a8659b802c81b6e149731020ca9df868..31c7af60159867f1274d2f07b0b9c0bf3675921a 100644 (file)
@@ -347,7 +347,7 @@ check_ublox_message(char *which, uint8_t *msg)
 void
 ao_dump_state(void *wchan)
 {
 void
 ao_dump_state(void *wchan)
 {
-       if (wchan == &ao_gps_data)
+       if (wchan == &ao_gps_new)
                ao_gps_show();
        return;
 }
                ao_gps_show();
        return;
 }