I bet device manager has command line interface #3547
This commit is contained in:
parent
1471193da9
commit
ac3abdc9b3
|
@ -6,7 +6,7 @@ import java.net.URL;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class rusEFIVersion {
|
||||
public static final int CONSOLE_VERSION = 20211112;
|
||||
public static final int CONSOLE_VERSION = 20211114;
|
||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
public static long classBuildTimeMillis() {
|
||||
|
|
|
@ -10,9 +10,16 @@ import com.rusefi.io.DfuHelper;
|
|||
import com.rusefi.io.IoStream;
|
||||
import com.rusefi.io.serial.SerialIoStreamJSerialComm;
|
||||
import com.rusefi.ui.StatusWindow;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
@ -107,14 +114,21 @@ public class DfuFlasher {
|
|||
wnd.appendMsg("ERROR: Device not connected or STM32 Bootloader driver not installed?");
|
||||
wnd.appendMsg("ERROR: Please try installing drivers using 'Install Drivers' button on rusEFI splash screen");
|
||||
wnd.appendMsg("ERROR: Alternatively please install drivers using Device Manager pointing at 'drivers/silent_st_drivers/DFU_Driver' folder");
|
||||
appendDeviceReport(wnd);
|
||||
wnd.setErrorState(true);
|
||||
} else {
|
||||
wnd.appendMsg(stdout.length() + " / " + errorResponse.length());
|
||||
wnd.appendMsg("ERROR: does not look like DFU has worked!");
|
||||
appendDeviceReport(wnd);
|
||||
wnd.setErrorState(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static void appendDeviceReport(StatusWindow wnd) {
|
||||
for (String line : getDevicesReport())
|
||||
wnd.appendMsg("Devices: " + line);
|
||||
}
|
||||
|
||||
private static void timeForDfuSwitch(StatusWindow wnd) {
|
||||
wnd.appendMsg("Giving time for USB enumeration...");
|
||||
try {
|
||||
|
@ -133,4 +147,29 @@ public class DfuFlasher {
|
|||
|
||||
return DFU_BINARY_LOCATION + "/" + DFU_BINARY + " -c port=usb1 -w " + absolutePath + " -v -s";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static List<String> getDevicesReport() {
|
||||
// todo: assert windows 10, explicit message if not
|
||||
List<String> report = new ArrayList<>();
|
||||
|
||||
try {
|
||||
Process powerShellProcess = Runtime.getRuntime().exec("powershell \"Get-PnpDevice -PresentOnly\"");
|
||||
// Getting the results
|
||||
powerShellProcess.getOutputStream().close();
|
||||
|
||||
String line;
|
||||
BufferedReader stdout = new BufferedReader(new InputStreamReader(powerShellProcess.getInputStream()));
|
||||
while ((line = stdout.readLine()) != null) {
|
||||
String lowerCase = line.toLowerCase();
|
||||
if (!lowerCase.contains("stm32") && !lowerCase.contains("dfu") && !lowerCase.contains("rusefi"))
|
||||
continue;
|
||||
report.add(line);
|
||||
}
|
||||
stdout.close();
|
||||
return report;
|
||||
} catch (IOException e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue