projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
had the sense backwards .. presence of 'attached' should put us in the loader
[fw/altos]
/
altoslib
/
AltosEepromRecord.java
diff --git
a/altoslib/AltosEepromRecord.java
b/altoslib/AltosEepromRecord.java
index e937c3d0c4bfff99c1ed9a58fc3c1723b63ad696..43e8ea4dbeccefa323e7ad273f0029c1750e8313 100644
(file)
--- a/
altoslib/AltosEepromRecord.java
+++ b/
altoslib/AltosEepromRecord.java
@@
-50,8
+50,22
@@
public abstract class AltosEepromRecord implements Comparable<AltosEepromRecord>
return data8(i) | (data8(i+1) << 8) | (data8(i+2) << 16) | (data8(i+3) << 24);
}
return data8(i) | (data8(i+1) << 8) | (data8(i+2) << 16) | (data8(i+3) << 24);
}
+ public boolean empty(int s) {
+ for (int i = 0; i < length; i++)
+ if (eeprom.data8(s + i) != 0xff)
+ return false;
+ return true;
+ }
+
public boolean valid(int s) {
public boolean valid(int s) {
- return AltosConvert.checksum(eeprom.data, s, length) == 0;
+ int ck = AltosConvert.checksum(eeprom.data, s, length);
+
+ if (ck != 0) {
+ ++eeprom.errors;
+ System.out.printf("invalid checksum 0x%x at 0x%x\n", ck, s);
+ return false;
+ }
+ return true;
}
public boolean valid() {
}
public boolean valid() {
@@
-90,11
+104,9
@@
public abstract class AltosEepromRecord implements Comparable<AltosEepromRecord>
/* Flush any pending GPS changes */
if (!AltosLib.is_gps_cmd(cmd())) {
/* Flush any pending GPS changes */
if (!AltosLib.is_gps_cmd(cmd())) {
- AltosGPS gps =
cal_data
.temp_gps();
- if (gps != null)
{
+ AltosGPS gps =
listener
.temp_gps();
+ if (gps != null)
listener.set_gps(gps);
listener.set_gps(gps);
- cal_data.reset_temp_gps();
- }
}
}
}
}
@@
-102,25
+114,18
@@
public abstract class AltosEepromRecord implements Comparable<AltosEepromRecord>
int s = start + length;
while (s + length <= eeprom.data.size()) {
int s = start + length;
while (s + length <= eeprom.data.size()) {
- if (valid(s))
+ if (
!empty(s) &&
valid(s))
return s;
s += length;
}
return -1;
}
return s;
s += length;
}
return -1;
}
- public boolean hasNext() {
- return next_start() >= 0;
- }
-
public abstract AltosEepromRecord next();
public AltosEepromRecord(AltosEeprom eeprom, int start, int length) {
this.eeprom = eeprom;
this.start = start;
this.length = length;
public abstract AltosEepromRecord next();
public AltosEepromRecord(AltosEeprom eeprom, int start, int length) {
this.eeprom = eeprom;
this.start = start;
this.length = length;
-
- while (start + length < eeprom.data.size() && !valid())
- start += length;
}
}
}
}