Console to show device signature in window title #3115
This commit is contained in:
parent
bcaa862b18
commit
df451376e0
|
@ -68,6 +68,7 @@ public class BinaryProtocol {
|
|||
private final IoStream stream;
|
||||
private final IncomingDataBuffer incomingData;
|
||||
private boolean isBurnPending;
|
||||
public String signature;
|
||||
|
||||
private BinaryProtocolState state = new BinaryProtocolState();
|
||||
|
||||
|
@ -220,20 +221,19 @@ public class BinaryProtocol {
|
|||
}
|
||||
|
||||
/**
|
||||
* this method would switch controller to binary protocol and read configuration snapshot from controller
|
||||
* this method reads configuration snapshot from controller
|
||||
*
|
||||
* @return true if everything fine
|
||||
*/
|
||||
public boolean connectAndReadConfiguration(DataListener listener) {
|
||||
try {
|
||||
HelloCommand.send(stream);
|
||||
String response = HelloCommand.getHelloResponse(incomingData);
|
||||
System.out.println("Got " + response);
|
||||
SignatureHelper.downloadIfNotAvailable(SignatureHelper.getUrl(response));
|
||||
signature = HelloCommand.getHelloResponse(incomingData);
|
||||
System.out.println("Got " + signature);
|
||||
SignatureHelper.downloadIfNotAvailable(SignatureHelper.getUrl(signature));
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
// switchToBinaryProtocol();
|
||||
readImage(Fields.TOTAL_CONFIG_SIZE);
|
||||
if (isClosed)
|
||||
return false;
|
||||
|
|
|
@ -13,8 +13,9 @@ import static com.rusefi.shared.FileUtil.RUSEFI_SETTINGS_FOLDER;
|
|||
public class SignatureHelper {
|
||||
private final static String LOCAL_INI = RUSEFI_SETTINGS_FOLDER + File.separator + "ini_database";
|
||||
|
||||
public static final String PREFIX = "rusEFI ";
|
||||
public static final char SLASH = '/';
|
||||
// todo: find a way to reference Fields.PROTOCOL_SIGNATURE_PREFIX
|
||||
private static final String PREFIX = "rusEFI ";
|
||||
private static final char SLASH = '/';
|
||||
|
||||
public static Pair<String, String> getUrl(String signature) {
|
||||
if (signature == null || !signature.startsWith(PREFIX))
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.net.URL;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class rusEFIVersion {
|
||||
public static final int CONSOLE_VERSION = 20210723;
|
||||
public static final int CONSOLE_VERSION = 20210806;
|
||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||
|
||||
public static long classBuildTimeMillis() {
|
||||
|
|
|
@ -10,13 +10,16 @@ import com.rusefi.maintenance.VersionChecker;
|
|||
import com.rusefi.ui.storage.Node;
|
||||
import com.rusefi.ui.util.FrameHelper;
|
||||
import com.rusefi.ui.util.UiUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static com.devexperts.logging.Logging.getLogging;
|
||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||
|
||||
public class MainFrame {
|
||||
@NotNull
|
||||
private final ConsoleUI consoleUI;
|
||||
private final TabbedPanel tabbedPane;
|
||||
/**
|
||||
|
@ -46,7 +49,7 @@ public class MainFrame {
|
|||
public ConnectionFailedListener listener;
|
||||
|
||||
public MainFrame(ConsoleUI consoleUI, TabbedPanel tabbedPane) {
|
||||
this.consoleUI = consoleUI;
|
||||
this.consoleUI = Objects.requireNonNull(consoleUI);
|
||||
|
||||
this.tabbedPane = tabbedPane;
|
||||
listener = () -> {
|
||||
|
@ -102,7 +105,9 @@ public class MainFrame {
|
|||
|
||||
private void setTitle() {
|
||||
String disconnected = ConnectionStatusLogic.INSTANCE.isConnected() ? "" : "DISCONNECTED ";
|
||||
frame.getFrame().setTitle(disconnected + "Console " + Launcher.CONSOLE_VERSION + "; firmware=" + Launcher.firmwareVersion.get() + "@" + consoleUI.port);
|
||||
BinaryProtocol bp = consoleUI.uiContext.getLinkManager().getCurrentStreamState();
|
||||
String signature = bp == null ? "not loaded" : bp.signature;
|
||||
frame.getFrame().setTitle(disconnected + "Console " + Launcher.CONSOLE_VERSION + "; firmware=" + Launcher.firmwareVersion.get() + "@" + consoleUI.port + " " + signature);
|
||||
}
|
||||
|
||||
private void windowClosedHandler() {
|
||||
|
|
Loading…
Reference in New Issue