altosui: Set 'flight' value in AltosEepromMonitor window during download
[fw/altos] / altosui / AltosEepromDownload.java
index c3bdd15968018d6ad052ac98c640034c5b73caf4..6e2fd061b1cbef6afe1f6ef223a118b95a57782c 100644 (file)
@@ -94,18 +94,26 @@ public class AltosEepromDownload implements Runnable {
 
        void CaptureEeprom(AltosEepromChunk eechunk, int log_format) throws IOException {
                boolean any_valid = false;
+               boolean got_flight = false;
 
                int record_length = 8;
 
                state.set_serial(flights.config_data.serial);
+               monitor.set_serial(flights.config_data.serial);
 
                for (int i = 0; i < AltosEepromChunk.chunk_size && !done; i += record_length) {
-                       AltosEeprom r = eechunk.eeprom(i, log_format);
+                       AltosEeprom r = eechunk.eeprom(i, log_format, state);
+
+                       if (r == null)
+                               continue;
 
                        record_length = r.record_length();
 
                        r.update_state(state);
 
+                       if (!got_flight && state.flight != AltosLib.MISSING)
+                               monitor.set_flight(state.flight);
+
                        /* Monitor state transitions to update display */
                        if (state.state != AltosLib.ao_flight_invalid &&
                            state.state <= AltosLib.ao_flight_landed)
@@ -231,7 +239,10 @@ public class AltosEepromDownload implements Runnable {
                                     serial_line.device.toShortString(),
                                     JOptionPane.ERROR_MESSAGE);
                } catch (InterruptedException ie) {
-                       System.out.printf("download interrupted\n");
+                       show_message(String.format("Connection to \"%s\" interrupted",
+                                                  serial_line.device.toShortString()),
+                                    "Connection Interrupted",
+                                    JOptionPane.ERROR_MESSAGE);
                } catch (TimeoutException te) {
                        show_message(String.format("Connection to \"%s\" failed",
                                                   serial_line.device.toShortString()),