diff options
author | Keith Packard <keithp@keithp.com> | 2015-02-07 17:08:03 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2015-02-07 17:08:03 -0800 |
commit | c0ce45100dd205f59cd84465138c74d9b31df0bb (patch) | |
tree | f743025ea75fb3507da19d7126d5bd0353a65407 /altoslib/AltosLink.java | |
parent | 8a2be4d36a3b116d82529805430c5fb665688267 (diff) |
altoslib: Drop telemetry packets processed while monitoring is disabled
A lag between the thread queuing telemetry packets and one pulling
them out can result in stale telemetry data being returned to the
reader. Fix this by dropping telemetry read while monitoring is disabled.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosLink.java')
-rw-r--r-- | altoslib/AltosLink.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 639d2ac7..95acfc44 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -386,7 +386,7 @@ public abstract class AltosLink implements Runnable { flush_output(); } - public void set_monitor(boolean monitor) { + public synchronized void set_monitor(boolean monitor) { monitor_mode = monitor; if (monitor) printf("m %x\n", telemetry_len()); @@ -395,6 +395,10 @@ public abstract class AltosLink implements Runnable { flush_output(); } + public synchronized boolean get_monitor() { + return monitor_mode; + } + private void set_channel(int channel) { if (monitor_mode) printf("m 0\nc r %d\nm %x\n", |