altoslib: Don't close telemetry reader at startup unless something fails
authorKeith Packard <keithp@keithp.com>
Wed, 18 Dec 2013 20:40:22 +0000 (12:40 -0800)
committerKeith Packard <keithp@keithp.com>
Wed, 18 Dec 2013 20:40:22 +0000 (12:40 -0800)
Was always closing the file, which led to very little telemetry being received.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosTelemetryReader.java

index 405c555b35b460c27448ca73fae8bb23a12b6c20..eeb35cb51c6579e141678d4c2cce352b9d3eb6d2 100644 (file)
@@ -124,6 +124,7 @@ public class AltosTelemetryReader extends AltosFlightReader {
        public AltosTelemetryReader (AltosLink in_link)
                throws IOException, InterruptedException, TimeoutException {
                link = in_link;
+               boolean success = false;
                try {
                        log = new AltosLog(link);
                        name = link.name;
@@ -133,8 +134,10 @@ public class AltosTelemetryReader extends AltosFlightReader {
                        telemetry = AltosPreferences.telemetry(link.serial);
                        set_telemetry(telemetry);
                        link.add_monitor(telem);
+                       success = true;
                } finally {
-                       close(true);
+                       if (!success)
+                               close(true);
                }
        }
 }