Auto DFU throws NPE in case of no ports connected fix #2949
This commit is contained in:
parent
39448e3c79
commit
0a42b1c701
|
@ -6,7 +6,7 @@ import java.net.URL;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class rusEFIVersion {
|
||||
public static final int CONSOLE_VERSION = 20210618;
|
||||
public static final int CONSOLE_VERSION = 20210711;
|
||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
public static long classBuildTimeMillis() {
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.rusefi.autodetect.PortDetector;
|
|||
import com.rusefi.io.DfuHelper;
|
||||
import com.rusefi.io.IoStream;
|
||||
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
||||
import com.rusefi.ui.StatusConsumer;
|
||||
import com.rusefi.ui.StatusWindow;
|
||||
import com.rusefi.ui.util.URLLabel;
|
||||
|
||||
|
@ -33,15 +32,21 @@ public class DfuFlasher {
|
|||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
doAutoDfu(comboPorts);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
manualButton.addActionListener(e -> runDfuProgramming());
|
||||
}
|
||||
|
||||
public static void doAutoDfu(JComboBox<String> comboPorts) {
|
||||
String port = comboPorts.getSelectedItem().toString();
|
||||
public static void doAutoDfu(Object selectedItem) {
|
||||
String port = selectedItem.toString();
|
||||
StringBuilder messages = new StringBuilder();
|
||||
|
||||
if (!PortDetector.isAutoPort(port)) {
|
||||
|
|
|
@ -56,7 +56,7 @@ public class ProgramSelector {
|
|||
// todo: add ST-LINK no-assert mode
|
||||
|
||||
if (isAutoDfu) {
|
||||
DfuFlasher.doAutoDfu(comboPorts);
|
||||
DfuFlasher.doAutoDfu(comboPorts.getSelectedItem());
|
||||
} else if (isManualDfu){
|
||||
DfuFlasher.runDfuProgramming();
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue