altoslib: Handle eeprom tick wrapping
authorKeith Packard <keithp@keithp.com>
Sun, 28 May 2017 21:33:28 +0000 (14:33 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 28 May 2017 21:33:28 +0000 (14:33 -0700)
Need to deal with eeprom files with tick values that cross the 16-bit
barrier.
Use 'wide_tick' to order eeprom record.
Remeber 'prev_tick' to order cal data time sequence.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosCalData.java
altoslib/AltosEepromRecord.java
altoslib/AltosEepromRecordSet.java

index 960de30a45f5aeb1f3f89462c3697616559c43bc..54b75817bb7196b2fc8b82cd88c5ca4d5ea0bcd1 100644 (file)
@@ -172,6 +172,7 @@ public class AltosCalData {
                                        tick += 65536;
                                }
                        }
+                       prev_tick = tick;
                        this.tick = tick;
                }
        }
index 7a0cc8f92ac4be3d89d3b21e43fbc248450f0a3e..75fe5381f51b1c9e57de5b85cc846969b55927d5 100644 (file)
@@ -74,7 +74,7 @@ public abstract class AltosEepromRecord implements Comparable<AltosEepromRecord>
                if (cmd_diff != 0)
                        return cmd_diff;
 
-               int     tick_diff = tick() - o.tick();
+               int     tick_diff = wide_tick - o.wide_tick;
 
                if (tick_diff != 0)
                        return tick_diff;
index 0c60c1a5ab5b8db2196a626b3a22a822b0b55748..c019a092bbeb0c44d3652e1768e8fbea6de50c09 100644 (file)
@@ -33,6 +33,7 @@ public class AltosEepromRecordSet implements AltosRecordSet {
                                if (record.cmd() == AltosLib.AO_LOG_FLIGHT) {
                                        cal_data.set_tick(record.tick());
                                        cal_data.set_boost_tick();
+                                       break;
                                }
                        }
                }