diff options
author | Keith Packard <keithp@keithp.com> | 2018-08-22 00:56:25 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2018-08-22 01:01:46 -0700 |
commit | 75420fecbc76ab718661718ada249673e139a29d (patch) | |
tree | c36cbadb26e5be11be2124ee79ea747091739e4b | |
parent | d8017f921649d2176d90239e02275dc5ef793815 (diff) |
altosuilib: Show a more useful message when the flash target device is unknown
The flashing code uses the new symbol table to find information in the
existing device; if they don't match at all, there won't be anything
about the target device known. Tell the user this, rather than
displaying mystic information (or crashing).
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | altosuilib/AltosFlashUI.java | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/altosuilib/AltosFlashUI.java b/altosuilib/AltosFlashUI.java index d6c7a16f..6dc80272 100644 --- a/altosuilib/AltosFlashUI.java +++ b/altosuilib/AltosFlashUI.java @@ -278,6 +278,12 @@ public class AltosFlashUI } boolean rom_config_matches (AltosRomconfig a, AltosRomconfig b) { + if (a == null || b == null) + return (a == null && b == null); + + if (!a.valid || !b.valid) + return false; + if (a.usb_id != null && b.usb_id != null && (a.usb_id.vid != b.usb_id.vid || a.usb_id.pid != b.usb_id.pid)) @@ -294,16 +300,27 @@ public class AltosFlashUI AltosRomconfig new_config; if (!rom_config_matches(existing_config, image_config)) { - int ret = JOptionPane.showConfirmDialog(this, - String.format("Device is %04x:%04x %s\nImage is %04x:%04x %s\nFlash anyways?", - existing_config.usb_id.vid, - existing_config.usb_id.pid, - existing_config.usb_product, - image_config.usb_id.vid, - image_config.usb_id.pid, - image_config.usb_product), - "Image doesn't match Device", - JOptionPane.YES_NO_OPTION); + int ret; + if (existing_config == null || !existing_config.valid) { + ret = JOptionPane.showConfirmDialog(this, + String.format("Cannot determine target device type\nImage is %04x:%04x %s\nFlash anyways?", + image_config.usb_id.vid, + image_config.usb_id.pid, + image_config.usb_product), + "Unknown Target Device", + JOptionPane.YES_NO_OPTION); + } else { + ret = JOptionPane.showConfirmDialog(this, + String.format("Device is %04x:%04x %s\nImage is %04x:%04x %s\nFlash anyways?", + existing_config.usb_id.vid, + existing_config.usb_id.pid, + existing_config.usb_product, + image_config.usb_id.vid, + image_config.usb_id.pid, + image_config.usb_product), + "Image doesn't match Device", + JOptionPane.YES_NO_OPTION); + } if (ret != JOptionPane.YES_OPTION) return false; } |