removing dead code
This commit is contained in:
parent
549c5e8ce3
commit
4af0cec252
|
@ -19,7 +19,6 @@ import com.rusefi.stream.TSHighSpeedLog;
|
||||||
import com.rusefi.stream.VcdStreamFile;
|
import com.rusefi.stream.VcdStreamFile;
|
||||||
import com.rusefi.tune.xml.Msq;
|
import com.rusefi.tune.xml.Msq;
|
||||||
import com.rusefi.ui.livedocs.LiveDocsRegistry;
|
import com.rusefi.ui.livedocs.LiveDocsRegistry;
|
||||||
import jssc.SerialPortException;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@ -257,7 +256,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void uploadChanges(ConfigurationImage newVersion, Logger logger) throws InterruptedException, EOFException, SerialPortException {
|
public void uploadChanges(ConfigurationImage newVersion, Logger logger) throws InterruptedException, EOFException {
|
||||||
ConfigurationImage current = getControllerConfiguration();
|
ConfigurationImage current = getControllerConfiguration();
|
||||||
// let's have our own copy which no one would be able to change
|
// let's have our own copy which no one would be able to change
|
||||||
newVersion = newVersion.clone();
|
newVersion = newVersion.clone();
|
||||||
|
@ -418,7 +417,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
Runtime.getRuntime().removeShutdownHook(hook);
|
Runtime.getRuntime().removeShutdownHook(hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeData(byte[] content, Integer offset, int size, Logger logger) throws SerialPortException, EOFException, InterruptedException {
|
public void writeData(byte[] content, Integer offset, int size, Logger logger) {
|
||||||
if (size > BLOCKING_FACTOR) {
|
if (size > BLOCKING_FACTOR) {
|
||||||
writeData(content, offset, BLOCKING_FACTOR, logger);
|
writeData(content, offset, BLOCKING_FACTOR, logger);
|
||||||
writeData(content, offset + BLOCKING_FACTOR, size - BLOCKING_FACTOR, logger);
|
writeData(content, offset + BLOCKING_FACTOR, size - BLOCKING_FACTOR, logger);
|
||||||
|
@ -446,7 +445,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void burn(Logger logger) throws InterruptedException, EOFException, SerialPortException {
|
public void burn(Logger logger) throws InterruptedException, EOFException {
|
||||||
if (!isBurnPending)
|
if (!isBurnPending)
|
||||||
return;
|
return;
|
||||||
logger.info("Need to burn");
|
logger.info("Need to burn");
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.rusefi.io;
|
package com.rusefi.io;
|
||||||
|
|
||||||
|
import com.fazecast.jSerialComm.SerialPort;
|
||||||
import com.rusefi.FileLog;
|
import com.rusefi.FileLog;
|
||||||
import com.rusefi.NamedThreadFactory;
|
import com.rusefi.NamedThreadFactory;
|
||||||
import com.rusefi.core.EngineState;
|
import com.rusefi.core.EngineState;
|
||||||
import com.rusefi.io.serial.SerialConnector;
|
import com.rusefi.io.serial.SerialConnector;
|
||||||
import com.rusefi.io.tcp.TcpConnector;
|
import com.rusefi.io.tcp.TcpConnector;
|
||||||
import jssc.SerialPortList;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -47,6 +47,14 @@ public class LinkManager {
|
||||||
return COMMUNICATION_EXECUTOR.submit(runnable);
|
return COMMUNICATION_EXECUTOR.submit(runnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String[] getCommPorts() {
|
||||||
|
SerialPort[] ports = SerialPort.getCommPorts();
|
||||||
|
String[] result = new String[ports.length];
|
||||||
|
for (int i = 0; i < ports.length; i++)
|
||||||
|
result[i] = ports[i].getSystemPortName();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public enum LogLevel {
|
public enum LogLevel {
|
||||||
INFO,
|
INFO,
|
||||||
DEBUG,
|
DEBUG,
|
||||||
|
@ -179,7 +187,7 @@ public class LinkManager {
|
||||||
* @return null if no port located
|
* @return null if no port located
|
||||||
*/
|
*/
|
||||||
public static String getDefaultPort() {
|
public static String getDefaultPort() {
|
||||||
String[] ports = SerialPortList.getPortNames();
|
String[] ports = getCommPorts();
|
||||||
if (ports.length == 0) {
|
if (ports.length == 0) {
|
||||||
System.out.println("Port not specified and no ports found");
|
System.out.println("Port not specified and no ports found");
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
package com.rusefi.io.serial;
|
|
||||||
|
|
||||||
import com.rusefi.FileLog;
|
|
||||||
import com.opensr5.io.DataListener;
|
|
||||||
import com.rusefi.io.IoStream;
|
|
||||||
import jssc.SerialPort;
|
|
||||||
import jssc.SerialPortEvent;
|
|
||||||
import jssc.SerialPortEventListener;
|
|
||||||
import jssc.SerialPortException;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Date: 12/25/12
|
|
||||||
* (c) Andrey Belomutskiy
|
|
||||||
*/
|
|
||||||
public class JSSCPortReader {
|
|
||||||
private static final int[] SLEEP_DURATIONS = {2, 20, 50, 100};
|
|
||||||
private final SerialPort serialPort;
|
|
||||||
private DataListener listener;
|
|
||||||
|
|
||||||
public JSSCPortReader(final SerialPort serialPort, final DataListener listener, IoStream serialIoStreamJSSC) {
|
|
||||||
this.serialPort = serialPort;
|
|
||||||
this.listener = listener;
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
while (serialPort.isOpened()) {
|
|
||||||
byte[] data = progressiveSleepRead(serialPort);
|
|
||||||
if (data != null)
|
|
||||||
listener.onDataArrived(data);
|
|
||||||
}
|
|
||||||
} catch (SerialPortException e) {
|
|
||||||
if (!serialIoStreamJSSC.isClosed()) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, "Reader_" + serialPort).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method starts with shorter sleeps (which we do not know to what extent Windows handle) and then we sleep
|
|
||||||
* a bit longer
|
|
||||||
* @param serialPort port to read from
|
|
||||||
* @return fresh data or null
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
private static byte[] progressiveSleepRead(SerialPort serialPort) throws SerialPortException {
|
|
||||||
for (int sleepDuration : SLEEP_DURATIONS) {
|
|
||||||
byte[] data;
|
|
||||||
synchronized (serialPort) {
|
|
||||||
data = serialPort.readBytes();
|
|
||||||
}
|
|
||||||
if (data != null)
|
|
||||||
return data;
|
|
||||||
try {
|
|
||||||
Thread.sleep(sleepDuration);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private SerialPortEventListener serialPortEventListener = new SerialPortEventListener() {
|
|
||||||
|
|
||||||
|
|
||||||
public void serialEvent(SerialPortEvent spe) {
|
|
||||||
if (spe.isRXCHAR() || spe.isRXFLAG()) {
|
|
||||||
// event-based serial read implementation does not work well on Windows 10 for some reason
|
|
||||||
// https://sourceforge.net/p/rusefi/tickets/264/
|
|
||||||
// try {
|
|
||||||
// handleRx(spe);
|
|
||||||
// } catch (SerialPortException e) {
|
|
||||||
// e.printStackTrace(System.err);
|
|
||||||
// }
|
|
||||||
} else if (spe.getEventType() != SerialPortEvent.TXEMPTY) {
|
|
||||||
FileLog.MAIN.logLine("less expected JSSCPortReader serialEvent " + spe.getEventType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// private void handleRx(SerialPortEvent spe) throws SerialPortException {
|
|
||||||
// if (spe.getEventValue() > 0) {
|
|
||||||
// byte[] buffer = serialPort.readBytes(spe.getEventValue());
|
|
||||||
// listener.onDataArrived(buffer);
|
|
||||||
// // System.out.println("arrived [" + str + "]");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void readInitial() throws SerialPortException {
|
|
||||||
int input = serialPort.getInputBufferBytesCount();
|
|
||||||
FileLog.MAIN.logLine(input + " bytes in input buffer");
|
|
||||||
while (serialPort.getInputBufferBytesCount() > 0) {
|
|
||||||
byte[] data = serialPort.readBytes();
|
|
||||||
if (data != null)
|
|
||||||
listener.onDataArrived(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public SerialPortEventListener getSerialPortEventListener() {
|
|
||||||
return serialPortEventListener;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,6 +3,6 @@ package com.rusefi;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class rusEFIVersion {
|
public class rusEFIVersion {
|
||||||
public static final int CONSOLE_VERSION = 20200606;
|
public static final int CONSOLE_VERSION = 20200607;
|
||||||
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
public static AtomicReference<String> firmwareVersion = new AtomicReference<>("N/A");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ import com.rusefi.ui.logview.LogViewer;
|
||||||
import com.rusefi.ui.storage.PersistentConfiguration;
|
import com.rusefi.ui.storage.PersistentConfiguration;
|
||||||
import com.rusefi.ui.util.DefaultExceptionHandler;
|
import com.rusefi.ui.util.DefaultExceptionHandler;
|
||||||
import com.rusefi.ui.util.JustOneInstance;
|
import com.rusefi.ui.util.JustOneInstance;
|
||||||
import jssc.SerialPortList;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
|
@ -247,7 +246,7 @@ public class Launcher extends rusEFIVersion {
|
||||||
if (isPortDefined) {
|
if (isPortDefined) {
|
||||||
new Launcher(port);
|
new Launcher(port);
|
||||||
} else {
|
} else {
|
||||||
for (String p : SerialPortList.getPortNames())
|
for (String p : LinkManager.getCommPorts())
|
||||||
MessagesCentral.getInstance().postMessage(Launcher.class, "Available port: " + p);
|
MessagesCentral.getInstance().postMessage(Launcher.class, "Available port: " + p);
|
||||||
new StartupFrame().chooseSerialPort();
|
new StartupFrame().chooseSerialPort();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.rusefi;
|
package com.rusefi;
|
||||||
|
|
||||||
|
import com.rusefi.io.LinkManager;
|
||||||
import com.rusefi.io.tcp.TcpConnector;
|
import com.rusefi.io.tcp.TcpConnector;
|
||||||
import jssc.SerialPortList;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -31,7 +31,7 @@ public enum SerialPortScanner {
|
||||||
@NotNull
|
@NotNull
|
||||||
void findAllAvailablePorts() {
|
void findAllAvailablePorts() {
|
||||||
List<String> ports = new ArrayList<>();
|
List<String> ports = new ArrayList<>();
|
||||||
String[] serialPorts = SerialPortList.getPortNames();
|
String[] serialPorts = LinkManager.getCommPorts();
|
||||||
if (serialPorts.length > 0 || serialPorts.length < 15)
|
if (serialPorts.length > 0 || serialPorts.length < 15)
|
||||||
ports.add(AUTO_SERIAL);
|
ports.add(AUTO_SERIAL);
|
||||||
ports.addAll(Arrays.asList(serialPorts));
|
ports.addAll(Arrays.asList(serialPorts));
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
import com.rusefi.ui.RecentCommands;
|
import com.rusefi.ui.RecentCommands;
|
||||||
import com.rusefi.ui.StatusWindow;
|
import com.rusefi.ui.StatusWindow;
|
||||||
import jssc.SerialPortException;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
@ -35,7 +34,7 @@ public class UploadChanges {
|
||||||
|
|
||||||
public static final Logger logger = createUiLogger();
|
public static final Logger logger = createUiLogger();
|
||||||
|
|
||||||
public static void main(String[] args) throws SerialPortException, InvocationTargetException, InterruptedException {
|
public static void main(String[] args) throws InvocationTargetException, InterruptedException {
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
System.out.println("Exactly one parameter expected");
|
System.out.println("Exactly one parameter expected");
|
||||||
return;
|
return;
|
||||||
|
@ -47,14 +46,14 @@ public class UploadChanges {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
showUi(port);
|
showUi(port);
|
||||||
} catch (SerialPortException | IOException | InterruptedException e) {
|
} catch (IOException | InterruptedException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void showUi(String port) throws SerialPortException, IOException, InterruptedException {
|
private static void showUi(String port) throws IOException, InterruptedException {
|
||||||
/*
|
/*
|
||||||
SerialPort serialPort;
|
SerialPort serialPort;
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ public class UploadChanges {
|
||||||
BinaryProtocolHolder.getInstance().getCurrentStreamState().uploadChanges(newVersion, logger);
|
BinaryProtocolHolder.getInstance().getCurrentStreamState().uploadChanges(newVersion, logger);
|
||||||
if (afterUpload != null)
|
if (afterUpload != null)
|
||||||
afterUpload.run();
|
afterUpload.run();
|
||||||
} catch (InterruptedException | EOFException | SerialPortException e) {
|
} catch (InterruptedException | EOFException e) {
|
||||||
logger.error("Error: " + e);
|
logger.error("Error: " + e);
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.rusefi.autodetect;
|
||||||
|
|
||||||
import com.rusefi.FileLog;
|
import com.rusefi.FileLog;
|
||||||
import com.rusefi.io.IoStream;
|
import com.rusefi.io.IoStream;
|
||||||
import jssc.SerialPortList;
|
import com.rusefi.io.LinkManager;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -51,7 +51,7 @@ public class PortDetector {
|
||||||
|
|
||||||
private static String[] getPortNames() {
|
private static String[] getPortNames() {
|
||||||
// long now = System.currentTimeMillis();
|
// long now = System.currentTimeMillis();
|
||||||
String[] portNames = SerialPortList.getPortNames();
|
String[] portNames = LinkManager.getCommPorts();
|
||||||
// FileLog.MAIN.logLine("Took " + (System.currentTimeMillis() - now));
|
// FileLog.MAIN.logLine("Took " + (System.currentTimeMillis() - now));
|
||||||
return portNames;
|
return portNames;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,15 @@ import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
public class InternetStatus {
|
public class InternetStatus {
|
||||||
public static final String GOOGLE = "http://google.com";
|
private static final String GOOGLE = "http://google.com";
|
||||||
|
private final JPanel panel = new JPanel();
|
||||||
private final JLabel status = new JLabel();
|
private final JLabel status = new JLabel();
|
||||||
|
|
||||||
public InternetStatus() {
|
public InternetStatus() {
|
||||||
|
panel.add(status);
|
||||||
|
Font defaultFont = status.getFont();
|
||||||
|
status.setFont(new Font(defaultFont.getName(), defaultFont.getStyle(), 2 * defaultFont.getSize()));
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
while (true) {
|
while (true) {
|
||||||
boolean isConnected = isServerReachable();
|
boolean isConnected = isServerReachable();
|
||||||
|
@ -23,10 +28,10 @@ public class InternetStatus {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
status.setText("online");
|
status.setText("online");
|
||||||
status.setForeground(Color.green);
|
panel.setBackground(Color.green);
|
||||||
} else {
|
} else {
|
||||||
status.setText("offline");
|
status.setText("offline");
|
||||||
status.setForeground(Color.red);
|
panel.setBackground(Color.red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -55,6 +60,6 @@ public class InternetStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getContent() {
|
public Component getContent() {
|
||||||
return status;
|
return panel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,5 +21,6 @@
|
||||||
<orderEntry type="library" name="XML for 11" level="project" />
|
<orderEntry type="library" name="XML for 11" level="project" />
|
||||||
<orderEntry type="module" module-name="shared_ui" />
|
<orderEntry type="module" module-name="shared_ui" />
|
||||||
<orderEntry type="module" module-name="autoupdate" exported="" />
|
<orderEntry type="module" module-name="autoupdate" exported="" />
|
||||||
|
<orderEntry type="library" name="jSerialComm" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
Loading…
Reference in New Issue