summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2015-02-07 15:09:57 -0800
committerKeith Packard <keithp@keithp.com>2015-02-07 15:19:27 -0800
commit8a2be4d36a3b116d82529805430c5fb665688267 (patch)
tree3d742c64ef8cd2f68ecd33d2129278237bc4dcf3
parente70f3dca01b15b75b0b8795eb71bd12817af4800 (diff)
altosuilib: Wait for product data while scanning
Now that Altos only sends config information once every 5 seconds, we want to keep waiting for that if we're receiving packets successfully. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--altosuilib/AltosScanUI.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/altosuilib/AltosScanUI.java b/altosuilib/AltosScanUI.java
index 7e51a55a..1b30f99d 100644
--- a/altosuilib/AltosScanUI.java
+++ b/altosuilib/AltosScanUI.java
@@ -159,6 +159,8 @@ public class AltosScanUI
Thread thread;
AltosFrequency[] frequencies;
int frequency_index;
+ int packet_count;
+ int tick_count;
void scan_exception(Exception e) {
if (e instanceof FileNotFoundException) {
@@ -200,6 +202,7 @@ public class AltosScanUI
AltosState state = reader.read();
if (state == null)
continue;
+ packet_count++;
if (state.flight != AltosLib.MISSING) {
final AltosScanResult result = new AltosScanResult(state.callsign,
state.serial,
@@ -284,6 +287,8 @@ public class AltosScanUI
return;
}
}
+ packet_count = 0;
+ tick_count = 0;
++frequency_index;
if (frequency_index >= frequencies.length)
frequency_index = 0;
@@ -308,7 +313,9 @@ public class AltosScanUI
}
void tick_timer() throws InterruptedException, TimeoutException {
- next();
+ ++tick_count;
+ if (packet_count == 0 || tick_count > 5)
+ next();
}
public void actionPerformed(ActionEvent e) {
@@ -356,7 +363,6 @@ public class AltosScanUI
if (r != null) {
if (device != null) {
if (reader != null) {
- System.out.printf("frequency %g rate %d\n", r.frequency.frequency, r.rate);
reader.set_telemetry(r.telemetry);
reader.set_telemetry_rate(r.rate);
reader.set_frequency(r.frequency.frequency);