diff options
| author | Mike Beattie <mike@ethernal.org> | 2013-09-03 15:10:23 +1200 |
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2013-09-05 11:42:22 -0700 |
| commit | ee14ad16c242e8bd7a9d33ebf569211d1490b8e1 (patch) | |
| tree | 4bba37bb571389888a741eb62e688464ce9f7fe9 /altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java | |
| parent | 5b976a6651f4eb05d30afc08b9e1f27c7e52ae00 (diff) | |
altosdroid: update to support new state code
Signed-off-by: Mike Beattie <mike@ethernal.org>
Conflicts:
altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java
altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java
altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java
Diffstat (limited to 'altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java')
| -rw-r--r-- | altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java index e37019fd..cdd1decd 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java @@ -37,25 +37,29 @@ public class TelemetryReader extends Thread { Handler handler;
AltosLink link;
- AltosRecord previous;
+ AltosState state = null;
- LinkedBlockingQueue<AltosLine> telem;
+ LinkedBlockingQueue<AltosLine> telemQueue;
- public AltosRecord read() throws ParseException, AltosCRCException, InterruptedException, IOException {
- AltosLine l = telem.take();
+ public AltosState read() throws ParseException, AltosCRCException, InterruptedException, IOException {
+ AltosLine l = telemQueue.take();
if (l.line == null)
throw new IOException("IO error");
- AltosRecord next = AltosTelemetry.parse(l.line, previous);
- previous = next;
- return next;
+ AltosTelemetry telem = AltosTelemetryLegacy.parse(l.line);
+ if (state == null)
+ state = new AltosState();
+ else
+ state = state.clone();
+ telem.update_state(state);
+ return state;
}
public void close() {
- previous = null;
- link.remove_monitor(telem);
+ state = null;
+ link.remove_monitor(telemQueue);
link = null;
- telem.clear();
- telem = null;
+ telemQueue.clear();
+ telemQueue = null;
}
public void run() {
@@ -64,10 +68,7 @@ public class TelemetryReader extends Thread { try {
for (;;) {
try {
- AltosRecord record = read();
- if (record == null)
- break;
- state = new AltosState(record, state);
+ state = read();
handler.obtainMessage(TelemetryService.MSG_TELEMETRY, state).sendToTarget();
} catch (ParseException pp) {
Log.e(TAG, String.format("Parse error: %d \"%s\"", pp.getErrorOffset(), pp.getMessage()));
@@ -87,8 +88,8 @@ public class TelemetryReader extends Thread { link = in_link;
handler = in_handler;
- previous = null;
- telem = new LinkedBlockingQueue<AltosLine>();
- link.add_monitor(telem);
+ state = null;
+ telemQueue = new LinkedBlockingQueue<AltosLine>();
+ link.add_monitor(telemQueue);
}
}
|
