micropeak: Check for empty data when fetching log
authorKeith Packard <keithp@keithp.com>
Sat, 8 Aug 2020 03:18:10 +0000 (20:18 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 8 Aug 2020 03:30:11 +0000 (20:30 -0700)
Don't pop up the graph window and don't save data from an erased
device.

Signed-off-by: Keith Packard <keithp@keithp.com>
micropeak/MicroDownload.java

index 1ede2d9a78989dd14f8599d098191807bdbe7026..be5a8568c0b23947d6aa6f4f28c80a6d160482ac 100644 (file)
@@ -64,21 +64,27 @@ public class MicroDownload extends AltosUIDialog implements Runnable, ActionList
        }
 
        private void done_internal() {
-               setVisible(false);
-               dispose();
-
                if (data != null && data.crc_valid) {
-                       status_value.setText("Received MicroPeak Data");
-                       owner = owner.SetData(data);
-                       MicroSave save = new MicroSave(owner, data);
-                       if (save.runDialog())
-                               owner.SetName(data.name);
+                       if (data.nsamples == 0) {
+                               JOptionPane.showMessageDialog(owner,
+                                                             "No Flight Data Present",
+                                                             "Empty Log",
+                                                             JOptionPane.WARNING_MESSAGE);
+                       } else {
+                               status_value.setText("Received MicroPeak Data");
+                               owner = owner.SetData(data);
+                               MicroSave save = new MicroSave(owner, data);
+                               if (save.runDialog())
+                                       owner.SetName(data.name);
+                       }
                } else {
                        JOptionPane.showMessageDialog(owner,
                                                      "Download Failed",
                                                      "Flight data corrupted",
                                                      JOptionPane.ERROR_MESSAGE);
                }
+               setVisible(false);
+               dispose();
        }
 
        public void drain_queue() {