auto-sync
This commit is contained in:
parent
4b74ebe7e2
commit
a216dcf812
|
@ -1,5 +1,5 @@
|
||||||
// This file was generated by Version2Header
|
// This file was generated by Version2Header
|
||||||
// Wed Feb 17 22:07:02 EST 2016
|
// Mon Feb 29 20:31:38 EST 2016
|
||||||
#ifndef VCS_VERSION
|
#ifndef VCS_VERSION
|
||||||
#define VCS_VERSION "9606"
|
#define VCS_VERSION "9640"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="Launcher COM3" type="Application" factoryName="Application">
|
<configuration default="false" name="Launcher COM3" type="Application" factoryName="Application" folderName="x">
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||||
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
|
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
|
||||||
<option name="VM_PARAMETERS" value="" />
|
<option name="VM_PARAMETERS" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="COM3" />
|
<option name="PROGRAM_PARAMETERS" value="COM3" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH" value="" />
|
<option name="ALTERNATIVE_JRE_PATH" />
|
||||||
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
||||||
<option name="ENV_VARIABLES" />
|
<option name="ENV_VARIABLES" />
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<option name="PASS_PARENT_ENVS" value="true" />
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="Launcher COM7" type="Application" factoryName="Application">
|
<configuration default="false" name="Launcher COM7" type="Application" factoryName="Application" folderName="x">
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||||
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
|
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
|
||||||
<option name="VM_PARAMETERS" value="" />
|
<option name="VM_PARAMETERS" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="COM7" />
|
<option name="PROGRAM_PARAMETERS" value="COM7" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH" value="" />
|
<option name="ALTERNATIVE_JRE_PATH" />
|
||||||
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
||||||
<option name="ENV_VARIABLES" />
|
<option name="ENV_VARIABLES" />
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<option name="PASS_PARENT_ENVS" value="true" />
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="Launcher COM9" type="Application" factoryName="Application">
|
<configuration default="false" name="Launcher COM9" type="Application" factoryName="Application" folderName="x">
|
||||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||||
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
|
<option name="MAIN_CLASS_NAME" value="com.rusefi.Launcher" />
|
||||||
<option name="VM_PARAMETERS" value="" />
|
<option name="VM_PARAMETERS" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="COM9" />
|
<option name="PROGRAM_PARAMETERS" value="COM9" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||||
<option name="ALTERNATIVE_JRE_PATH" value="" />
|
<option name="ALTERNATIVE_JRE_PATH" />
|
||||||
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
||||||
<option name="ENV_VARIABLES" />
|
<option name="ENV_VARIABLES" />
|
||||||
<option name="PASS_PARENT_ENVS" value="true" />
|
<option name="PASS_PARENT_ENVS" value="true" />
|
||||||
|
|
|
@ -174,7 +174,7 @@ public class AutoTest {
|
||||||
msg = "ProtegeLX running";
|
msg = "ProtegeLX running";
|
||||||
IoUtil.changeRpm(2000);
|
IoUtil.changeRpm(2000);
|
||||||
chart = nextChart();
|
chart = nextChart();
|
||||||
x = 127.92;
|
x = 112;
|
||||||
assertWave(msg, chart, EngineChart.SPARK_1, 0.13333333333333333, x, x + 180, x + 360, x + 540);
|
assertWave(msg, chart, EngineChart.SPARK_1, 0.13333333333333333, x, x + 180, x + 360, x + 540);
|
||||||
x = 0;
|
x = 0;
|
||||||
assertWaveFall(msg, chart, EngineChart.INJECTOR_1, 0.04666666666666654, x + 180, x + 540);
|
assertWaveFall(msg, chart, EngineChart.INJECTOR_1, 0.04666666666666654, x + 180, x + 540);
|
||||||
|
|
|
@ -6,12 +6,14 @@ import jssc.SerialPort;
|
||||||
import jssc.SerialPortEvent;
|
import jssc.SerialPortEvent;
|
||||||
import jssc.SerialPortEventListener;
|
import jssc.SerialPortEventListener;
|
||||||
import jssc.SerialPortException;
|
import jssc.SerialPortException;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date: 12/25/12
|
* Date: 12/25/12
|
||||||
* (c) Andrey Belomutskiy
|
* (c) Andrey Belomutskiy
|
||||||
*/
|
*/
|
||||||
public class SerialPortReader implements SerialPortEventListener {
|
public class SerialPortReader implements SerialPortEventListener {
|
||||||
|
private static final int[] SLEEP_DURATIONS = {2, 20, 50, 100};
|
||||||
private final SerialPort serialPort;
|
private final SerialPort serialPort;
|
||||||
private DataListener listener;
|
private DataListener listener;
|
||||||
|
|
||||||
|
@ -23,25 +25,42 @@ public class SerialPortReader implements SerialPortEventListener {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
while (serialPort.isOpened()) {
|
while (serialPort.isOpened()) {
|
||||||
byte[] data;
|
byte[] data = progressiveSleepRead(serialPort);
|
||||||
synchronized (serialPort) {
|
if (data != null)
|
||||||
data = serialPort.readBytes();
|
|
||||||
}
|
|
||||||
if (data != null) {
|
|
||||||
listener.onDataArrived(data);
|
listener.onDataArrived(data);
|
||||||
} else {
|
|
||||||
Thread.sleep(100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (SerialPortException e) {
|
} catch (SerialPortException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new IllegalStateException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "Reader_" + serialPort).start();
|
}, "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;
|
||||||
|
}
|
||||||
|
|
||||||
public void serialEvent(SerialPortEvent spe) {
|
public void serialEvent(SerialPortEvent spe) {
|
||||||
if (spe.isRXCHAR() || spe.isRXFLAG()) {
|
if (spe.isRXCHAR() || spe.isRXFLAG()) {
|
||||||
// event-based serial read implementation does not work well on Windows 10 for some reason
|
// event-based serial read implementation does not work well on Windows 10 for some reason
|
||||||
|
|
Loading…
Reference in New Issue