altosui: When fixing eeprom gps time information, make GPS data valid
authorKeith Packard <keithp@keithp.com>
Sun, 21 Nov 2010 06:03:26 +0000 (22:03 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 21 Nov 2010 06:03:26 +0000 (22:03 -0800)
Eeprom files may be missing the GPS time (due to a firmware bug). Working
around this involves finding the next valid GPS time and using that to
create a fake GPS time entry. However, that next GPS time may not
be locked or may have few sats as it is from the boost stage of the
flight. Fix this by simply forcing the fake time packet to have
4 sats and be locked.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/altosui/AltosEepromIterable.java

index fc6833216c8a0ea36d441b1d62d084092e040023..f8e6d7e5a2e16126755d4d7568be479d42445074 100644 (file)
@@ -309,6 +309,12 @@ public class AltosEepromIterable extends AltosRecordIterable {
                int flags = (good.b >> 8);
                int seconds = hour * 3600 + minute * 60 + second;
 
                int flags = (good.b >> 8);
                int seconds = hour * 3600 + minute * 60 + second;
 
+               /* Make sure this looks like a good GPS value */
+               if ((flags & Altos.AO_GPS_NUM_SAT_MASK) >> Altos.AO_GPS_NUM_SAT_SHIFT < 4)
+                       flags = (flags & ~Altos.AO_GPS_NUM_SAT_MASK) | (4 << Altos.AO_GPS_NUM_SAT_SHIFT);
+               flags |= Altos.AO_GPS_RUNNING;
+               flags |= Altos.AO_GPS_VALID;
+
                int new_seconds = seconds + diff;
                if (new_seconds < 0)
                        new_seconds += 24 * 3600;
                int new_seconds = seconds + diff;
                if (new_seconds < 0)
                        new_seconds += 24 * 3600;