altos: Don't hold GPS mutex while waiting in TM v2.0 report
authorKeith Packard <keithp@keithp.com>
Tue, 12 Nov 2013 06:18:58 +0000 (15:18 +0900)
committerKeith Packard <keithp@keithp.com>
Tue, 12 Nov 2013 07:27:31 +0000 (16:27 +0900)
Holding the GPS mutex while waiting for the GPS code to dump data into
the GPS variables is rather counter-productive.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/core/ao_gps_report_metrum.c

index b82936dd65bcef7078e0b80bb4e5b752b66583eb..fa03897622da3b462560f49319f4240342b1ee8d 100644 (file)
@@ -27,11 +27,12 @@ ao_gps_report_metrum(void)
        uint8_t c, n, i, p, valid, packets;
        uint8_t svid;
        uint8_t date_reported = 0;
+       uint8_t new;
 
        for (;;) {
-               ao_mutex_get(&ao_gps_mutex);
                while (!(new = ao_gps_new))
                        ao_sleep(&ao_gps_new);
+               ao_mutex_get(&ao_gps_mutex);
                if (new & AO_GPS_NEW_DATA)
                        ao_xmemcpy(&gps_data, &ao_gps_data, sizeof (ao_gps_data));
                if (new & AO_GPS_NEW_TRACKING)