X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=ao-tools%2Faltosui%2FAltosEepromReader.java;h=86bbaee0cde2a9640b768aca0f17a428032cc941;hp=0705d44e56949c867de81dba8b5ec8d9915e18d6;hb=6c653a4cba5fef8d49261cf1c024f3e86e9058c6;hpb=5f2f6a8f9ba56be867888758848bc7f152ccbd47 diff --git a/ao-tools/altosui/AltosEepromReader.java b/ao-tools/altosui/AltosEepromReader.java index 0705d44e..86bbaee0 100644 --- a/ao-tools/altosui/AltosEepromReader.java +++ b/ao-tools/altosui/AltosEepromReader.java @@ -116,7 +116,7 @@ public class AltosEepromReader extends AltosReader { if (last_reported) return null; last_reported = true; - return state; + return new AltosRecord(state); } record = record_iterator.next(); @@ -130,9 +130,7 @@ public class AltosEepromReader extends AltosReader { state.tick = record.tick; switch (record.cmd) { case Altos.AO_LOG_FLIGHT: - state.ground_accel = record.a; - state.flight = record.b; - seen |= seen_flight; + /* recorded when first read from the file */ break; case Altos.AO_LOG_SENSOR: state.accel = record.a; @@ -167,7 +165,15 @@ public class AltosEepromReader extends AltosReader { break; case Altos.AO_LOG_GPS_TIME: gps_tick = state.tick; + AltosGPS old = state.gps; state.gps = new AltosGPS(); + + /* GPS date doesn't get repeated through the file */ + if (old != null) { + state.gps.year = old.year; + state.gps.month = old.month; + state.gps.day = old.day; + } state.gps.hour = (record.a & 0xff); state.gps.minute = (record.a >> 8); state.gps.second = (record.b & 0xff); @@ -177,12 +183,6 @@ public class AltosEepromReader extends AltosReader { state.gps.date_valid = (flags & Altos.AO_GPS_DATE_VALID) != 0; state.gps.nsat = (flags & Altos.AO_GPS_NUM_SAT_MASK) >> Altos.AO_GPS_NUM_SAT_SHIFT; - System.out.printf("GPS %2d:%02d:%02d%s%s%s %d\n", - state.gps.hour, state.gps.minute, state.gps.second, - state.gps.connected ? " connected" : "", - state.gps.locked ? " locked" : "", - state.gps.date_valid ? " date_valid" : "", - state.gps.nsat); break; case Altos.AO_LOG_GPS_LAT: int lat32 = record.a | (record.b << 16); @@ -203,7 +203,7 @@ public class AltosEepromReader extends AltosReader { } break; case Altos.AO_LOG_GPS_DATE: - state.gps.year = record.a & 0xff; + state.gps.year = (record.a & 0xff) + 2000; state.gps.month = record.a >> 8; state.gps.day = record.b & 0xff; break; @@ -306,10 +306,6 @@ public class AltosEepromReader extends AltosReader { int new_hours = (new_minutes / 60); int new_hour = (new_hours % 24); - System.out.printf("Synthesizing time good %2d:%02d:%02d bad %2d:%02d:%02d\n", - hour, minute, second, - new_hour, new_minute, new_second); - bad.a = new_hour + (new_minute << 8); bad.b = new_second + (flags << 8); } @@ -344,6 +340,8 @@ public class AltosEepromReader extends AltosReader { AltosOrderedRecord record = new AltosOrderedRecord(line, index++, tick); if (record == null) break; + if (record.cmd == Altos.AO_LOG_INVALID) + continue; tick = record.tick; if (!saw_boost && record.cmd == Altos.AO_LOG_STATE && record.a >= Altos.ao_flight_boost) @@ -351,6 +349,11 @@ public class AltosEepromReader extends AltosReader { saw_boost = true; boost_tick = tick; } + if (record.cmd == Altos.AO_LOG_FLIGHT) { + state.ground_accel = record.a; + state.flight = record.b; + seen |= seen_flight; + } /* Two firmware bugs caused the loss of some GPS data. * The flight date would never be recorded, and often @@ -365,13 +368,9 @@ public class AltosEepromReader extends AltosReader { if (record.cmd == Altos.AO_LOG_GPS_TIME) { last_gps_time = record; if (missing_time) { - System.out.printf("Going back to clean up broken GPS time records\n"); Iterator iterator = records.iterator(); while (iterator.hasNext()) { AltosOrderedRecord old = iterator.next(); - if (old.cmd == Altos.AO_LOG_GPS_TIME) { - System.out.printf("Old time record %d, %d\n", old.a, old.b); - } if (old.cmd == Altos.AO_LOG_GPS_TIME && old.a == -1 && old.b == -1) { @@ -389,10 +388,9 @@ public class AltosEepromReader extends AltosReader { -1, -1, index-1); if (last_gps_time != null) update_time(last_gps_time, add_gps_time); - else { - System.out.printf("early GPS missing time\n"); + else missing_time = true; - } + records.add(add_gps_time); record.index = index++; }