X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosLink.java;h=44202c0c80eb0b6ebe1a53d4d46cadd78d3b7a2d;hp=829a1a63f90070d88baa4cb2659da0bb35f90825;hb=HEAD;hpb=e98235e314ac764509af26c93da9e6d1de8184ea diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 829a1a63..9346563d 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -16,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_12; +package org.altusmetrum.altoslib_14; import java.io.*; import java.util.concurrent.*; @@ -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); } @@ -379,7 +392,7 @@ public abstract class AltosLink implements Runnable { int cal) { if (debug) System.out.printf("set_radio_frequency %7.3f (freq %b) (set %b) %d\n", frequency, has_frequency, has_setting, cal); - if (frequency == 0) + if (frequency == 0 || frequency == AltosLib.MISSING) return; if (has_frequency) set_radio_freq((int) Math.floor (frequency * 1000 + 0.5)); @@ -494,6 +507,20 @@ public abstract class AltosLink implements Runnable { return ret; } + public void synchronize(int timeout) throws InterruptedException { + printf("v\n"); + for (;;) { + String line = get_reply(timeout); + + if (line == null) + break; + if (line.startsWith("software-version")) + break; + if (line.startsWith("altos-loader")) + break; + } + } + public void to_loader() throws InterruptedException { printf("X\n"); flush_output(); @@ -506,7 +533,7 @@ public abstract class AltosLink implements Runnable { public String name; public void start_remote() throws TimeoutException, InterruptedException { - if (frequency == 0.0) + if (frequency == 0.0 || frequency == AltosLib.MISSING) frequency = AltosPreferences.frequency(serial); if (debug) System.out.printf("start remote %7.3f\n", frequency); @@ -526,6 +553,7 @@ public abstract class AltosLink implements Runnable { if (debug) System.out.printf("stop remote\n"); try { + flush_output(); flush_input(); } finally { printf ("~\n");