From: Keith Packard Date: Wed, 3 Aug 2011 01:01:52 +0000 (-0700) Subject: altosui: Simple timeouts don't work with query data X-Git-Tag: 0.9.4.5~4 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=3cc2eed6cdafe788a8617ab45c6664077e76411e altosui: Simple timeouts don't work with query data To get the query to come back, it's best to abort and retry the command, other wise the command may have been lost to the previous connection. Signed-off-by: Keith Packard --- diff --git a/altosui/AltosConfigData.java b/altosui/AltosConfigData.java index 6b80171a..1d50ade9 100644 --- a/altosui/AltosConfigData.java +++ b/altosui/AltosConfigData.java @@ -85,7 +85,7 @@ public class AltosConfigData implements Iterable { serial_line.printf("c s\nv\n"); lines = new LinkedList(); for (;;) { - String line = serial_line.get_reply(5000); + String line = serial_line.get_reply_no_dialog(5000); if (line == null) throw new TimeoutException(); if (line.contains("Syntax error")) diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index 8f8f99d7..cb82a574 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -233,12 +233,14 @@ public class AltosSerial implements Runnable { abort = false; timeout_started = false; for (;;) { + System.out.printf("timeout %d\n", timeout); AltosLine line = reply_queue.poll(timeout, TimeUnit.MILLISECONDS); if (line != null) { stop_timeout_dialog(); --in_reply; return line.line; } + System.out.printf("no line remote %b can_cancel %b\n", remote, can_cancel); if (!remote || !can_cancel || check_timeout()) { --in_reply; return null; @@ -246,6 +248,14 @@ public class AltosSerial implements Runnable { } } + public String get_reply_no_dialog(int timeout) throws InterruptedException, TimeoutException { + flush_output(); + AltosLine line = reply_queue.poll(timeout, TimeUnit.MILLISECONDS); + if (line != null) + return line.line; + return null; + } + public void add_monitor(LinkedBlockingQueue q) { set_monitor(true); monitors.add(q);