diff options
author | Keith Packard <keithp@keithp.com> | 2010-08-24 16:43:38 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2010-08-24 16:43:38 -0700 |
commit | 99400fdc0f19ef538fc362dde5c3ab5b7cdac409 (patch) | |
tree | 79e56c346ec962ea2b110a6e9df2dc66bf4eda31 | |
parent | ba086cc77273efe5397f60dcaccd1e3771441481 (diff) |
altosui: flush replies from serial link when entering debug mode
We use replies in debug mode a lot and depend on them matching the
expected parameters. The case which caused trouble was using
TeleMetrum to reprogram TeleDongle -- sending the 'm 0' command (to
disable telemetry monitoring on TeleDongle) to the TeleMetrum caused
it to reply 'Syntax Error' which confused the subsequent flashing
operation. Flushing that reply gets things back in sync.
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | ao-tools/altosui/AltosDebug.java | 1 | ||||
-rw-r--r-- | ao-tools/altosui/AltosSerial.java | 10 |
2 files changed, 10 insertions, 1 deletions
diff --git a/ao-tools/altosui/AltosDebug.java b/ao-tools/altosui/AltosDebug.java index df40410a..06c9a0bd 100644 --- a/ao-tools/altosui/AltosDebug.java +++ b/ao-tools/altosui/AltosDebug.java @@ -98,6 +98,7 @@ public class AltosDebug extends AltosSerial { void ensure_debug_mode() { if (!debug_mode) { printf("m 0\nD\n"); + flush_reply(); debug_mode = true; } } diff --git a/ao-tools/altosui/AltosSerial.java b/ao-tools/altosui/AltosSerial.java index d02e25a9..3684f253 100644 --- a/ao-tools/altosui/AltosSerial.java +++ b/ao-tools/altosui/AltosSerial.java @@ -66,8 +66,10 @@ public class AltosSerial implements Runnable { LinkedBlockingQueue<String> q = monitors.get(e); q.put(line); } - } else + } else { +// System.out.printf("GOT: %s\n", line); reply_queue.put(line); + } line = ""; } } else { @@ -80,6 +82,11 @@ public class AltosSerial implements Runnable { } public void flush_reply() { + libaltos.altos_flush(altos); + try { + Thread.sleep(100); + } catch (InterruptedException ie) { + } reply_queue.clear(); } @@ -132,6 +139,7 @@ public class AltosSerial implements Runnable { } public void print(String data) { +// System.out.printf("\"%s\" ", data); for (int i = 0; i < data.length(); i++) putc(data.charAt(i)); } |