Long idle periods with TeleGPS can easily overflow 16 bits of tick
count. Using the GPS seconds provides an additional sort which will
span the tick wrap-around.
Signed-off-by: Keith Packard <keithp@keithp.com>
return data8[i] | (data8[i+1] << 8) | (data8[i+2] << 16) | (data8[i+3] << 24);
}
+ public boolean has_seconds() { return false; }
+
+ public int seconds() { return 0; }
+
public final static int header_length = 4;
public abstract int record_length();
public int vdop() { return data8(24); }
public int mode() { return data8(25); }
+ public boolean has_seconds() { return cmd == AltosLib.AO_LOG_GPS_TIME; }
+
+ public int seconds() {
+ switch (cmd) {
+ case AltosLib.AO_LOG_GPS_TIME:
+ return second() + 60 * (minute() + 60 * (hour() + 24 * (day() + 31 * month())));
+ default:
+ return 0;
+ }
+ }
+
public AltosEepromGPS (AltosEepromChunk chunk, int start) throws ParseException {
parse_chunk(chunk, start);
}
if (cmd_diff != 0)
return cmd_diff;
+ if (eeprom.has_seconds() && o.eeprom.has_seconds()) {
+ int seconds_diff = eeprom.seconds() - o.eeprom.seconds();
+
+ if (seconds_diff != 0)
+ return seconds_diff;
+ }
+
int tick_diff = tick - o.tick;
if (tick_diff != 0)
eeproms = new LinkedList<AltosEeprom>();
return new AltosEepromOrderedIterator(eeproms);
}
-}
\ No newline at end of file
+}