Better Windows build-in DFU #3338

no sleep in case of manual DFU
This commit is contained in:
rusefillc 2021-10-22 14:36:54 -04:00
parent ad3d9ea559
commit 3fda7305f1
1 changed files with 13 additions and 7 deletions

View File

@ -80,7 +80,10 @@ public class DfuFlasher {
wnd.appendMsg("rusEFI console can only program on Windows");
return;
}
ExecHelper.submitAction(() -> executeDFU(wnd), DfuFlasher.class + " thread");
ExecHelper.submitAction(() -> {
timeForDfuSwitch(wnd);
executeDFU(wnd);
}, DfuFlasher.class + " thread");
} else {
wnd.appendMsg("Please use manual DFU to change bundle type.");
}
@ -93,12 +96,6 @@ public class DfuFlasher {
}
private static void executeDFU(StatusWindow wnd) {
wnd.appendMsg("Giving time for USB enumeration...");
try {
Thread.sleep(3 * Timeouts.SECOND);
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
AtomicBoolean errorReported = new AtomicBoolean();
StringBuffer stdout = new StringBuffer();
String errorResponse = ExecHelper.executeCommand(FirmwareFlasher.BINARY_LOCATION,
@ -140,6 +137,15 @@ public class DfuFlasher {
wnd.appendMsg("Please power cycle device to exit DFU mode");
}
private static void timeForDfuSwitch(StatusWindow wnd) {
wnd.appendMsg("Giving time for USB enumeration...");
try {
Thread.sleep(2 * Timeouts.SECOND);
} catch (InterruptedException e) {
throw new IllegalStateException(e);
}
}
private static String getDfuCommand() {
String fileName = IniFileModel.findFile(Launcher.INPUT_FILES_PATH, "rusefi", ".dfu");