- log = new AltosLog(link);
- name = link.name;
- previous = null;
- telem = new LinkedBlockingQueue<AltosLine>();
- frequency = AltosPreferences.frequency(link.serial);
- set_frequency(frequency);
- telemetry = AltosPreferences.telemetry(link.serial);
- set_telemetry(telemetry);
- link.add_monitor(telem);
+ stacked = in_stacked;
+ boolean success = false;
+ try {
+ log = new AltosLog(link);
+ name = link.name;
+ telem = new LinkedBlockingQueue<AltosLine>();
+ frequency = AltosPreferences.frequency(link.serial);
+ set_frequency(frequency);
+ telemetry = AltosPreferences.telemetry(link.serial);
+ set_telemetry(telemetry);
+ telemetry_rate = AltosPreferences.telemetry_rate(link.serial);
+ set_telemetry_rate(telemetry_rate);
+ link.add_monitor(telem);
+ success = true;
+ } finally {
+ if (!success)
+ close(true);
+ }
+ }
+
+ private static AltosFlightReader existing_data(AltosLink link) {
+ if (link == null)
+ return null;
+
+ File file = AltosPreferences.logfile(link.serial);
+ if (file != null) {
+ AltosStateIterable iterable = AltosStateIterable.iterable(file);
+ if (iterable != null)
+ return new AltosReplayReader(iterable.iterator(), file, false);
+ }
+ return null;
+ }
+
+ public AltosTelemetryReader(AltosLink link)
+ throws IOException, InterruptedException, TimeoutException {
+ this(link, null);