X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosTelemetryReader.java;h=eeb35cb51c6579e141678d4c2cce352b9d3eb6d2;hp=aea978445578e536b3daf3a5b1ffc73ffaf3675d;hb=216405bc49ef2fc0e9941989f054e41f2fef9cfe;hpb=a9c495c7ca1e08b7ac76b0dab8b3bd9bd3a7edfc diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index aea97844..eeb35cb5 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -54,7 +54,10 @@ public class AltosTelemetryReader extends AltosFlightReader { public void close(boolean interrupted) { link.remove_monitor(telem); log.close(); - link.close(); + try { + link.close(); + } catch (InterruptedException ie) { + } } public void set_frequency(double in_frequency) throws InterruptedException, TimeoutException { @@ -83,7 +86,7 @@ public class AltosTelemetryReader extends AltosFlightReader { else return false; } catch (InterruptedException ie) { - return true; + return false; } catch (TimeoutException te) { return true; } @@ -114,13 +117,14 @@ public class AltosTelemetryReader extends AltosFlightReader { return link.has_monitor_battery(); } - public double monitor_battery() { + public double monitor_battery() throws InterruptedException { return link.monitor_battery(); } public AltosTelemetryReader (AltosLink in_link) throws IOException, InterruptedException, TimeoutException { link = in_link; + boolean success = false; try { log = new AltosLog(link); name = link.name; @@ -130,12 +134,10 @@ public class AltosTelemetryReader extends AltosFlightReader { telemetry = AltosPreferences.telemetry(link.serial); set_telemetry(telemetry); link.add_monitor(telem); - } catch (TimeoutException e) { - close(true); - throw(e); - } catch (InterruptedException e) { - close(true); - throw(e); + success = true; + } finally { + if (!success) + close(true); } } }