projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
AltosSiteMapTile: adjust centering calculation
[fw/altos]
/
ao-tools
/
altosui
/
AltosLog.java
diff --git
a/ao-tools/altosui/AltosLog.java
b/ao-tools/altosui/AltosLog.java
index ec868b9c8dd2bcc078cf5b07541a07140e847c56..137147d5cc1aa2079c66ef1cf7d865a0cf2e3965 100644
(file)
--- a/
ao-tools/altosui/AltosLog.java
+++ b/
ao-tools/altosui/AltosLog.java
@@
-22,8
+22,6
@@
import java.lang.*;
import java.util.*;
import java.text.ParseException;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.*;
import java.text.ParseException;
import java.util.concurrent.LinkedBlockingQueue;
-import altosui.AltosSerial;
-import altosui.AltosFile;
/*
* This creates a thread to capture telemetry data and write it to
/*
* This creates a thread to capture telemetry data and write it to
@@
-31,16
+29,22
@@
import altosui.AltosFile;
*/
class AltosLog implements Runnable {
*/
class AltosLog implements Runnable {
- LinkedBlockingQueue<
String>
input_queue;
+ LinkedBlockingQueue<
AltosLine>
input_queue;
LinkedBlockingQueue<String> pending_queue;
int serial;
int flight;
FileWriter log_file;
Thread log_thread;
LinkedBlockingQueue<String> pending_queue;
int serial;
int flight;
FileWriter log_file;
Thread log_thread;
- void close() throws IOException {
- if (log_file != null)
- log_file.close();
+ void close() {
+ if (log_file != null) {
+ try {
+ log_file.close();
+ } catch (IOException io) {
+ }
+ }
+ if (log_thread != null)
+ log_thread.interrupt();
}
boolean open (AltosTelemetry telem) throws IOException {
}
boolean open (AltosTelemetry telem) throws IOException {
@@
-64,9
+68,11
@@
class AltosLog implements Runnable {
public void run () {
try {
for (;;) {
public void run () {
try {
for (;;) {
- String line = input_queue.take();
+ AltosLine line = input_queue.take();
+ if (line.line == null)
+ continue;
try {
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;
if (telem.serial != serial || telem.flight != flight || log_file == null) {
close();
serial = telem.serial;
@@
-74,26
+80,24
@@
class AltosLog implements Runnable {
open(telem);
}
} catch (ParseException pe) {
open(telem);
}
} catch (ParseException pe) {
+ } catch (AltosCRCException ce) {
}
if (log_file != null) {
}
if (log_file != null) {
- log_file.write(line);
+ log_file.write(line
.line
);
log_file.write('\n');
log_file.flush();
} else
log_file.write('\n');
log_file.flush();
} else
- pending_queue.put(line);
+ pending_queue.put(line
.line
);
}
} catch (InterruptedException ie) {
} catch (IOException ie) {
}
}
} catch (InterruptedException ie) {
} catch (IOException ie) {
}
- try {
- close();
- } catch (IOException ie) {
- }
+ close();
}
public AltosLog (AltosSerial s) {
pending_queue = new LinkedBlockingQueue<String> ();
}
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;
s.add_monitor(input_queue);
serial = -1;
flight = -1;