The log thread automatically switches output files when the incoming
telemetry changes. Don't use 'close' for that as 'close' terminates
the log thread as well as closing the file. Create a new
'close_log_file' function which just closes the file.
Signed-off-by: Keith Packard <keithp@keithp.com>
FileWriter log_file;
Thread log_thread;
- void close() {
+ private void close_log_file() {
if (log_file != null) {
try {
log_file.close();
} catch (IOException io) {
}
+ log_file = null;
}
- if (log_thread != null)
+ }
+
+ void close() {
+ close_log_file();
+ if (log_thread != null) {
+ log_thread.interrupt();
+ log_thread = null;
log_thread.interrupt();
+ }
}
boolean open (AltosTelemetry telem) throws IOException {
try {
AltosTelemetry telem = new AltosTelemetry(line.line);
if (telem.serial != serial || telem.flight != flight || log_file == null) {
- close();
+ close_log_file();
serial = telem.serial;
flight = telem.flight;
open(telem);