Auto DFU throw NPE in case of no ports connected #2949
This commit is contained in:
parent
774e0525e3
commit
3d823f5789
|
@ -34,18 +34,18 @@ public class DfuFlasher {
|
|||
public void actionPerformed(ActionEvent event) {
|
||||
// todo: better usability would be to disable "Program" port in case of no ports found
|
||||
Object selectedItem = comboPorts.getSelectedItem();
|
||||
if (selectedItem == null) {
|
||||
JOptionPane.showMessageDialog(comboPorts, "Failed to located serial ports");
|
||||
} else {
|
||||
doAutoDfu(selectedItem);
|
||||
}
|
||||
doAutoDfu(selectedItem, comboPorts);
|
||||
}
|
||||
});
|
||||
|
||||
manualButton.addActionListener(e -> runDfuProgramming());
|
||||
}
|
||||
|
||||
public static void doAutoDfu(Object selectedItem) {
|
||||
public static void doAutoDfu(Object selectedItem, JComponent parent) {
|
||||
if (selectedItem == null) {
|
||||
JOptionPane.showMessageDialog(parent, "Failed to located serial ports");
|
||||
return;
|
||||
}
|
||||
String port = selectedItem.toString();
|
||||
StringBuilder messages = new StringBuilder();
|
||||
|
||||
|
|
|
@ -50,13 +50,12 @@ public class ProgramSelector {
|
|||
|
||||
getConfig().getRoot().setProperty(getClass().getSimpleName(), selectedMode);
|
||||
|
||||
|
||||
boolean isAutoDfu = selectedMode.equals(AUTO_DFU);
|
||||
boolean isManualDfu = selectedMode.equals(MANUAL_DFU);
|
||||
// todo: add ST-LINK no-assert mode
|
||||
|
||||
if (isAutoDfu) {
|
||||
DfuFlasher.doAutoDfu(comboPorts.getSelectedItem());
|
||||
DfuFlasher.doAutoDfu(comboPorts.getSelectedItem(), comboPorts);
|
||||
} else if (isManualDfu){
|
||||
DfuFlasher.runDfuProgramming();
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue