summaryrefslogtreecommitdiff
path: root/ao-tools/altosui/AltosLog.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-09-03 12:43:45 -0700
committerKeith Packard <keithp@keithp.com>2010-09-03 12:43:45 -0700
commit59798c6fd11502a9c8b66090c23ba50eb250692e (patch)
treec8ea2547ca7c626bab2d401e2d96720ab06d61da /ao-tools/altosui/AltosLog.java
parent16d8d6a8853d09f683b13f9cda3c3174a0aab130 (diff)
altosui: Catch I/O errors on telemetry device, report to user
This catches the USB device being unplugged and makes sure the user sees an error dialog in this case. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'ao-tools/altosui/AltosLog.java')
-rw-r--r--ao-tools/altosui/AltosLog.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/ao-tools/altosui/AltosLog.java b/ao-tools/altosui/AltosLog.java
index 2c241771..f876beba 100644
--- a/ao-tools/altosui/AltosLog.java
+++ b/ao-tools/altosui/AltosLog.java
@@ -24,6 +24,7 @@ import java.text.ParseException;
import java.util.concurrent.LinkedBlockingQueue;
import altosui.AltosSerial;
import altosui.AltosFile;
+import altosui.AltosLine;
/*
* This creates a thread to capture telemetry data and write it to
@@ -31,7 +32,7 @@ import altosui.AltosFile;
*/
class AltosLog implements Runnable {
- LinkedBlockingQueue<String> input_queue;
+ LinkedBlockingQueue<AltosLine> input_queue;
LinkedBlockingQueue<String> pending_queue;
int serial;
int flight;
@@ -64,9 +65,11 @@ class AltosLog implements Runnable {
public void run () {
try {
for (;;) {
- String line = input_queue.take();
+ AltosLine line = input_queue.take();
+ if (line.line == null)
+ continue;
try {
- AltosTelemetry telem = new AltosTelemetry(line);
+ AltosTelemetry telem = new AltosTelemetry(line.line);
if (telem.serial != serial || telem.flight != flight || log_file == null) {
close();
serial = telem.serial;
@@ -77,11 +80,11 @@ class AltosLog implements Runnable {
} catch (AltosCRCException ce) {
}
if (log_file != null) {
- log_file.write(line);
+ log_file.write(line.line);
log_file.write('\n');
log_file.flush();
} else
- pending_queue.put(line);
+ pending_queue.put(line.line);
}
} catch (InterruptedException ie) {
} catch (IOException ie) {
@@ -94,7 +97,7 @@ class AltosLog implements Runnable {
public AltosLog (AltosSerial s) {
pending_queue = new LinkedBlockingQueue<String> ();
- input_queue = new LinkedBlockingQueue<String> ();
+ input_queue = new LinkedBlockingQueue<AltosLine> ();
s.add_monitor(input_queue);
serial = -1;
flight = -1;