Merge branch 'master' of https://github.com/rusefi/rusefi into second_can

This commit is contained in:
kon 2020-08-04 21:30:46 -07:00
commit ffb30eb0b1
30 changed files with 249 additions and 45 deletions

View File

@ -1,2 +1,2 @@
#pragma once
#define VCS_DATE 20200804
#define VCS_DATE 20200805

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Mon Aug 03 20:49:50 UTC 2020
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Wed Aug 05 03:19:35 UTC 2020
// by class com.rusefi.output.FileFsioSettingsConsumer
FSIO_SETTING_FANONTEMPERATURE = 1000,

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Mon Aug 03 20:49:50 UTC 2020
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Wed Aug 05 03:19:35 UTC 2020
// by class com.rusefi.output.FileFsioSettingsConsumer
case FSIO_SETTING_FANONTEMPERATURE:

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Mon Aug 03 20:49:50 UTC 2020
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Wed Aug 05 03:19:35 UTC 2020
// by class com.rusefi.output.FileFsioSettingsConsumer
static LENameOrdinalPair lefanOnTemperature(FSIO_SETTING_FANONTEMPERATURE, "cfg_fanOnTemperature");

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Mon Aug 03 20:49:50 UTC 2020
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Wed Aug 05 03:19:35 UTC 2020
// by class com.rusefi.output.FileFsioSettingsConsumer
case FSIO_SETTING_FANONTEMPERATURE:

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD all
#define SIGNATURE_DATE 2020.08.03
#define SIGNATURE_HASH 1319574552
#define TS_SIGNATURE "rusEFI 2020.08.03.all.1319574552"
#define SIGNATURE_DATE 2020.08.05
#define SIGNATURE_HASH 4227757186
#define TS_SIGNATURE "rusEFI 2020.08.05.all.4227757186"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD frankenso_na6
#define SIGNATURE_DATE 2020.08.03
#define SIGNATURE_HASH 1925900737
#define TS_SIGNATURE "rusEFI 2020.08.03.frankenso_na6.1925900737"
#define SIGNATURE_DATE 2020.08.05
#define SIGNATURE_HASH 3348332891
#define TS_SIGNATURE "rusEFI 2020.08.05.frankenso_na6.3348332891"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD kin
#define SIGNATURE_DATE 2020.08.03
#define SIGNATURE_HASH 1634949560
#define TS_SIGNATURE "rusEFI 2020.08.03.kin.1634949560"
#define SIGNATURE_DATE 2020.08.05
#define SIGNATURE_HASH 3559534882
#define TS_SIGNATURE "rusEFI 2020.08.05.kin.3559534882"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD mre_f4
#define SIGNATURE_DATE 2020.08.03
#define SIGNATURE_HASH 3853734828
#define TS_SIGNATURE "rusEFI 2020.08.03.mre_f4.3853734828"
#define SIGNATURE_DATE 2020.08.05
#define SIGNATURE_HASH 1357527862
#define TS_SIGNATURE "rusEFI 2020.08.05.mre_f4.1357527862"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD mre_f7
#define SIGNATURE_DATE 2020.08.03
#define SIGNATURE_HASH 3853734828
#define TS_SIGNATURE "rusEFI 2020.08.03.mre_f7.3853734828"
#define SIGNATURE_DATE 2020.08.05
#define SIGNATURE_HASH 1357527862
#define TS_SIGNATURE "rusEFI 2020.08.05.mre_f7.1357527862"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD prometheus_405
#define SIGNATURE_DATE 2020.08.03
#define SIGNATURE_HASH 1498504614
#define TS_SIGNATURE "rusEFI 2020.08.03.prometheus_405.1498504614"
#define SIGNATURE_DATE 2020.08.05
#define SIGNATURE_HASH 3959960892
#define TS_SIGNATURE "rusEFI 2020.08.05.prometheus_405.3959960892"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD prometheus_469
#define SIGNATURE_DATE 2020.08.03
#define SIGNATURE_HASH 1498504614
#define TS_SIGNATURE "rusEFI 2020.08.03.prometheus_469.1498504614"
#define SIGNATURE_DATE 2020.08.05
#define SIGNATURE_HASH 3959960892
#define TS_SIGNATURE "rusEFI 2020.08.05.prometheus_469.3959960892"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD proteus_f4
#define SIGNATURE_DATE 2020.08.03
#define SIGNATURE_HASH 568128749
#define TS_SIGNATURE "rusEFI 2020.08.03.proteus_f4.568128749"
#define SIGNATURE_DATE 2020.08.05
#define SIGNATURE_HASH 2491784311
#define TS_SIGNATURE "rusEFI 2020.08.05.proteus_f4.2491784311"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD proteus_f7
#define SIGNATURE_DATE 2020.08.03
#define SIGNATURE_HASH 568128749
#define TS_SIGNATURE "rusEFI 2020.08.03.proteus_f7.568128749"
#define SIGNATURE_DATE 2020.08.05
#define SIGNATURE_HASH 2491784311
#define TS_SIGNATURE "rusEFI 2020.08.05.proteus_f7.2491784311"

View File

@ -9,6 +9,8 @@
# Andrey Belomutskiy, (c) 2012-2017
#
# different way to have the same result would be using "self"
# (self and (coolant > fan_off_setting)) | (coolant > fan_on_setting) | is_clt_broken
FAN_CONTROL_LOGIC=(fan and (coolant > fan_off_setting)) | (coolant > fan_on_setting) | is_clt_broken
FUEL_PUMP_LOGIC=(time_since_boot < startup_fuel_pump_duration) | (rpm > 0)

View File

@ -1664,6 +1664,14 @@ end_struct
#define TS_SD_R_COMMAND 'r'
#define TS_SD_W_COMMAND 'w'
#define TS_SD_PROTOCOL_RTC 7
#define TS_SD_PROTOCOL_FETCH_INFO 0x11
#define TS_SD_PROTOCOL_FETCH_DATA 0x14
#define TS_SD_PROTOCOL_DO 1
#define TS_SD_PROTOCOL_READ_DIR 2
#define TS_SD_PROTOCOL_REMOVE_FILE 6
#define TS_SD_PROTOCOL_FETCH_COMPRESSED 8
// High speed logger commands
#define TS_SET_LOGGER_SWITCH 'l'
#define TS_GET_LOGGER_GET_BUFFER 'L'

View File

