- 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);
+ 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);
+ }