diff options
author | Keith Packard <keithp@keithp.com> | 2010-11-19 18:25:48 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2010-11-19 18:25:48 -0800 |
commit | 9ffc2eb53a47e435f39b02896b0e43ae5f47f450 (patch) | |
tree | 31fa4b96ea6c3bd2138b62540d2c94d50859824c /ao-tools/altosui/AltosSerial.java | |
parent | 68078eab3c07d8dc83302747cf6f3dcb1797c6ce (diff) |
altosui: Use timeouts to recover from broken packet links.
This puts timeouts every place the system reads from the packet link
and aborts the in-progress operation if it takes more than a second to
get a response.
Also mixed in here are persistent igniter status displays for the
ejection testing UI.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'ao-tools/altosui/AltosSerial.java')
-rw-r--r-- | ao-tools/altosui/AltosSerial.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ao-tools/altosui/AltosSerial.java b/ao-tools/altosui/AltosSerial.java index 99a92fdb..0d32a5ae 100644 --- a/ao-tools/altosui/AltosSerial.java +++ b/ao-tools/altosui/AltosSerial.java @@ -132,6 +132,14 @@ public class AltosSerial implements Runnable { return line.line; } + public String get_reply(int timeout) throws InterruptedException { + flush_output(); + AltosLine line = reply_queue.poll(timeout, TimeUnit.MILLISECONDS); + if (line == null) + return null; + return line.line; + } + public void add_monitor(LinkedBlockingQueue<AltosLine> q) { set_monitor(true); monitors.add(q); @@ -185,10 +193,9 @@ public class AltosSerial implements Runnable { throw new AltosSerialInUseException(device); devices_opened.add(device.getPath()); } - close(); altos = libaltos.altos_open(device); if (altos == null) - throw new FileNotFoundException(device.getPath()); + throw new FileNotFoundException(device.toString()); input_thread = new Thread(this); input_thread.start(); print("~\nE 0\n"); |