projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altosui: Deal with serial port exceptions a bit better
[fw/altos]
/
altosui
/
AltosTelemetryIterable.java
diff --git
a/altosui/AltosTelemetryIterable.java
b/altosui/AltosTelemetryIterable.java
index 90a08485c8301611ebd7e66d8d751f20d423d66e..278cbfb75b9e2e28ebceff7aa5f0621f84c60cb2 100644
(file)
--- a/
altosui/AltosTelemetryIterable.java
+++ b/
altosui/AltosTelemetryIterable.java
@@
-22,7
+22,7
@@
import java.util.*;
import java.text.*;
public class AltosTelemetryIterable extends AltosRecordIterable {
import java.text.*;
public class AltosTelemetryIterable extends AltosRecordIterable {
-
LinkedList<AltosRecord>
records;
+
TreeSet<AltosRecord>
records;
public Iterator<AltosRecord> iterator () {
return records.iterator();
public Iterator<AltosRecord> iterator () {
return records.iterator();
@@
-41,7
+41,7
@@
public class AltosTelemetryIterable extends AltosRecordIterable {
int boost_tick = 0;
AltosRecord previous = null;
int boost_tick = 0;
AltosRecord previous = null;
- records = new
LinkedLis
t<AltosRecord> ();
+ records = new
TreeSe
t<AltosRecord> ();
try {
for (;;) {
try {
for (;;) {
@@
-53,12
+53,11
@@
public class AltosTelemetryIterable extends AltosRecordIterable {
AltosRecord record = AltosTelemetry.parse(line, previous);
if (record == null)
break;
AltosRecord record = AltosTelemetry.parse(line, previous);
if (record == null)
break;
- previous = record;
if (records.isEmpty()) {
current_tick = record.tick;
} else {
if (records.isEmpty()) {
current_tick = record.tick;
} else {
- int tick = record.tick
| (current_tick & ~ 0xffff)
;
-
if
(tick < current_tick - 0x1000)
+ int tick = record.tick;
+
while
(tick < current_tick - 0x1000)
tick += 0x10000;
current_tick = tick;
record.tick = current_tick;
tick += 0x10000;
current_tick = tick;
record.tick = current_tick;
@@
-74,7
+73,9
@@
public class AltosTelemetryIterable extends AltosRecordIterable {
has_gps = true;
if (record.main != AltosRecord.MISSING)
has_ignite = true;
has_gps = true;
if (record.main != AltosRecord.MISSING)
has_ignite = true;
- records.add(record);
+ if (previous != null && previous.tick != record.tick)
+ records.add(previous);
+ previous = record;
} catch (ParseException pe) {
System.out.printf("parse exception %s\n", pe.getMessage());
} catch (AltosCRCException ce) {
} catch (ParseException pe) {
System.out.printf("parse exception %s\n", pe.getMessage());
} catch (AltosCRCException ce) {
@@
-84,6
+85,9
@@
public class AltosTelemetryIterable extends AltosRecordIterable {
System.out.printf("io exception\n");
}
System.out.printf("io exception\n");
}
+ if (previous != null)
+ records.add(previous);
+
/* adjust all tick counts to be relative to boost time */
for (AltosRecord r : this)
r.time = (r.tick - boost_tick) / 100.0;
/* adjust all tick counts to be relative to boost time */
for (AltosRecord r : this)
r.time = (r.tick - boost_tick) / 100.0;