X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosEepromRecord.java;h=e5196c50039a69434d36bd661f612ad50bb3ae08;hb=62eae8a17d870e8ac6937ba23da01a5fbc652c6c;hp=e61a7159f19af1e4673b80ed560623ebeb7c3a47;hpb=bd2480fd757b67557d9c7de42e402034002c3e37;p=fw%2Faltos diff --git a/altosui/AltosEepromRecord.java b/altosui/AltosEepromRecord.java index e61a7159..e5196c50 100644 --- a/altosui/AltosEepromRecord.java +++ b/altosui/AltosEepromRecord.java @@ -65,20 +65,31 @@ public class AltosEepromRecord { throw new TimeoutException(); int[] values = ParseHex(line); - if (values == null) - throw new ParseException(String.format("invalid line %s", line), 0); + if (values == null || values.length < 9) { + System.out.printf("invalid line %s", line); + throw new ParseException(String.format("inalid line %s", line), 0); + } if (values[0] != (addr & 0xff)) throw new ParseException(String.format("data address out of sync at 0x%x", addr), 0); - if (checksum(values) != 0) - throw new ParseException(String.format("invalid checksum at 0x%x", addr), 0); - + int i; + for (i = 1; i < values.length; i++) + if (values[i] != 0xff) + break; cmd = values[1]; + tick_valid = true; + if (i != values.length) { + if (checksum(values) != 0) + throw new ParseException(String.format("invalid checksum at 0x%x in line %s", addr, line), 0); + } else { + cmd = Altos.AO_LOG_INVALID; + tick_valid = false; + } + tick = values[3] + (values[4] << 8); a = values[5] + (values[6] << 8); b = values[7] + (values[8] << 8); data = null; - tick_valid = true; } public AltosEepromRecord (String line) {