integration
This commit is contained in:
parent
e3bac550a6
commit
e5ef8e71f3
|
@ -2,6 +2,11 @@ package com.rusefi.io;
|
|||
|
||||
public interface UpdateOperationCallbacks {
|
||||
void log(String message);
|
||||
|
||||
default void append(String message) {
|
||||
log(message);
|
||||
}
|
||||
|
||||
void done();
|
||||
void error();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public enum SerialPortScanner {
|
|||
|
||||
private volatile boolean isRunning = true;
|
||||
|
||||
private static final boolean SHOW_SOCKETCAN = isLinux();
|
||||
private static final boolean SHOW_SOCKETCAN = FileLog.isLinux();
|
||||
|
||||
static final String AUTO_SERIAL = "Auto Serial";
|
||||
|
||||
|
@ -58,9 +58,9 @@ public enum SerialPortScanner {
|
|||
|
||||
if (includeSlowLookup) {
|
||||
ports.addAll(TcpConnector.getAvailablePorts());
|
||||
createStatusWindow("DFU update")
|
||||
stLinkConnected = DfuFlasher.detectStLink(StatusConsumer.VOID);
|
||||
PCANConnected = DfuFlasher.detectPcan(StatusConsumer.VOID);
|
||||
dfuConnected = DfuFlasher.detectSTM32BootloaderDriverState(UpdateOperationCallbacks.DUMMY);
|
||||
stLinkConnected = DfuFlasher.detectStLink(UpdateOperationCallbacks.DUMMY);
|
||||
PCANConnected = DfuFlasher.detectPcan(UpdateOperationCallbacks.DUMMY);
|
||||
} else {
|
||||
dfuConnected = false;
|
||||
stLinkConnected = false;
|
||||
|
|
|
@ -96,7 +96,7 @@ public class DfuFlasher {
|
|||
}
|
||||
});
|
||||
if (signature.get() == null) {
|
||||
wnd.append("*** ERROR *** rusEFI has not responded on selected " + port + "\n" +
|
||||
callbacks.append("*** ERROR *** rusEFI has not responded on selected " + port + "\n" +
|
||||
"Maybe try automatic serial port detection?");
|
||||
callbacks.error();
|
||||
return null;
|
||||
|
@ -114,11 +114,11 @@ public class DfuFlasher {
|
|||
return null;
|
||||
}).getSerialPort();
|
||||
if (port == null) {
|
||||
wnd.append("*** ERROR *** rusEFI serial port not detected");
|
||||
wnd.setErrorState();
|
||||
callbacks.append("*** ERROR *** rusEFI serial port not detected");
|
||||
callbacks.error();
|
||||
return null;
|
||||
} else {
|
||||
wnd.append("Detected rusEFI on " + port + "\n");
|
||||
callbacks.append("Detected rusEFI on " + port + "\n");
|
||||
}
|
||||
}
|
||||
return isSignatureValidated;
|
||||
|
@ -146,7 +146,7 @@ public class DfuFlasher {
|
|||
boolean driverIsHappy = detectSTM32BootloaderDriverState(callbacks);
|
||||
if (!driverIsHappy) {
|
||||
callbacks.append("*** DRIVER ERROR? *** Did you have a chance to try 'Install Drivers' button on top of rusEFI console start screen?");
|
||||
callbacks.setErrorState();
|
||||
callbacks.error();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -172,11 +172,11 @@ public class DfuFlasher {
|
|||
callbacks.done();
|
||||
} else if (stdout.toString().contains("Target device not found")) {
|
||||
callbacks.append("ERROR: Device not connected or STM32 Bootloader driver not installed?");
|
||||
appendWindowsVersion(wnd);
|
||||
appendWindowsVersion(callbacks);
|
||||
callbacks.append("ERROR: Please try installing drivers using 'Install Drivers' button on rusEFI splash screen");
|
||||
callbacks.append("ERROR: Alternatively please install drivers using Device Manager pointing at 'drivers/silent_st_drivers/DFU_Driver' folder");
|
||||
appendDeviceReport(wnd);
|
||||
wnd.setErrorState();
|
||||
appendDeviceReport(callbacks);
|
||||
callbacks.error();
|
||||
} else {
|
||||
appendWindowsVersion(callbacks);
|
||||
appendDeviceReport(callbacks);
|
||||
|
@ -189,10 +189,10 @@ public class DfuFlasher {
|
|||
return detectDevice(callbacks, WMIC_DFU_QUERY_COMMAND, "ConfigManagerErrorCode=0");
|
||||
}
|
||||
|
||||
public static boolean detectStLink(StatusConsumer wnd) {
|
||||
public static boolean detectStLink(UpdateOperationCallbacks wnd) {
|
||||
return detectDevice(wnd, WMIC_STLINK_QUERY_COMMAND, "STLink");
|
||||
}
|
||||
public static boolean detectPcan(StatusConsumer wnd) {
|
||||
public static boolean detectPcan(UpdateOperationCallbacks wnd) {
|
||||
return detectDevice(wnd, WMIC_PCAN_QUERY_COMMAND, "PCAN");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package com.rusefi.maintenance;
|
||||
|
||||
import com.rusefi.FileLog;
|
||||
import com.rusefi.ui.StatusConsumer;
|
||||
import com.rusefi.ui.StatusWindow;
|
||||
import com.rusefi.io.UpdateOperationCallbacks;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
@ -33,8 +32,7 @@ public class DriverInstall {
|
|||
if (dialogResult != JOptionPane.YES_OPTION)
|
||||
return;
|
||||
|
||||
final StatusWindow wnd = new StatusWindow();
|
||||
wnd.showFrame("Windows rusEFI ST Drivers");
|
||||
final UpdateOperationCallbacks wnd = new UpdateStatusWindow("Windows rusEFI ST Drivers");
|
||||
|
||||
ExecHelper.submitAction(() -> installDrivers(wnd), getClass() + " thread");
|
||||
|
||||
|
@ -44,7 +42,7 @@ public class DriverInstall {
|
|||
return button;
|
||||
}
|
||||
|
||||
private static void installDrivers(StatusConsumer wnd) {
|
||||
private static void installDrivers(UpdateOperationCallbacks wnd) {
|
||||
FileLog.MAIN.logLine("IsWindows=" + FileLog.isWindows());
|
||||
if (!new File(FOLDER).exists()) {
|
||||
String message = FOLDER + " not found";
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.rusefi.maintenance;
|
|||
|
||||
import com.rusefi.Launcher;
|
||||
import com.rusefi.core.io.BundleUtil;
|
||||
import com.rusefi.io.UpdateOperationCallbacks;
|
||||
import com.rusefi.ui.StatusWindow;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -57,7 +58,7 @@ public class FirmwareFlasher {
|
|||
return OPENOCD_EXE + " -f openocd/" + cfg;
|
||||
}
|
||||
|
||||
protected static String executeOpenOCDCommand(String command, StatusWindow wnd) {
|
||||
protected static String executeOpenOCDCommand(String command, UpdateOperationCallbacks wnd) {
|
||||
return ExecHelper.executeCommand(OPENOCD_BINARY_LOCATION,
|
||||
OPENOCD_BINARY_LOCATION + File.separator + command,
|
||||
OPENOCD_EXE, wnd);
|
||||
|
|
|
@ -145,7 +145,7 @@ public class ProgramSelector {
|
|||
boolean hasDfuDevice = currentHardware.isDfuFound();
|
||||
|
||||
mode.removeAllItems();
|
||||
if (IS_WIN) {
|
||||
if (FileLog.isWindows()) {
|
||||
if (hasSerialPorts) {
|
||||
mode.addItem(AUTO_DFU);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.devexperts.logging.Logging;
|
|||
import com.rusefi.core.io.BundleUtil;
|
||||
import com.rusefi.core.rusEFIVersion;
|
||||
import com.rusefi.core.ui.FrameHelper;
|
||||
import com.rusefi.io.UpdateOperationCallbacks;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -17,7 +18,7 @@ import static com.devexperts.logging.Logging.getLogging;
|
|||
* Andrey Belomutskiy, (c) 2013-2020
|
||||
* 3/7/2015
|
||||
*/
|
||||
public class StatusWindow implements StatusConsumer {
|
||||
public class StatusWindow implements StatusConsumer, UpdateOperationCallbacks {
|
||||
private static final Logging log = getLogging(StatusWindow.class);
|
||||
|
||||
private static final Color LIGHT_RED = new Color(255, 102, 102);
|
||||
|
@ -60,7 +61,24 @@ public class StatusWindow implements StatusConsumer {
|
|||
copyContentToClipboard();
|
||||
}
|
||||
|
||||
public void setSuccessState() {
|
||||
@Override
|
||||
public void log(String message) {
|
||||
append(message);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
setSuccessState();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error() {
|
||||
setErrorState();
|
||||
}
|
||||
|
||||
public void setSuccessState() {
|
||||
logTextArea.setBackground(LIGHT_GREEN);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.rusefi.autodetect.PortDetector;
|
|||
import com.rusefi.core.ui.FrameHelper;
|
||||
import com.rusefi.maintenance.DfuFlasher;
|
||||
import com.rusefi.maintenance.ProgramSelector;
|
||||
import com.rusefi.maintenance.UpdateStatusWindow;
|
||||
import com.rusefi.ui.LogoHelper;
|
||||
import com.rusefi.ui.util.HorizontalLine;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
|
@ -33,7 +34,7 @@ public class BasicStartupFrame {
|
|||
panel.add(ToolButtons.createShowDeviceManagerButton());
|
||||
|
||||
JButton update = ProgramSelector.createUpdateFirmwareButton();
|
||||
update.addActionListener(e -> DfuFlasher.doAutoDfu(PortDetector.AUTO, update));
|
||||
update.addActionListener(e -> DfuFlasher.doAutoDfu(update, PortDetector.AUTO, new UpdateStatusWindow("Update")));
|
||||
panel.add(update);
|
||||
} else {
|
||||
panel.add(new JLabel("Sorry only works on Windows"));
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rusefi.maintenance;
|
||||
|
||||
import com.rusefi.io.UpdateOperationCallbacks;
|
||||
import com.rusefi.ui.StatusConsumer;
|
||||
|
||||
import static com.rusefi.maintenance.DfuFlasher.detectPcan;
|
||||
|
@ -7,7 +8,7 @@ import static com.rusefi.maintenance.DfuFlasher.detectStLink;
|
|||
|
||||
public class DfuFlasherSandbox {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("detectStLink " + detectStLink(StatusConsumer.VOID));
|
||||
System.out.println("detectPcan " + detectPcan(StatusConsumer.VOID));
|
||||
System.out.println("detectStLink " + detectStLink(UpdateOperationCallbacks.DUMMY));
|
||||
System.out.println("detectPcan " + detectPcan(UpdateOperationCallbacks.DUMMY));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue