altosui: Flush telemetry lines before starting to watch for scan results
authorKeith Packard <keithp@keithp.com>
Sun, 17 Jul 2011 04:05:06 +0000 (21:05 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 17 Jul 2011 04:06:15 +0000 (21:06 -0700)
This prevents pending telemetry lines from being incorrectly
attributed to the wrong channel/telemetry.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosScanUI.java
altosui/AltosTelemetryReader.java

index bc1638e..96cab73 100644 (file)
@@ -280,6 +280,11 @@ public class AltosScanUI
                        reader = new AltosTelemetryReader(device);
                        reader.serial.set_channel(channel);
                        reader.serial.set_telemetry(telemetry);
+                       try {
+                               Thread.sleep(100);
+                       } catch (InterruptedException ie) {
+                       }
+                       reader.flush();
                        handler = new TelemetryHandler();
                        thread = new Thread(handler);
                        thread.start();
index 18f1784..23524b2 100644 (file)
@@ -39,6 +39,10 @@ class AltosTelemetryReader extends AltosFlightReader {
                return next;
        }
 
+       void flush() {
+               telem.clear();
+       }
+
        void close(boolean interrupted) {
                serial.remove_monitor(telem);
                log.close();