altosui: Must flush serial line after configuring for telemetry
authorKeith Packard <keithp@keithp.com>
Fri, 3 Sep 2010 19:31:05 +0000 (12:31 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 3 Sep 2010 19:41:06 +0000 (12:41 -0700)
Without flushing the configuration commands to the serial device, it
never sees them as the telemetry input thread doesn't flush.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/altosui/AltosSerial.java

index c3daf3b93cd8c00188ddff48563995d079b65cf0..bc35d6b8b2bdb9bd61fb8a07bb24876d0d9d0b79 100644 (file)
@@ -101,7 +101,8 @@ public class AltosSerial implements Runnable {
        }
 
        public void flush_output() {
-               libaltos.altos_flush(altos);
+               if (altos != null)
+                       libaltos.altos_flush(altos);
        }
 
        public void flush_input() {
@@ -180,8 +181,8 @@ public class AltosSerial implements Runnable {
                input_thread = new Thread(this);
                input_thread.start();
                print("~\nE 0\n");
+               flush_output();
                set_monitor(monitor_mode);
-               flush_input();
        }
 
        public void set_channel(int channel) {
@@ -190,6 +191,7 @@ public class AltosSerial implements Runnable {
                                printf("m 0\nc r %d\nm 1\n", channel);
                        else
                                printf("c r %d\n", channel);
+                       flush_output();
                }
        }
 
@@ -200,12 +202,15 @@ public class AltosSerial implements Runnable {
                                printf("m 1\n");
                        else
                                printf("m 0\n");
+                       flush_output();
                }
        }
 
        public void set_callsign(String callsign) {
-               if (altos != null)
+               if (altos != null) {
                        printf ("c c %s\n", callsign);
+                       flush_output();
+               }
        }
 
        public AltosSerial() {