altos: Allow ublox to run at other baud rates
[fw/altos] / altoslib / AltosEepromIterable.java
index 2e8715bafe76c8456230be7f9623867f6c9aa888..b84574ef9647261ea724d9510f0946f03469f544 100644 (file)
@@ -15,7 +15,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altoslib;
+package org.altusmetrum.altoslib_1;
 
 import java.io.*;
 import java.util.*;
@@ -125,30 +125,40 @@ public class AltosEepromIterable extends AltosRecordIterable {
                        state.gps.locked = (flags & AltosLib.AO_GPS_VALID) != 0;
                        state.gps.nsat = (flags & AltosLib.AO_GPS_NUM_SAT_MASK) >>
                                AltosLib.AO_GPS_NUM_SAT_SHIFT;
-                       state.new_gps = true;
+                       state.gps_sequence++;
                        has_gps = true;
                        break;
                case AltosLib.AO_LOG_GPS_LAT:
                        eeprom.seen |= AltosRecord.seen_gps_lat;
                        int lat32 = record.a | (record.b << 16);
+                       if (state.gps == null)
+                               state.gps = new AltosGPS();
                        state.gps.lat = (double) lat32 / 1e7;
                        break;
                case AltosLib.AO_LOG_GPS_LON:
                        eeprom.seen |= AltosRecord.seen_gps_lon;
                        int lon32 = record.a | (record.b << 16);
+                       if (state.gps == null)
+                               state.gps = new AltosGPS();
                        state.gps.lon = (double) lon32 / 1e7;
                        break;
                case AltosLib.AO_LOG_GPS_ALT:
+                       if (state.gps == null)
+                               state.gps = new AltosGPS();
                        state.gps.alt = record.a;
                        break;
                case AltosLib.AO_LOG_GPS_SAT:
                        if (state.tick == eeprom.gps_tick) {
                                int svid = record.a;
                                int c_n0 = record.b >> 8;
+                               if (state.gps == null)
+                                       state.gps = new AltosGPS();
                                state.gps.add_sat(svid, c_n0);
                        }
                        break;
                case AltosLib.AO_LOG_GPS_DATE:
+                       if (state.gps == null)
+                               state.gps = new AltosGPS();
                        state.gps.year = (record.a & 0xff) + 2000;
                        state.gps.month = record.a >> 8;
                        state.gps.day = record.b & 0xff;