altoslib: Make stop_remote delay depend on the data rate
authorKeith Packard <keithp@keithp.com>
Thu, 5 Jul 2018 03:25:58 +0000 (20:25 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 5 Jul 2018 03:25:58 +0000 (20:25 -0700)
It takes longer to flush commands at 2400 baud, so wait longer when
disabling remote mode.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosLink.java

index 829a1a63f90070d88baa4cb2659da0bb35f90825..3ad3489173e149557c7d0caf437eae9ab8bfdf93 100644 (file)
@@ -339,9 +339,22 @@ public abstract class AltosLink implements Runnable {
 
 
        public void flush_input() throws InterruptedException {
-               if (remote)
-                       flush_input(500);
-               else
+               if (remote) {
+                       int timeout = 500;
+                       switch (telemetry_rate) {
+                       case AltosLib.ao_telemetry_rate_38400:
+                       default:
+                               timeout = 500;
+                               break;
+                       case AltosLib.ao_telemetry_rate_9600:
+                               timeout = 1000;
+                               break;
+                       case AltosLib.ao_telemetry_rate_2400:
+                               timeout = 2000;
+                               break;
+                       }
+                       flush_input(timeout);
+               } else
                        flush_input(100);
        }