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