diff options
author | Keith Packard <keithp@keithp.com> | 2016-04-25 23:12:34 -0400 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2016-04-25 23:12:34 -0400 |
commit | 204ae5142702044eb8ad2697a55028e904067958 (patch) | |
tree | eadc8893251e4ebbfd036ccc57ac95aa1aba199d /altoslib | |
parent | 565404599fe9edf9ba16aec348eeb19ea31af743 (diff) |
altosdroid: Add idle mode monitoring, reboot. Start igniters
This adds three idle mode operations -- monitor idle, reboot flight
computer and test igniters. The igniter test isn't quite wired up.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib')
-rw-r--r-- | altoslib/AltosIdleMonitor.java | 18 | ||||
-rw-r--r-- | altoslib/AltosIgnite.java | 15 | ||||
-rw-r--r-- | altoslib/AltosLink.java | 16 |
3 files changed, 31 insertions, 18 deletions
diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index d377fbfd..bcf20ef3 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -28,6 +28,7 @@ public class AltosIdleMonitor extends Thread { AltosIdleFetch fetch; boolean remote; + boolean close_on_exit; double frequency; String callsign; @@ -107,18 +108,25 @@ public class AltosIdleMonitor extends Thread { } } catch (InterruptedException ie) { } - try { - link.close(); - } catch (InterruptedException ie) { + if (close_on_exit) { + try { + link.close(); + } catch (InterruptedException ie) { + } } } - public AltosIdleMonitor(AltosIdleMonitorListener in_listener, AltosLink in_link, boolean in_remote) - throws FileNotFoundException, InterruptedException, TimeoutException { + public AltosIdleMonitor(AltosIdleMonitorListener in_listener, AltosLink in_link, boolean in_remote, boolean in_close_on_exit) { listener = in_listener; link = in_link; remote = in_remote; + close_on_exit = in_close_on_exit; listener_state = new AltosListenerState(); fetch = new AltosIdleFetch(link); } + + public AltosIdleMonitor(AltosIdleMonitorListener in_listener, AltosLink in_link, boolean in_remote) { + this(in_listener, in_link, in_remote, true); + } } + diff --git a/altoslib/AltosIgnite.java b/altoslib/AltosIgnite.java index 61873b22..ab9c2da6 100644 --- a/altoslib/AltosIgnite.java +++ b/altoslib/AltosIgnite.java @@ -24,6 +24,7 @@ import java.util.concurrent.*; public class AltosIgnite { AltosLink link; boolean remote; + boolean close_on_exit; boolean link_started; boolean have_npyro = false; int npyro; @@ -180,14 +181,18 @@ public class AltosIgnite { public void close() throws InterruptedException { stop_link(); - link.close(); + if (close_on_exit) + link.close(); link = null; } - public AltosIgnite(AltosLink in_link, boolean in_remote) - throws FileNotFoundException, TimeoutException, InterruptedException { - + public AltosIgnite(AltosLink in_link, boolean in_remote, boolean in_close_on_exit) { link = in_link; remote = in_remote; + close_on_exit = in_close_on_exit; + } + + public AltosIgnite(AltosLink in_link, boolean in_remote) { + this(in_link, in_remote, true); } -}
\ No newline at end of file +} diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index d3c178b7..73bab3ef 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -539,15 +539,15 @@ public abstract class AltosLink implements Runnable { if (config_data.has_monitor_battery()) { try { - String[] items = adc(); - for (int i = 0; i < items.length;) { - if (items[i].equals("batt")) { - monitor_batt = Integer.parseInt(items[i+1]); - i += 2; - continue; + String[] items = adc(); + for (int i = 0; i < items.length;) { + if (items[i].equals("batt")) { + monitor_batt = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + i++; } - i++; - } } catch (TimeoutException te) { } } |