From a81d028dc62a0a624051fc3c9debb9687fda931e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 21 Sep 2015 06:00:36 +0100 Subject: [PATCH] altosuilib: In display thread, set new state synchronously When replaying telemetry, received_time gets set by both the telemetry reader (when the file is initially read) and by the replay reader (as the telemetry is processed). Because these two events are separated by the time it takes to play the file, the second time is the one we want for figuring out how long since the last telemetry packet. However, if we set the global state when pulling the state out of the telemetry reader, and then the replay reader pauses for a long time, then the voice output thread sees the intermediate time value and thinks that it has been a long time since the last packet was received and reports that the rocket may have crashed. Fix this by just holding the read state until it has been passed by the replay reader and had the received_time set to current time. Signed-off-by: Keith Packard --- altosuilib/AltosDisplayThread.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/altosuilib/AltosDisplayThread.java b/altosuilib/AltosDisplayThread.java index a773022b..fac4ad72 100644 --- a/altosuilib/AltosDisplayThread.java +++ b/altosuilib/AltosDisplayThread.java @@ -219,12 +219,14 @@ public class AltosDisplayThread extends Thread { try { for (;;) { try { - state = reader.read(); - if (state == null) { + AltosState new_state = reader.read(); + if (new_state == null) { + state = null; listener_state.running = false; break; } - reader.update(state); + reader.update(new_state); + state = new_state; show_safely(); told = tell(); idle_thread.notice(told); -- 2.30.2