X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosTelemetryReader.java;h=eeb35cb51c6579e141678d4c2cce352b9d3eb6d2;hb=f65880cf5bfcba5005c32db2b300448e585f3e45;hp=dfbad5fb21c7b431b85cdc9e91990afcf2ffb60e;hpb=5b976a6651f4eb05d30afc08b9e1f27c7e52ae00;p=fw%2Faltos diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index dfbad5fb..eeb35cb5 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -34,7 +34,7 @@ public class AltosTelemetryReader extends AltosFlightReader { AltosLine l = telem.take(); if (l.line == null) throw new IOException("IO error"); - AltosTelemetry telem = AltosTelemetryLegacy.parse(l.line); + AltosTelemetry telem = AltosTelemetry.parse(l.line); if (state == null) state = new AltosState(); else @@ -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); } } }