@ -40,7 +40,7 @@ public class SerialAutoChecker implements Runnable {
IncomingDataBuffer incomingData = stream.getDataBuffer();
try {
HelloCommand.send(stream);
byte[] response = incomingData.getPacket("", false);
byte[] response = incomingData.getPacket("");
if (!checkResponseCode(response, BinaryProtocolCommands.RESPONSE_OK))
return;
String signature = new String(response, 1, response.length - 1);

View File

@ -46,6 +46,10 @@ public class IncomingDataBuffer {
return incomingData;
}
public byte[] getPacket(String msg) throws EOFException {
return getPacket(msg, false, System.currentTimeMillis());
}
public byte[] getPacket(String msg, boolean allowLongResponse) throws EOFException {
return getPacket(msg, allowLongResponse, System.currentTimeMillis());
}

View File

@ -28,6 +28,8 @@ public interface IoStream extends WriteStream, Closeable, StreamStatistics {
Logging log = getLogging(IoStream.class);
static String printHexBinary(byte[] data) {
if (data == null)
return "(null)";
char[] hexCode = "0123456789ABCDEF".toCharArray();
StringBuilder r = new StringBuilder(data.length * 2);

View File

@ -25,7 +25,7 @@ public class HelloCommand implements Command {
@Nullable
public static String getHelloResponse(IncomingDataBuffer incomingData) throws EOFException {
byte[] response = incomingData.getPacket("[hello]", false);
byte[] response = incomingData.getPacket("[hello]");
if (!checkResponseCode(response, BinaryProtocolCommands.RESPONSE_OK))
return null;
return new String(response, 1, response.length - 1);

View File

@ -34,6 +34,7 @@ import static com.rusefi.config.generated.Fields.*;
* This class makes rusEfi console a proxy for other tuning software, this way we can have two tools connected via same
* serial port simultaneously
*
* See BinaryProtocolServerSandbox
* @author Andrey Belomutskiy
* 11/24/15
*/
@ -213,18 +214,18 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
private void handleSD_W_command(TcpIoStream stream, Packet packet, byte[] payload) throws IOException {
log.info("TS_SD: 'w' " + IoStream.printHexBinary(packet.packet));
if (payload[1] == 0 && payload[2] == 0x11) {
if (payload[1] == 0 && payload[2] == TS_SD_PROTOCOL_FETCH_INFO) {
if (payload[6] == 1) {
if (payload[6] == TS_SD_PROTOCOL_DO) {
log.info("TS_SD: do command, command=" + payload[payload.length - 1]);
sendOkResponse(stream);
} else if (payload[6] == 2) {
} else if (payload[6] == TS_SD_PROTOCOL_READ_DIR) {
log.info("TS_SD: read directory command " + payload[payload.length - 1]);
sendOkResponse(stream);
} else if (payload[6] == 6) {
} else if (payload[6] == TS_SD_PROTOCOL_REMOVE_FILE) {
log.info("TS_SD: remove file command " + Arrays.toString(packet.packet));
sendOkResponse(stream);
} else if (payload[6] == 8) {
} else if (payload[6] == TS_SD_PROTOCOL_FETCH_COMPRESSED) {
log.info("TS_SD: read compressed file command " + Arrays.toString(packet.packet));
ByteBuffer bb = ByteBuffer.wrap(payload, 7, 8);
bb.order(ByteOrder.BIG_ENDIAN);
@ -232,6 +233,8 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
int sectorCount = bb.getInt();
log.info("TS_SD: sectorNumber=" + sectorNumber + ", sectorCount=" + sectorCount);
sendOkResponse(stream);
} else {
log.info("TS_SD: Got unexpected w fetch " + IoStream.printHexBinary(packet.packet));
}
} else {
log.info("TS_SD: Got unexpected w " + IoStream.printHexBinary(packet.packet));
@ -240,11 +243,11 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
private void handleSD_R_command(TcpIoStream stream, Packet packet, byte[] payload) throws IOException {
log.info("TS_SD: 'r' " + IoStream.printHexBinary(packet.packet));
if (payload[1] == 0 && payload[2] == 7) {
if (payload[1] == 0 && payload[2] == TS_SD_PROTOCOL_RTC) {
log.info("TS_SD: RTC read command");
byte[] response = new byte[9];
stream.sendPacket(response);
} else if (payload[1] == 0 && payload[2] == 0x11) {
} else if (payload[1] == 0 && payload[2] == TS_SD_PROTOCOL_FETCH_INFO) {
ByteBuffer bb = ByteBuffer.wrap(payload, 5, 2);
bb.order(ByteOrder.BIG_ENDIAN);
int bufferLength = bb.getShort();
@ -268,7 +271,7 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
response[9] = 0;
response[10] = 1; // number of files
} else {
} else if (bufferLength == 0x202){
// SD read directory command
//
@ -289,9 +292,12 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
// response[1 + 30] = (byte) 1;
// response[1 + 31] = (byte) 0; // size
} else {
log.info("TS_SD: Got unexpected r fetch " + IoStream.printHexBinary(packet.packet));
return;
}
stream.sendPacket(response);
} else if (payload[1] == 0 && payload[2] == 0x14) {
} else if (payload[1] == 0 && payload[2] == TS_SD_PROTOCOL_FETCH_DATA) {
ByteBuffer bb = ByteBuffer.wrap(payload, 3, 4);
bb.order(ByteOrder.BIG_ENDIAN);
int blockNumber = bb.getShort();

Binary file not shown.

View File

@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="jsr305-2.0.1">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../java_console/lib/jsr305-2.0.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/../../java_console/lib/jsr305-2.0.1.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -15,7 +15,7 @@
debug="true"
target="${javac.target}"
destdir="build/classes"
classpath="lib/junit.jar:../../java_console/lib/annotations.jar:lib/snakeyaml.jar">
classpath="../../java_console/lib/jsr305-2.0.1.jar:lib/junit.jar:../../java_console/lib/annotations.jar:lib/snakeyaml.jar">
<src path="src"/>
<src path="${console_path}/autoupdate/src"/>
<src path="${console_path}/inifile/src"/>

View File

@ -17,7 +17,8 @@ import static com.rusefi.ReaderState.MULT_TOKEN;
public class VariableRegistry {
private static final String _16_HEX_SUFFIX = "_16_hex";
private static final String _HEX_SUFFIX = "_hex";
private TreeMap<String, String> data = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
private static final String HEX_PREFIX = "0x";
private final TreeMap<String, String> data = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
public static final VariableRegistry INSTANCE = new VariableRegistry();
private final Pattern VAR = Pattern.compile("(@@(.*?)@@)");
@ -85,6 +86,13 @@ public class VariableRegistry {
@SuppressWarnings("StringConcatenationInsideStringBufferAppend")
private void tryToRegisterAsInteger(String var, String value) {
if (value.trim().startsWith(HEX_PREFIX)) {
int intValue = Integer.parseInt(value.trim().substring(HEX_PREFIX.length()), 16);
intValues.put(var, intValue);
javaDefinitions.put(var, "\tpublic static final int " + var + " = " + value + ";" + EOL);
return;
}
try {
int intValue = Integer.parseInt(value);
SystemOut.println("key [" + var + "] value: " + intValue);

View File

@ -121,6 +121,25 @@ public class ConfigFieldParserTest {
}
@Test
public void testDefine() throws IOException {
VariableRegistry.INSTANCE.clear();
ReaderState state = new ReaderState();
String test =
"#define ERROR_BUFFER_SIZE 120\n" +
"#define ERROR_BUFFER_SIZE_H 0x120\n" +
"";
BufferedReader reader = new BufferedReader(new StringReader(test));
JavaFieldsConsumer javaFieldsConsumer = new TestJavaFieldsConsumer(state);
state.readBufferedReader(reader, Arrays.asList(javaFieldsConsumer));
assertEquals("\tpublic static final int ERROR_BUFFER_SIZE = 120;\n" +
"\tpublic static final int ERROR_BUFFER_SIZE_H = 0x120;\n" +
"",
VariableRegistry.INSTANCE.getJavaConstants());
}
@Test
public void testFsioVisible() throws IOException {
{

View File

@ -0,0 +1,94 @@
package com.rusefi.ts_plugin;
import com.rusefi.config.generated.Fields;
import com.rusefi.io.ConnectionStateListener;
import com.rusefi.io.IoStream;
import com.rusefi.io.LinkManager;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import static com.rusefi.config.generated.Fields.TS_SD_PROTOCOL_FETCH_INFO;
public class ConnectPanel {
private final JPanel content = new JPanel(new BorderLayout());
private LinkManager controllerConnector;
public ConnectPanel() {
JPanel flow = new JPanel(new FlowLayout());
JButton connect = new JButton("Connect");
connect.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
controllerConnector = new LinkManager()
.setCompositeLogicEnabled(false)
.setNeedPullData(false);
controllerConnector.startAndConnect(":2390", ConnectionStateListener.VOID);
}
});
JButton poke = new JButton("poke");
poke.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
byte[] packet;
byte[] response;
IoStream stream = controllerConnector.getConnector().getBinaryProtocol().getStream();
packet = new byte[3];
packet[0] = Fields.TS_SD_R_COMMAND;
packet[2] = Fields.TS_SD_PROTOCOL_RTC;
stream.sendPacket(packet);
response = stream.getDataBuffer().getPacket("RTC status");
System.out.println("RTC response " + IoStream.printHexBinary(response));
packet = new byte[17];
packet[0] = Fields.TS_SD_W_COMMAND;
packet[2] = TS_SD_PROTOCOL_FETCH_INFO;
packet[6] = Fields.TS_SD_PROTOCOL_READ_DIR;
stream.sendPacket(packet);
response = stream.getDataBuffer().getPacket("read dir command");
System.out.println("read dir command " + IoStream.printHexBinary(response));
packet = new byte[8];
packet[0] = Fields.TS_SD_R_COMMAND;
packet[1] = 0;
packet[2] = TS_SD_PROTOCOL_FETCH_INFO;
packet[5] = 0x02;
packet[6] = 0x02;
stream.sendPacket(packet);
response = stream.getDataBuffer().getPacket("read command", true);
System.out.println("read command " + IoStream.printHexBinary(response));
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
});
flow.add(connect);
flow.add(poke);
content.add(flow);
}
public JComponent getContent() {
return content;
}
}

View File

@ -47,6 +47,7 @@ public class PluginEntry implements TsPluginBody {
tabbedPane.addTab("Upload", uploadTab.getContent());
tabbedPane.addTab("Broadcast", broadcastTab.getContent());
tabbedPane.addTab("Remote ECU", remoteTab.getContent());
tabbedPane.addTab("Read SD Card", new SdCardReader().getContent());
content.add(tabbedPane);
}

View File

@ -0,0 +1,16 @@
package com.rusefi.ts_plugin;
import javax.swing.*;
import java.awt.*;
public class SdCardReader {
private final JPanel content = new JPanel();
public SdCardReader() {
content.add(new ConnectPanel().getContent());
}
public Component getContent() {
return content;
}
}

View File

@ -111,6 +111,39 @@ TEST(fsio, testIfFunction) {
testExpression("1 22 33 if", 22);
}
TEST(fsio, testHysteresisSelf) {
WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995);
LEElement thepool[TEST_POOL_SIZE];
LEElementPool pool(thepool, TEST_POOL_SIZE);
// value ON: 450
// value OFF: 400
// Human formula: (self and (rpm > 400)) | (rpm > 450)
LEElement * element = pool.parseExpression("self rpm 400 > and rpm 450 > |");
ASSERT_TRUE(element != NULL) << "Not NULL expected";
LECalculator c;
double selfValue = 0;
engine->fsioState.mockRpm = 0;
selfValue = c.getValue2(selfValue, element PASS_ENGINE_PARAMETER_SUFFIX);
ASSERT_EQ(0, selfValue);
engine->fsioState.mockRpm = 430;
selfValue = c.getValue2(selfValue, element PASS_ENGINE_PARAMETER_SUFFIX);
// OFF since not ON yet
ASSERT_EQ(0, selfValue);
engine->fsioState.mockRpm = 460;
selfValue = c.getValue2(selfValue, element PASS_ENGINE_PARAMETER_SUFFIX);
ASSERT_EQ(1, selfValue);
engine->fsioState.mockRpm = 430;
selfValue = c.getValue2(selfValue, element PASS_ENGINE_PARAMETER_SUFFIX);
// OFF since was ON yet
ASSERT_EQ(1, selfValue);
}
TEST(fsio, testLogicExpressions) {
testParsing();
{