X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosTelemetryReader.java;h=3dff661a3e3a91ed876166d32a59b334c17f4cd2;hb=ae1174317fc476e39077f7dc257ec08709c6b301;hp=dfbad5fb21c7b431b85cdc9e91990afcf2ffb60e;hpb=5b976a6651f4eb05d30afc08b9e1f27c7e52ae00;p=fw%2Faltos diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index dfbad5fb..3dff661a 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_2; +package org.altusmetrum.altoslib_4; import java.text.*; import java.io.*; @@ -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); } } }