summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-01-16 14:28:35 -0800
committerKeith Packard <keithp@keithp.com>2011-01-16 14:28:35 -0800
commitfb534aae15f0f1e5d69790e159d0287b6b8a514a (patch)
tree14c917c127c4302b99123337c52ce9d8f0ad0cb8
parentd4add23186b3586c99579d83efdc003f79e9bf7a (diff)
altosui: Use long input flush timeout when remote.
100ms isn't long enough to capture pending remote serial input, so use 300 ms in that mode. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--altosui/AltosSerial.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java
index e609c6b5..f9f9e6e4 100644
--- a/altosui/AltosSerial.java
+++ b/altosui/AltosSerial.java
@@ -48,6 +48,7 @@ public class AltosSerial implements Runnable {
int line_count;
boolean monitor_mode;
static boolean debug;
+ boolean remote;
LinkedList<String> pending_output = new LinkedList<String>();
static void set_debug(boolean new_debug) {
@@ -126,9 +127,13 @@ public class AltosSerial implements Runnable {
public void flush_input() {
flush_output();
boolean got_some;
+
+ int timeout = 100;
+ if (remote)
+ timeout = 300;
do {
try {
- Thread.sleep(100);
+ Thread.sleep(timeout);
} catch (InterruptedException ie) {
}
got_some = !reply_queue.isEmpty();
@@ -259,14 +264,21 @@ public class AltosSerial implements Runnable {
}
public void start_remote() {
+ if (debug)
+ System.out.printf("start remote\n");
set_radio();
printf("p\nE 0\n");
flush_input();
+ remote = true;
}
public void stop_remote() {
+ if (debug)
+ System.out.printf("stop remote\n");
+ flush_input();
printf ("~");
flush_output();
+ remote = false;
}
public AltosSerial(AltosDevice in_device) throws FileNotFoundException, AltosSerialInUseException {