diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 871a6a5b8e..9615fc5edb 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -2231,115 +2231,12 @@ end_struct #define ENGINE_MAKE_Hyundai "Hyundai" -! TEST_CONTROL_MAGIC_WORD copy-paste while we are learning how to share between rusEFI and stim firmware -#define CAN_BENCH_HEADER2 0x66 -#define BENCH_FUEL_PUMP_DURATION 3000 -#define BENCH_FAN_DURATION 2000 -#define BENCH_VVT_DURATION 300 -#define BENCH_MAIN_RELAY_DURATION 1000 -#define BENCH_STARTER_DURATION 4000 -#define BENCH_AC_RELAY_DURATION 800 - -#define DEFAULT_SELT_STIM_RPM 1200 -#define DEFAULT_SELT_STIM_VVT0 23 - -#define PROTOCOL_MSG "msg" -#define PROTOCOL_HELLO_PREFIX "***" - -#define TS_RESPONSE_UNDERRUN 0x80 -#define TS_RESPONSE_OVERRUN 0x81 -#define TS_RESPONSE_CRC_FAILURE 0x82 -#define TS_RESPONSE_UNRECOGNIZED_COMMAND 0x83 -#define TS_RESPONSE_OUT_OF_RANGE 0x84 -#define TS_RESPONSE_FRAMING_ERROR 0x8D ! we need 3 seconds on single-bank to survive write-to-flash reconnect ! dual-bank devices can go with 300 for better TS reconnect experience #define TS_BLOCK_READ_TIMEOUT 3000 -#define MLQ_HEADER_SIZE 24 -#define MLQ_FIELD_HEADER_SIZE 89 - -#define PROTOCOL_OUTPIN "outpin" -#define PROTOCOL_ANALOG_CHART "analog_chart" -#define PROTOCOL_ENGINE_SNIFFER "wave_chart" -#define PROTOCOL_KNOCK_SPECTROGRAMM "knock_spectrogram" -#define PROTOCOL_VERSION_TAG "rusEfiVersion" -#define PROTOCOL_TEST_RESPONSE_TAG "ts_p_alive" -#define PROTOCOL_SIGNATURE_PREFIX "rusEFI " -#define FRONTEND_TITLE_BAR_NAME "rusEFI" - -! Engine Sniffer Protocol -#define PROTOCOL_ES_DOWN "d" -#define PROTOCOL_ES_UP "u" -#define TOP_DEAD_CENTER_MESSAGE "r" - -! Engine Sniffer channel names -#define PROTOCOL_CRANK1 "t1" -#define PROTOCOL_CRANK2 "t2" - -#define PROTOCOL_VVT1_NAME "VVT1" -#define PROTOCOL_VVT2_NAME "VVT2" -#define PROTOCOL_VVT3_NAME "VVT3" -#define PROTOCOL_VVT4_NAME "VVT4" -#define PROTOCOL_HIP_NAME "HIP" -#define PROTOCOL_TACH_NAME "tach" -#define PROTOCOL_HPFP_NAME "hpfp" -#define PROTOCOL_ACR_NAME "acr" - -#define PROTOCOL_WA_CHANNEL_1 "input1" -#define PROTOCOL_WA_CHANNEL_2 "input2" -#define PROTOCOL_WA_CHANNEL_3 "input3" -#define PROTOCOL_WA_CHANNEL_4 "input4" - - -#define TS_PROTOCOL "001" -! These commands are used by TunerStudio and the rusEFI console -! 0x4F ochGetCommand -#define TS_OUTPUT_COMMAND 'O' -! 0x53 queryCommand - this one is about detailed signature -#define TS_HELLO_COMMAND 'S' -! todo: replace all usages of TS_HELLO_COMMAND with TS_QUERY_COMMAND -! todo#2: actually is above still the case? -! TS auto-detect depends on well-known queryCommand value 'Q' which is not yet mentioned in https://www.tunerstudio.com/index.php/support/manuals/tsdevmanuals/137-ecu-definition-specification-aka-the-ini-document -! that Q command is not mentioned in the .ini neither since it could happen during ECU auto-detection phase before any .ini is available -#define TS_QUERY_COMMAND 'Q' -! 0x6B 107 -#define TS_CRC_CHECK_COMMAND 'k' - - -! 0x50 80 -#define TS_PAGE_COMMAND 'P' -! 0x46 -#define TS_COMMAND_F 'F' -#define TS_GET_PROTOCOL_VERSION_COMMAND_F 'F' -! versionInfo 0x56 86 this one is only used for TS title bar -#define TS_GET_FIRMWARE_VERSION 'V' -! returns getFirmwareError(), works together with ind_hasFatalError -#define TS_GET_CONFIG_ERROR 'e' - -#define TS_SIMULATE_CAN '>' - -! 0x42 burnCommand -#define TS_BURN_COMMAND 'B' -! 0x77 -#define TS_IO_TEST_COMMAND 'Z' - -#define TS_RESPONSE_OK 0 -#define TS_RESPONSE_BURN_OK 4 - -! Engine Sniffer time stamp unit, in microseconds -#define ENGINE_SNIFFER_UNIT_US 10 - - -#define TS_COMPOSITE_ENABLE 1 -#define TS_COMPOSITE_DISABLE 2 -#define TS_COMPOSITE_READ 3 - -#define TS_TRIGGER_SCOPE_ENABLE 4 -#define TS_TRIGGER_SCOPE_DISABLE 5 -#define TS_TRIGGER_SCOPE_READ 6 ! Generic channel names, your board may want to override these #define TS_TRIGGER_SCOPE_CHANNEL_1_NAME "Channel 1" diff --git a/firmware/integration/ts_protocol.txt b/firmware/integration/ts_protocol.txt index c5a5b42685..8da5da25d1 100644 --- a/firmware/integration/ts_protocol.txt +++ b/firmware/integration/ts_protocol.txt @@ -1,3 +1,59 @@ +#define TS_PROTOCOL "001" +! These commands are used by TunerStudio and the rusEFI console +! 0x4F ochGetCommand +#define TS_OUTPUT_COMMAND 'O' +! 0x53 queryCommand - this one is about detailed signature +#define TS_HELLO_COMMAND 'S' +! todo: replace all usages of TS_HELLO_COMMAND with TS_QUERY_COMMAND +! todo#2: actually is above still the case? +! TS auto-detect depends on well-known queryCommand value 'Q' which is not yet mentioned in https://www.tunerstudio.com/index.php/support/manuals/tsdevmanuals/137-ecu-definition-specification-aka-the-ini-document +! that Q command is not mentioned in the .ini neither since it could happen during ECU auto-detection phase before any .ini is available +#define TS_QUERY_COMMAND 'Q' +! 0x6B 107 +#define TS_CRC_CHECK_COMMAND 'k' + + +! 0x50 80 +#define TS_PAGE_COMMAND 'P' +! 0x46 +#define TS_COMMAND_F 'F' +#define TS_GET_PROTOCOL_VERSION_COMMAND_F 'F' +! versionInfo 0x56 86 this one is only used for TS title bar +#define TS_GET_FIRMWARE_VERSION 'V' +! returns getFirmwareError(), works together with ind_hasFatalError +#define TS_GET_CONFIG_ERROR 'e' + +#define TS_SIMULATE_CAN '>' + +! 0x42 burnCommand +#define TS_BURN_COMMAND 'B' +! 0x77 +#define TS_IO_TEST_COMMAND 'Z' + +#define TS_RESPONSE_OK 0 +#define TS_RESPONSE_BURN_OK 4 + +! Engine Sniffer time stamp unit, in microseconds +#define ENGINE_SNIFFER_UNIT_US 10 + + +#define TS_COMPOSITE_ENABLE 1 +#define TS_COMPOSITE_DISABLE 2 +#define TS_COMPOSITE_READ 3 + +#define TS_TRIGGER_SCOPE_ENABLE 4 +#define TS_TRIGGER_SCOPE_DISABLE 5 +#define TS_TRIGGER_SCOPE_READ 6 + +#define PROTOCOL_MSG "msg" +#define PROTOCOL_HELLO_PREFIX "***" + +#define TS_RESPONSE_UNDERRUN 0x80 +#define TS_RESPONSE_OVERRUN 0x81 +#define TS_RESPONSE_CRC_FAILURE 0x82 +#define TS_RESPONSE_UNRECOGNIZED_COMMAND 0x83 +#define TS_RESPONSE_OUT_OF_RANGE 0x84 +#define TS_RESPONSE_FRAMING_ERROR 0x8D ! 0x52 82 #define TS_READ_COMMAND 'R' ! 0x47 @@ -86,3 +142,52 @@ #define CMD_ENABLE "enable" #define CMD_DISABLE "disable" #define CMD_TRIGGER_HW_INPUT "trigger_hw_input" + + +#define PROTOCOL_OUTPIN "outpin" +#define PROTOCOL_ANALOG_CHART "analog_chart" +#define PROTOCOL_ENGINE_SNIFFER "wave_chart" +#define PROTOCOL_KNOCK_SPECTROGRAMM "knock_spectrogram" +#define PROTOCOL_VERSION_TAG "rusEfiVersion" +#define PROTOCOL_TEST_RESPONSE_TAG "ts_p_alive" +#define PROTOCOL_SIGNATURE_PREFIX "rusEFI " +#define FRONTEND_TITLE_BAR_NAME "rusEFI" + +! Engine Sniffer Protocol +#define PROTOCOL_ES_DOWN "d" +#define PROTOCOL_ES_UP "u" +#define TOP_DEAD_CENTER_MESSAGE "r" + +! Engine Sniffer channel names +#define PROTOCOL_CRANK1 "t1" +#define PROTOCOL_CRANK2 "t2" + +#define PROTOCOL_VVT1_NAME "VVT1" +#define PROTOCOL_VVT2_NAME "VVT2" +#define PROTOCOL_VVT3_NAME "VVT3" +#define PROTOCOL_VVT4_NAME "VVT4" +#define PROTOCOL_HIP_NAME "HIP" +#define PROTOCOL_TACH_NAME "tach" +#define PROTOCOL_HPFP_NAME "hpfp" +#define PROTOCOL_ACR_NAME "acr" + +#define PROTOCOL_WA_CHANNEL_1 "input1" +#define PROTOCOL_WA_CHANNEL_2 "input2" +#define PROTOCOL_WA_CHANNEL_3 "input3" +#define PROTOCOL_WA_CHANNEL_4 "input4" + +#define MLQ_HEADER_SIZE 24 +#define MLQ_FIELD_HEADER_SIZE 89 + +! TEST_CONTROL_MAGIC_WORD copy-paste while we are learning how to share between rusEFI and stim firmware +#define CAN_BENCH_HEADER2 0x66 + +#define BENCH_FUEL_PUMP_DURATION 3000 +#define BENCH_FAN_DURATION 2000 +#define BENCH_VVT_DURATION 300 +#define BENCH_MAIN_RELAY_DURATION 1000 +#define BENCH_STARTER_DURATION 4000 +#define BENCH_AC_RELAY_DURATION 800 + +#define DEFAULT_SELT_STIM_RPM 1200 +#define DEFAULT_SELT_STIM_VVT0 23 diff --git a/java_console/autotest/src/main/java/com/rusefi/IoUtil.java b/java_console/autotest/src/main/java/com/rusefi/IoUtil.java index 90f909d929..167d0f6b64 100644 --- a/java_console/autotest/src/main/java/com/rusefi/IoUtil.java +++ b/java_console/autotest/src/main/java/com/rusefi/IoUtil.java @@ -168,7 +168,7 @@ public class IoUtil { } public static void realHardwareConnect(LinkManager linkManager, String port) { - linkManager.getEngineState().registerStringValueAction(Fields.PROTOCOL_OUTPIN, (EngineState.ValueCallback) EngineState.ValueCallback.VOID); + linkManager.getEngineState().registerStringValueAction(Integration.PROTOCOL_OUTPIN, (EngineState.ValueCallback) EngineState.ValueCallback.VOID); linkManager.getEngineState().registerStringValueAction(AverageAnglesUtil.KEY, (EngineState.ValueCallback) EngineState.ValueCallback.VOID); try { diff --git a/java_console/autotest/src/main/java/com/rusefi/TestingUtils.java b/java_console/autotest/src/main/java/com/rusefi/TestingUtils.java index 8dbeaddc86..504bbf0123 100644 --- a/java_console/autotest/src/main/java/com/rusefi/TestingUtils.java +++ b/java_console/autotest/src/main/java/com/rusefi/TestingUtils.java @@ -131,7 +131,7 @@ public class TestingUtils { final AtomicReference result = new AtomicReference<>(); FileLog.MAIN.logLine("waiting for next chart"); - commandQueue.getLinkManager().getEngineState().replaceStringValueAction(Fields.PROTOCOL_ENGINE_SNIFFER, new EngineState.ValueCallback() { + commandQueue.getLinkManager().getEngineState().replaceStringValueAction(Integration.PROTOCOL_ENGINE_SNIFFER, new EngineState.ValueCallback() { @Override public void onUpdate(String value) { engineChartLatch.countDown(); @@ -149,6 +149,6 @@ public class TestingUtils { } public static void installVoidEngineSnifferAction(CommandQueue commandQueue) { - commandQueue.getLinkManager().getEngineState().replaceStringValueAction(Fields.PROTOCOL_ENGINE_SNIFFER, (EngineState.ValueCallback) EngineState.ValueCallback.VOID); + commandQueue.getLinkManager().getEngineState().replaceStringValueAction(Integration.PROTOCOL_ENGINE_SNIFFER, (EngineState.ValueCallback) EngineState.ValueCallback.VOID); } } diff --git a/java_console/autotest/src/main/java/com/rusefi/simulator/SimulatorFunctionalTest.java b/java_console/autotest/src/main/java/com/rusefi/simulator/SimulatorFunctionalTest.java index e8c574d63d..75a48e6b23 100644 --- a/java_console/autotest/src/main/java/com/rusefi/simulator/SimulatorFunctionalTest.java +++ b/java_console/autotest/src/main/java/com/rusefi/simulator/SimulatorFunctionalTest.java @@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit; import static com.rusefi.IoUtil.getDisableCommand; import static com.rusefi.binaryprotocol.IoHelper.swap16; -import static com.rusefi.config.generated.Fields.TS_SIMULATE_CAN; +import static com.rusefi.config.generated.Integration.TS_SIMULATE_CAN; import static org.junit.Assert.assertTrue; public class SimulatorFunctionalTest { @@ -45,13 +45,13 @@ public class SimulatorFunctionalTest { int vvtOutputFrequency = 300; // todo: move the constant to Fields testPwmPin(bench_mode_e.BENCH_VVT0_VALVE, vvtOutputFrequency); - testOutputPin(bench_mode_e.BENCH_MAIN_RELAY, Fields.BENCH_MAIN_RELAY_DURATION); - testOutputPin(bench_mode_e.BENCH_FUEL_PUMP, Fields.BENCH_FUEL_PUMP_DURATION); - testOutputPin(bench_mode_e.BENCH_FAN_RELAY, Fields.BENCH_FAN_DURATION); - testOutputPin(bench_mode_e.HD_ACR, Fields.BENCH_AC_RELAY_DURATION); - testOutputPin(bench_mode_e.HD_ACR2, Fields.BENCH_AC_RELAY_DURATION); - testOutputPin(bench_mode_e.BENCH_AC_COMPRESSOR_RELAY, Fields.BENCH_AC_RELAY_DURATION); - testOutputPin(bench_mode_e.BENCH_STARTER_ENABLE_RELAY, Fields.BENCH_STARTER_DURATION); + testOutputPin(bench_mode_e.BENCH_MAIN_RELAY, Integration.BENCH_MAIN_RELAY_DURATION); + testOutputPin(bench_mode_e.BENCH_FUEL_PUMP, Integration.BENCH_FUEL_PUMP_DURATION); + testOutputPin(bench_mode_e.BENCH_FAN_RELAY, Integration.BENCH_FAN_DURATION); + testOutputPin(bench_mode_e.HD_ACR, Integration.BENCH_AC_RELAY_DURATION); + testOutputPin(bench_mode_e.HD_ACR2, Integration.BENCH_AC_RELAY_DURATION); + testOutputPin(bench_mode_e.BENCH_AC_COMPRESSOR_RELAY, Integration.BENCH_AC_RELAY_DURATION); + testOutputPin(bench_mode_e.BENCH_STARTER_ENABLE_RELAY, Integration.BENCH_STARTER_DURATION); EcuTestHelper ecu = new EcuTestHelper(linkManager); ecu.sendCommand(getDisableCommand(Integration.CMD_SELF_STIMULATION)); diff --git a/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java b/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java index d2baf81d39..094a3fadcd 100644 --- a/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java +++ b/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocol.java @@ -74,27 +74,27 @@ public class BinaryProtocol { public static String findCommand(byte command) { switch (command) { - case Fields.TS_PAGE_COMMAND: + case Integration.TS_PAGE_COMMAND: return "PAGE"; - case Fields.TS_COMMAND_F: + case Integration.TS_COMMAND_F: return "PROTOCOL"; - case Fields.TS_CRC_CHECK_COMMAND: + case Integration.TS_CRC_CHECK_COMMAND: return "CRC_CHECK"; - case Fields.TS_BURN_COMMAND: + case Integration.TS_BURN_COMMAND: return "BURN"; - case Fields.TS_HELLO_COMMAND: + case Integration.TS_HELLO_COMMAND: return "HELLO"; case Integration.TS_READ_COMMAND: return "READ"; case Integration.TS_GET_TEXT: return "TS_GET_TEXT"; - case Fields.TS_GET_FIRMWARE_VERSION: + case Integration.TS_GET_FIRMWARE_VERSION: return "GET_FW_VERSION"; case Integration.TS_CHUNK_WRITE_COMMAND: return "WRITE_CHUNK"; - case Fields.TS_OUTPUT_COMMAND: + case Integration.TS_OUTPUT_COMMAND: return "TS_OUTPUT_COMMAND"; - case Fields.TS_RESPONSE_OK: + case Integration.TS_RESPONSE_OK: return "TS_RESPONSE_OK"; default: return "command " + (char) command + "/" + command; @@ -199,7 +199,7 @@ public class BinaryProtocol { byte[] packet = GetOutputsCommand.createRequest(TS_FILE_VERSION_OFFSET, requestSize); String msg = "load TS_CONFIG_VERSION"; - byte[] response = executeCommand(Fields.TS_OUTPUT_COMMAND, packet, msg); + byte[] response = executeCommand(Integration.TS_OUTPUT_COMMAND, packet, msg); if (!checkResponseCode(response) || response.length != requestSize + 1) { close(); return "Failed to " + msg; @@ -427,7 +427,7 @@ public class BinaryProtocol { public int getCrcFromController(int configSize) { byte[] packet = createRequestCrcPayload(configSize); - byte[] response = executeCommand(Fields.TS_CRC_CHECK_COMMAND, packet, "get CRC32"); + byte[] response = executeCommand(Integration.TS_CRC_CHECK_COMMAND, packet, "get CRC32"); if (checkResponseCode(response) && response.length == 5) { ByteBuffer bb = ByteBuffer.wrap(response, 1, 4); @@ -567,7 +567,7 @@ public class BinaryProtocol { long start = System.currentTimeMillis(); while (!isClosed && (System.currentTimeMillis() - start < Timeouts.BINARY_IO_TIMEOUT)) { byte[] response = executeCommand(Integration.TS_EXECUTE, command, "execute"); - if (!checkResponseCode(response, (byte) Fields.TS_RESPONSE_OK) || response.length != 1) { + if (!checkResponseCode(response, (byte) Integration.TS_RESPONSE_OK) || response.length != 1) { continue; } return false; @@ -614,7 +614,7 @@ public class BinaryProtocol { // TODO: Get rid of the +1. This adds a byte at the front to tack a fake TS response code on the front // of the reassembled packet. byte[] reassemblyBuffer = new byte[TS_TOTAL_OUTPUT_SIZE + 1]; - reassemblyBuffer[0] = Fields.TS_RESPONSE_OK; + reassemblyBuffer[0] = Integration.TS_RESPONSE_OK; int reassemblyIdx = 0; int remaining = TS_TOTAL_OUTPUT_SIZE; @@ -624,12 +624,12 @@ public class BinaryProtocol { int chunkSize = Math.min(remaining, Fields.BLOCKING_FACTOR); byte[] response = executeCommand( - Fields.TS_OUTPUT_COMMAND, + Integration.TS_OUTPUT_COMMAND, GetOutputsCommand.createRequest(reassemblyIdx, chunkSize), "output channels" ); - if (response == null || response.length != (chunkSize + 1) || response[0] != Fields.TS_RESPONSE_OK) { + if (response == null || response.length != (chunkSize + 1) || response[0] != Integration.TS_RESPONSE_OK) { return false; } diff --git a/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocolLogger.java b/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocolLogger.java index 493ab1c78e..bee986f870 100644 --- a/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocolLogger.java +++ b/java_console/io/src/main/java/com/rusefi/binaryprotocol/BinaryProtocolLogger.java @@ -79,7 +79,7 @@ public class BinaryProtocolLogger { if (needCompositeLogger) { getComposite(binaryProtocol); } else if (isCompositeLoggerEnabled) { - binaryProtocol.executeCommand(Integration.TS_SET_LOGGER_SWITCH, new byte[]{Fields.TS_COMPOSITE_DISABLE}, "disable composite"); + binaryProtocol.executeCommand(Integration.TS_SET_LOGGER_SWITCH, new byte[]{Integration.TS_COMPOSITE_DISABLE}, "disable composite"); isCompositeLoggerEnabled = false; closeComposites(); } diff --git a/java_console/io/src/main/java/com/rusefi/binaryprotocol/IoHelper.java b/java_console/io/src/main/java/com/rusefi/binaryprotocol/IoHelper.java index f74a4008e1..ae78b46280 100644 --- a/java_console/io/src/main/java/com/rusefi/binaryprotocol/IoHelper.java +++ b/java_console/io/src/main/java/com/rusefi/binaryprotocol/IoHelper.java @@ -2,6 +2,7 @@ package com.rusefi.binaryprotocol; import com.devexperts.logging.Logging; import com.rusefi.config.generated.Fields; +import com.rusefi.config.generated.Integration; import com.rusefi.util.HexBinary; import java.util.zip.CRC32; @@ -69,7 +70,7 @@ public class IoHelper { } public static boolean checkResponseCode(byte[] response) { - return checkResponseCode(response, (byte) Fields.TS_RESPONSE_OK); + return checkResponseCode(response, (byte) Integration.TS_RESPONSE_OK); } /** diff --git a/java_console/io/src/main/java/com/rusefi/io/commands/BurnCommand.java b/java_console/io/src/main/java/com/rusefi/io/commands/BurnCommand.java index 4c97fddfab..7cd4341f9b 100644 --- a/java_console/io/src/main/java/com/rusefi/io/commands/BurnCommand.java +++ b/java_console/io/src/main/java/com/rusefi/io/commands/BurnCommand.java @@ -2,13 +2,14 @@ package com.rusefi.io.commands; import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.config.generated.Fields; +import com.rusefi.config.generated.Integration; import static com.rusefi.binaryprotocol.IoHelper.checkResponseCode; -import static com.rusefi.config.generated.Fields.TS_RESPONSE_BURN_OK; +import static com.rusefi.config.generated.Integration.TS_RESPONSE_BURN_OK; public class BurnCommand { public static boolean execute(BinaryProtocol bp) { - byte[] response = bp.executeCommand(Fields.TS_BURN_COMMAND, "burn"); + byte[] response = bp.executeCommand(Integration.TS_BURN_COMMAND, "burn"); boolean isExpectedBurnResponseCode = checkResponseCode(response, (byte) TS_RESPONSE_BURN_OK); boolean isExpectedBurnResponseLength = response.length == 1; return isExpectedBurnResponseCode && isExpectedBurnResponseLength; diff --git a/java_console/io/src/main/java/com/rusefi/io/commands/ErrorInfoCommand.java b/java_console/io/src/main/java/com/rusefi/io/commands/ErrorInfoCommand.java deleted file mode 100644 index 3a6e1156fa..0000000000 --- a/java_console/io/src/main/java/com/rusefi/io/commands/ErrorInfoCommand.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.rusefi.io.commands; - -import com.rusefi.binaryprotocol.IncomingDataBuffer; -import com.rusefi.config.generated.Fields; -import com.rusefi.io.IoStream; - -import org.jetbrains.annotations.Nullable; - -import java.io.EOFException; -import java.io.IOException; - -import static com.rusefi.io.commands.HelloCommand.getStringResponse; - -public class ErrorInfoCommand { - public static void send(IoStream stream) throws IOException { - stream.sendPacket(new byte[]{Fields.TS_GET_CONFIG_ERROR}); - } - - @Nullable - public static String getResponse(IncomingDataBuffer incomingData) throws EOFException { - return getStringResponse("[config_error]", incomingData); - } - -} diff --git a/java_console/io/src/main/java/com/rusefi/io/commands/HelloCommand.java b/java_console/io/src/main/java/com/rusefi/io/commands/HelloCommand.java index c02e04477d..284d0ea34c 100644 --- a/java_console/io/src/main/java/com/rusefi/io/commands/HelloCommand.java +++ b/java_console/io/src/main/java/com/rusefi/io/commands/HelloCommand.java @@ -2,6 +2,7 @@ package com.rusefi.io.commands; import com.rusefi.binaryprotocol.IncomingDataBuffer; import com.rusefi.config.generated.Fields; +import com.rusefi.config.generated.Integration; import com.rusefi.io.IoStream; import com.rusefi.io.tcp.BinaryProtocolServer; import org.jetbrains.annotations.Nullable; @@ -19,7 +20,7 @@ public class HelloCommand implements Command { } public static void send(IoStream stream) throws IOException { - stream.sendPacket(new byte[]{Fields.TS_HELLO_COMMAND}); + stream.sendPacket(new byte[]{Integration.TS_HELLO_COMMAND}); } @Nullable @@ -37,7 +38,7 @@ public class HelloCommand implements Command { @Override public byte getCommand() { - return Fields.TS_HELLO_COMMAND; + return Integration.TS_HELLO_COMMAND; } @Override diff --git a/java_console/io/src/main/java/com/rusefi/io/commands/PTraceHelper.java b/java_console/io/src/main/java/com/rusefi/io/commands/PTraceHelper.java index 8e80a5d281..ba34c1b57f 100644 --- a/java_console/io/src/main/java/com/rusefi/io/commands/PTraceHelper.java +++ b/java_console/io/src/main/java/com/rusefi/io/commands/PTraceHelper.java @@ -26,7 +26,7 @@ public class PTraceHelper { @NotNull private static List executeGetPTraceCommand(BinaryProtocol bp) { byte[] packet = bp.executeCommand(Integration.TS_PERF_TRACE_GET_BUFFER, "get trace"); - if (!checkResponseCode(packet, (byte) Fields.TS_RESPONSE_OK) || ((packet.length - 1) % 8) != 0) + if (!checkResponseCode(packet, (byte) Integration.TS_RESPONSE_OK) || ((packet.length - 1) % 8) != 0) throw new IllegalStateException("Unsupported command or error? packet length=" + (packet != null ? 0 : packet.length)); return Entry.parseBuffer(packet); diff --git a/java_console/io/src/main/java/com/rusefi/io/tcp/BinaryProtocolProxy.java b/java_console/io/src/main/java/com/rusefi/io/tcp/BinaryProtocolProxy.java index 1f1f8a9f0c..543d74bc79 100644 --- a/java_console/io/src/main/java/com/rusefi/io/tcp/BinaryProtocolProxy.java +++ b/java_console/io/src/main/java/com/rusefi/io/tcp/BinaryProtocolProxy.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.net.Socket; import static com.devexperts.logging.Logging.getLogging; -import static com.rusefi.config.generated.Fields.TS_PROTOCOL; +import static com.rusefi.config.generated.Integration.TS_PROTOCOL; import static com.rusefi.core.FileUtil.close; /** @@ -65,7 +65,7 @@ public class BinaryProtocolProxy { */ while (!targetEcu.isClosed()) { byte firstByte = clientStream.getDataBuffer().readByte(timeoutMs); - if (firstByte == Fields.TS_GET_PROTOCOL_VERSION_COMMAND_F) { + if (firstByte == Integration.TS_GET_PROTOCOL_VERSION_COMMAND_F) { log.info("Responding to GET_PROTOCOL_VERSION with " + TS_PROTOCOL); clientStream.write(TS_PROTOCOL.getBytes()); clientStream.flush(); diff --git a/java_console/io/src/main/java/com/rusefi/io/tcp/BinaryProtocolServer.java b/java_console/io/src/main/java/com/rusefi/io/tcp/BinaryProtocolServer.java index 800ddcabfc..d6d6bb8686 100644 --- a/java_console/io/src/main/java/com/rusefi/io/tcp/BinaryProtocolServer.java +++ b/java_console/io/src/main/java/com/rusefi/io/tcp/BinaryProtocolServer.java @@ -160,15 +160,15 @@ public class BinaryProtocolServer { log.info("Got command " + BinaryProtocol.findCommand(command)); - if (command == Fields.TS_HELLO_COMMAND) { + if (command == Integration.TS_HELLO_COMMAND) { new HelloCommand(Fields.TS_SIGNATURE).handle(stream); - } else if (command == Fields.TS_GET_PROTOCOL_VERSION_COMMAND_F) { + } else if (command == Integration.TS_GET_PROTOCOL_VERSION_COMMAND_F) { stream.sendPacket((TS_OK + TS_PROTOCOL).getBytes()); - } else if (command == Fields.TS_GET_FIRMWARE_VERSION) { + } else if (command == Integration.TS_GET_FIRMWARE_VERSION) { stream.sendPacket((TS_OK + "rusEFI proxy").getBytes()); - } else if (command == Fields.TS_CRC_CHECK_COMMAND) { + } else if (command == Integration.TS_CRC_CHECK_COMMAND) { handleCrc(linkManager, stream); - } else if (command == Fields.TS_PAGE_COMMAND) { + } else if (command == Integration.TS_PAGE_COMMAND) { stream.sendPacket(TS_OK.getBytes()); } else if (command == Integration.TS_READ_COMMAND) { ByteRange byteRange = ByteRange.valueOf(payload); @@ -176,13 +176,13 @@ public class BinaryProtocolServer { } else if (command == Integration.TS_CHUNK_WRITE_COMMAND) { ByteRange byteRange = ByteRange.valueOf(payload); handleWrite(linkManager, payload, byteRange, stream); - } else if (command == Fields.TS_BURN_COMMAND) { + } else if (command == Integration.TS_BURN_COMMAND) { stream.sendPacket(new byte[]{TS_RESPONSE_BURN_OK}); } else if (command == Integration.TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY) { System.err.println("NOT IMPLEMENTED TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY relay"); // todo: relay command stream.sendPacket(TS_OK.getBytes()); - } else if (command == Fields.TS_OUTPUT_COMMAND) { + } else if (command == Integration.TS_OUTPUT_COMMAND) { BinaryProtocolState binaryProtocolState = linkManager.getBinaryProtocolState(); byte[] currentOutputs = binaryProtocolState.getCurrentOutputs(); @@ -252,7 +252,7 @@ public class BinaryProtocolServer { public static int getPacketLength(IncomingDataBuffer in, Handler protocolCommandHandler, int ioTimeout) throws IOException { byte first = in.readByte(ioTimeout); - if (first == Fields.TS_GET_PROTOCOL_VERSION_COMMAND_F) { + if (first == Integration.TS_GET_PROTOCOL_VERSION_COMMAND_F) { protocolCommandHandler.handle(); return 0; } diff --git a/java_console/io/src/main/java/com/rusefi/proxy/BaseBroadcastingThread.java b/java_console/io/src/main/java/com/rusefi/proxy/BaseBroadcastingThread.java index 9c34f4b6da..a62c656984 100644 --- a/java_console/io/src/main/java/com/rusefi/proxy/BaseBroadcastingThread.java +++ b/java_console/io/src/main/java/com/rusefi/proxy/BaseBroadcastingThread.java @@ -4,6 +4,7 @@ import com.devexperts.logging.Logging; import com.rusefi.NamedThreadFactory; import com.rusefi.binaryprotocol.IncomingDataBuffer; import com.rusefi.config.generated.Fields; +import com.rusefi.config.generated.Integration; import com.rusefi.io.commands.HelloCommand; import com.rusefi.io.tcp.BinaryProtocolServer; import com.rusefi.io.tcp.TcpIoStream; @@ -44,7 +45,7 @@ public class BaseBroadcastingThread { byte command = payload[0]; - if (isFirstHello && command == Fields.TS_HELLO_COMMAND) { + if (isFirstHello && command == Integration.TS_HELLO_COMMAND) { // first TS_HELLO_COMMAND is PROXY request, consecutive TS_HELLO_COMMAND would be real deal from user desktop application isFirstHello = false; // respond on hello request with information about session diff --git a/java_console/io/src/main/java/com/rusefi/proxy/client/LocalApplicationProxy.java b/java_console/io/src/main/java/com/rusefi/proxy/client/LocalApplicationProxy.java index cf8980ce3f..3e68a0dfe3 100644 --- a/java_console/io/src/main/java/com/rusefi/proxy/client/LocalApplicationProxy.java +++ b/java_console/io/src/main/java/com/rusefi/proxy/client/LocalApplicationProxy.java @@ -116,7 +116,7 @@ public class LocalApplicationProxy implements Closeable { if (isTimeForApplicationToConnect(lastActivity.get(), BINARY_IO_TIMEOUT / 2)) { // TODO: why is this logic duplicated from BinaryProtocol? byte[] commandPacket = new byte[5]; - commandPacket[0] = Fields.TS_OUTPUT_COMMAND; + commandPacket[0] = Integration.TS_OUTPUT_COMMAND; System.arraycopy(GetOutputsCommand.createRequest(), 0, commandPacket, 1, 4); // we do not really need the data, we just need to take response from the socket diff --git a/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/BinaryProtocolServerSandbox.java b/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/BinaryProtocolServerSandbox.java index 3b639a092e..874c96f432 100644 --- a/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/BinaryProtocolServerSandbox.java +++ b/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/BinaryProtocolServerSandbox.java @@ -34,4 +34,4 @@ class BinaryProtocolServerSandbox { linkManager.setConnector(LinkConnector.getDetachedConnector(state)); new BinaryProtocolServer().start(linkManager); } -} \ No newline at end of file +} diff --git a/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/Elm327Sandbox.java b/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/Elm327Sandbox.java index c9a7ea9f7b..919a9973ad 100644 --- a/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/Elm327Sandbox.java +++ b/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/Elm327Sandbox.java @@ -2,6 +2,7 @@ package com.rusefi.binaryprotocol.test; import com.rusefi.binaryprotocol.IncomingDataBuffer; import com.rusefi.config.generated.Fields; +import com.rusefi.config.generated.Integration; import com.rusefi.io.IoStream; import com.rusefi.io.LinkManager; import com.rusefi.io.can.elm.Elm327Connector; @@ -52,12 +53,12 @@ public class Elm327Sandbox { Elm327Connector.whyDoWeNeedToSleepBetweenCommands(); { - tsStream.sendPacket(new byte[]{Fields.TS_HELLO_COMMAND}); + tsStream.sendPacket(new byte[]{Integration.TS_HELLO_COMMAND}); byte[] response = dataBuffer.getPacket("[hello command]"); if (!checkResponseCode(response)) return; String signature = new String(response, 1, response.length - 1); - System.out.println(Fields.TS_HELLO_COMMAND + " returned " + signature); + System.out.println(Integration.TS_HELLO_COMMAND + " returned " + signature); if (!signature.startsWith(Fields.PROTOCOL_SIGNATURE_PREFIX)) throw new IllegalStateException("Unexpected S " + signature); diff --git a/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/SandboxCommon.java b/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/SandboxCommon.java index 057df09714..4a76b7549b 100644 --- a/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/SandboxCommon.java +++ b/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/SandboxCommon.java @@ -6,6 +6,7 @@ import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.binaryprotocol.BinaryProtocolState; import com.rusefi.binaryprotocol.IncomingDataBuffer; import com.rusefi.config.generated.Fields; +import com.rusefi.config.generated.Integration; import com.rusefi.io.ConnectionStateListener; import com.rusefi.util.HexBinary; import com.rusefi.io.IoStream; @@ -82,7 +83,7 @@ public class SandboxCommon { static void runGetProtocolCommand(String prefix, IoStream tsStream) throws IOException { IncomingDataBuffer dataBuffer = tsStream.getDataBuffer(); - tsStream.write(new byte[]{Fields.TS_GET_PROTOCOL_VERSION_COMMAND_F}); + tsStream.write(new byte[]{Integration.TS_GET_PROTOCOL_VERSION_COMMAND_F}); tsStream.flush(); byte[] fResponse = new byte[3]; dataBuffer.waitForBytes("hello", System.currentTimeMillis(), fResponse.length); diff --git a/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/TcpServerSandbox.java b/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/TcpServerSandbox.java index 71dc32909f..c189321f14 100644 --- a/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/TcpServerSandbox.java +++ b/java_console/io/src/test/java/com/rusefi/binaryprotocol/test/TcpServerSandbox.java @@ -94,16 +94,16 @@ public class TcpServerSandbox { byte command = payload[0]; - if (command == Fields.TS_HELLO_COMMAND) { + if (command == Integration.TS_HELLO_COMMAND) { new HelloCommand(Fields.TS_SIGNATURE).handle(stream); - } else if (command == Fields.TS_GET_PROTOCOL_VERSION_COMMAND_F) { + } else if (command == Integration.TS_GET_PROTOCOL_VERSION_COMMAND_F) { stream.sendPacket((TS_OK + TS_PROTOCOL).getBytes()); - } else if (command == Fields.TS_PAGE_COMMAND) { + } else if (command == Integration.TS_PAGE_COMMAND) { stream.sendPacket(TS_OK.getBytes()); - } else if (command == Fields.TS_CRC_CHECK_COMMAND) { + } else if (command == Integration.TS_CRC_CHECK_COMMAND) { stream.sendPacket(BinaryProtocolServer.createCrcResponse(TOTALLY_EMPTY_CONFIGURATION)); } else if (command == Integration.TS_SET_LOGGER_SWITCH) { - if (payload[1] == Fields.TS_COMPOSITE_READ) { + if (payload[1] == Integration.TS_COMPOSITE_READ) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos.write(TS_OK.charAt(0)); LittleEndianOutputStream dout = new LittleEndianOutputStream(baos); @@ -121,10 +121,10 @@ public class TcpServerSandbox { } else { stream.sendPacket(TS_OK.getBytes()); } - } else if (command == Fields.TS_OUTPUT_COMMAND) { + } else if (command == Integration.TS_OUTPUT_COMMAND) { byte[] response = getOutputCommandResponse(payload, ecuState.outputs); stream.sendPacket(response); - } else if (command == Fields.TS_GET_SCATTERED_GET_COMMAND) { + } else if (command == Integration.TS_GET_SCATTERED_GET_COMMAND) { // System.out.println("Cool TS_GET_SCATTERED_GET_COMMAND"); int startOffset = HIGHSPEEDOFFSETS.getOffset(); int totalResponseSize = 0; @@ -149,8 +149,8 @@ public class TcpServerSandbox { System.out.println("TS_CHUNK_WRITE_COMMAND " + byteRange + " payload " + payload.length); System.arraycopy(payload, WriteChunkCommand.SCR_POS_WITH, TOTALLY_EMPTY_CONFIGURATION, byteRange.getOffset(), byteRange.getCount()); stream.sendPacket(TS_OK.getBytes()); - } else if (command == Fields.TS_BURN_COMMAND) { - stream.sendPacket(new byte[]{Fields.TS_RESPONSE_BURN_OK}); + } else if (command == Integration.TS_BURN_COMMAND) { + stream.sendPacket(new byte[]{Integration.TS_RESPONSE_BURN_OK}); } else if (command == Integration.TS_READ_COMMAND) { ByteRange byteRange = ByteRange.valueOf(payload); int count = byteRange.getCount(); @@ -158,7 +158,7 @@ public class TcpServerSandbox { byte[] response = new byte[1 + count]; response[0] = (byte) TS_OK.charAt(0); stream.sendPacket(response); - } else if (command == Fields.TS_GET_FIRMWARE_VERSION) { + } else if (command == Integration.TS_GET_FIRMWARE_VERSION) { stream.sendPacket((TS_OK + "rusEFI proxy").getBytes()); } else throw new UnsupportedOperationException("Unsupported command " + BinaryProtocol.findCommand(command)); diff --git a/java_console/io/src/test/java/com/rusefi/test/OchGetCommandTest.java b/java_console/io/src/test/java/com/rusefi/test/OchGetCommandTest.java index 03028ff271..99f9915f9b 100644 --- a/java_console/io/src/test/java/com/rusefi/test/OchGetCommandTest.java +++ b/java_console/io/src/test/java/com/rusefi/test/OchGetCommandTest.java @@ -3,6 +3,7 @@ package com.rusefi.test; import com.rusefi.binaryprotocol.BinaryProtocol; import com.rusefi.binaryprotocol.IoHelper; import com.rusefi.config.generated.Fields; +import com.rusefi.config.generated.Integration; import com.rusefi.io.commands.GetOutputsCommand; //import org.apache.commons.codec.binary.Hex; import org.junit.jupiter.api.Assertions; @@ -16,7 +17,7 @@ public class OchGetCommandTest { int offset = 400; int chunkSize = 300; byte[] payload = GetOutputsCommand.createRequest(offset, chunkSize); - byte[] fullPacket = BinaryProtocol.getFullRequest((byte) Fields.TS_OUTPUT_COMMAND, payload); + byte[] fullPacket = BinaryProtocol.getFullRequest((byte) Integration.TS_OUTPUT_COMMAND, payload); // System.out.println("OchGetCommand command " + Hex.encodeHexString(fullPacket, false)); assertArrayEquals(new byte[]{0x4f, (byte) 0x90, 0x01, 0x2c, 0x01}, fullPacket); diff --git a/java_console/models/src/main/java/com/rusefi/config/generated/Integration.java b/java_console/models/src/main/java/com/rusefi/config/generated/Integration.java index d4e0cc6155..0a8d2b59f7 100644 --- a/java_console/models/src/main/java/com/rusefi/config/generated/Integration.java +++ b/java_console/models/src/main/java/com/rusefi/config/generated/Integration.java @@ -1,6 +1,13 @@ package com.rusefi.config.generated; public class Integration { + public static final int BENCH_AC_RELAY_DURATION = 800; + public static final int BENCH_FAN_DURATION = 2000; + public static final int BENCH_FUEL_PUMP_DURATION = 3000; + public static final int BENCH_MAIN_RELAY_DURATION = 1000; + public static final int BENCH_STARTER_DURATION = 4000; + public static final int BENCH_VVT_DURATION = 300; + public static final int CAN_BENCH_HEADER2 = 0x66; public static final String CMD_AC_RELAY_BENCH = "acrelaybench"; public static final String CMD_ALTERNATOR_PIN = "set_alternator_pin"; public static final String CMD_BOOST_PIN = "set_boost_pin"; @@ -49,22 +56,81 @@ public class Integration { public static final String CMD_TRIGGERINFO = "triggerinfo"; public static final String CMD_VSS_PIN = "vss_pin"; public static final String CMD_WRITECONFIG = "writeconfig"; + public static final int DEFAULT_SELT_STIM_RPM = 1200; + public static final int DEFAULT_SELT_STIM_VVT0 = 23; + public static final int ENGINE_SNIFFER_UNIT_US = 10; + public static final String FRONTEND_TITLE_BAR_NAME = "rusEFI"; + public static final int MLQ_FIELD_HEADER_SIZE = 89; + public static final int MLQ_HEADER_SIZE = 24; + public static final String PROTOCOL_ACR_NAME = "acr"; + public static final String PROTOCOL_ANALOG_CHART = "analog_chart"; + public static final String PROTOCOL_CRANK1 = "t1"; + public static final String PROTOCOL_CRANK2 = "t2"; + public static final String PROTOCOL_ENGINE_SNIFFER = "wave_chart"; + public static final String PROTOCOL_ES_DOWN = "d"; + public static final String PROTOCOL_ES_UP = "u"; + public static final String PROTOCOL_HELLO_PREFIX = "***"; + public static final String PROTOCOL_HIP_NAME = "HIP"; + public static final String PROTOCOL_HPFP_NAME = "hpfp"; + public static final String PROTOCOL_KNOCK_SPECTROGRAMM = "knock_spectrogram"; + public static final String PROTOCOL_MSG = "msg"; + public static final String PROTOCOL_OUTPIN = "outpin"; + public static final String PROTOCOL_SIGNATURE_PREFIX = "rusEFI "; + public static final String PROTOCOL_TACH_NAME = "tach"; + public static final String PROTOCOL_TEST_RESPONSE_TAG = "ts_p_alive"; + public static final String PROTOCOL_VERSION_TAG = "rusEfiVersion"; + public static final String PROTOCOL_VVT1_NAME = "VVT1"; + public static final String PROTOCOL_VVT2_NAME = "VVT2"; + public static final String PROTOCOL_VVT3_NAME = "VVT3"; + public static final String PROTOCOL_VVT4_NAME = "VVT4"; + public static final String PROTOCOL_WA_CHANNEL_1 = "input1"; + public static final String PROTOCOL_WA_CHANNEL_2 = "input2"; + public static final String PROTOCOL_WA_CHANNEL_3 = "input3"; + public static final String PROTOCOL_WA_CHANNEL_4 = "input4"; + public static final String TOP_DEAD_CENTER_MESSAGE = "r"; + public static final char TS_BURN_COMMAND = 'B'; public static final char TS_CHUNK_WRITE_COMMAND = 'C'; + public static final char TS_COMMAND_F = 'F'; + public static final int TS_COMPOSITE_DISABLE = 2; + public static final int TS_COMPOSITE_ENABLE = 1; + public static final int TS_COMPOSITE_READ = 3; + public static final char TS_CRC_CHECK_COMMAND = 'k'; public static final char TS_EXECUTE = 'E'; public static final char TS_GET_COMPOSITE_BUFFER_DONE_DIFFERENTLY = '8'; + public static final char TS_GET_CONFIG_ERROR = 'e'; + public static final char TS_GET_FIRMWARE_VERSION = 'V'; public static final char TS_GET_OUTPUTS_SIZE = '4'; + public static final char TS_GET_PROTOCOL_VERSION_COMMAND_F = 'F'; public static final char TS_GET_SCATTERED_GET_COMMAND = '9'; public static final char TS_GET_TEXT = 'G'; + public static final char TS_HELLO_COMMAND = 'S'; + public static final char TS_IO_TEST_COMMAND = 'Z'; public static final char TS_KNOCK_SPECTROGRAM_DISABLE = 'n'; public static final char TS_KNOCK_SPECTROGRAM_ENABLE = 'm'; public static final char TS_ONLINE_PROTOCOL = 'z'; + public static final char TS_OUTPUT_COMMAND = 'O'; + public static final char TS_PAGE_COMMAND = 'P'; public static final char TS_PERF_TRACE_BEGIN = '_'; public static final char TS_PERF_TRACE_GET_BUFFER = 'b'; + public static final String TS_PROTOCOL = "001"; public static final char TS_QUERY_BOOTLOADER = 'L'; public static final int TS_QUERY_BOOTLOADER_NONE = 0; public static final int TS_QUERY_BOOTLOADER_OPENBLT = 1; + public static final char TS_QUERY_COMMAND = 'Q'; public static final char TS_READ_COMMAND = 'R'; + public static final int TS_RESPONSE_BURN_OK = 4; + public static final int TS_RESPONSE_CRC_FAILURE = 0x82; + public static final int TS_RESPONSE_FRAMING_ERROR = 0x8D; + public static final int TS_RESPONSE_OK = 0; + public static final int TS_RESPONSE_OUT_OF_RANGE = 0x84; + public static final int TS_RESPONSE_OVERRUN = 0x81; + public static final int TS_RESPONSE_UNDERRUN = 0x80; + public static final int TS_RESPONSE_UNRECOGNIZED_COMMAND = 0x83; public static final char TS_SET_LOGGER_SWITCH = 'l'; + public static final char TS_SIMULATE_CAN = '>'; public static final char TS_SINGLE_WRITE_COMMAND = 'W'; public static final char TS_TEST_COMMAND = 't'; + public static final int TS_TRIGGER_SCOPE_DISABLE = 5; + public static final int TS_TRIGGER_SCOPE_ENABLE = 4; + public static final int TS_TRIGGER_SCOPE_READ = 6; } diff --git a/java_console/ui/src/main/java/com/rusefi/SerialPortScanner.java b/java_console/ui/src/main/java/com/rusefi/SerialPortScanner.java index 3fc932f202..619197f7d9 100644 --- a/java_console/ui/src/main/java/com/rusefi/SerialPortScanner.java +++ b/java_console/ui/src/main/java/com/rusefi/SerialPortScanner.java @@ -366,7 +366,7 @@ public enum SerialPortScanner { stream.sendPacket(new byte[]{(byte) Integration.TS_QUERY_BOOTLOADER}); byte[] response = stream.getDataBuffer().getPacket(500, "ecuHasOpenblt"); - if (!IoHelper.checkResponseCode(response, (byte) Fields.TS_RESPONSE_OK)) { + if (!IoHelper.checkResponseCode(response, (byte) Integration.TS_RESPONSE_OK)) { // ECU didn't understand request, bootloader certainly not supported return false; } diff --git a/java_console/ui/src/main/java/com/rusefi/ui/knock/KnockPane.java b/java_console/ui/src/main/java/com/rusefi/ui/knock/KnockPane.java index 632e0c0cb3..f8ff092781 100644 --- a/java_console/ui/src/main/java/com/rusefi/ui/knock/KnockPane.java +++ b/java_console/ui/src/main/java/com/rusefi/ui/knock/KnockPane.java @@ -89,7 +89,7 @@ public class KnockPane { uiContext.getLinkManager().submit(() -> { //uiContext.getLinkManager().setCompositeLogicEnabled(false); // todo: use big_buffer BinaryProtocol binaryProtocol = uiContext.getLinkManager().getConnector().getBinaryProtocol(); - binaryProtocol.executeCommand(Fields.TS_KNOCK_SPECTROGRAM_ENABLE, "start knock analyzer"); + binaryProtocol.executeCommand(Integration.TS_KNOCK_SPECTROGRAM_ENABLE, "start knock analyzer"); }); } }); diff --git a/java_tools/proxy_server/src/main/java/com/rusefi/server/ControllerConnectionState.java b/java_tools/proxy_server/src/main/java/com/rusefi/server/ControllerConnectionState.java index 7c8afa9945..510ac16bd4 100644 --- a/java_tools/proxy_server/src/main/java/com/rusefi/server/ControllerConnectionState.java +++ b/java_tools/proxy_server/src/main/java/com/rusefi/server/ControllerConnectionState.java @@ -2,6 +2,7 @@ package com.rusefi.server; import com.devexperts.logging.Logging; import com.opensr5.ini.IniFileModel; +import com.rusefi.config.generated.Integration; import com.rusefi.core.SignatureHelper; import com.rusefi.auth.AuthTokenUtil; import com.rusefi.binaryprotocol.IncomingDataBuffer; @@ -130,7 +131,7 @@ public class ControllerConnectionState { public void getOutputs() throws IOException { // TODO: why is this logic duplicated from BinaryProtocol? byte[] commandPacket = new byte[5]; - commandPacket[0] = Fields.TS_OUTPUT_COMMAND; + commandPacket[0] = Integration.TS_OUTPUT_COMMAND; System.arraycopy(GetOutputsCommand.createRequest(), 0, commandPacket, 1, 4); long start = System.currentTimeMillis(); @@ -167,7 +168,7 @@ public class ControllerConnectionState { public void invokeOnlineCommand(byte command) throws IOException { byte[] packet = new byte[2]; - packet[0] = Fields.TS_ONLINE_PROTOCOL; + packet[0] = Integration.TS_ONLINE_PROTOCOL; packet[1] = command; stream.sendPacket(packet); } diff --git a/java_tools/proxy_server/src/test/java/com/rusefi/ServerTest.java b/java_tools/proxy_server/src/test/java/com/rusefi/ServerTest.java index 26fd3e7382..b5ff9b2eed 100644 --- a/java_tools/proxy_server/src/test/java/com/rusefi/ServerTest.java +++ b/java_tools/proxy_server/src/test/java/com/rusefi/ServerTest.java @@ -1,6 +1,7 @@ package com.rusefi; import com.rusefi.config.generated.Fields; +import com.rusefi.config.generated.Integration; import com.rusefi.io.IoStream; import com.rusefi.io.commands.GetOutputsCommand; import com.rusefi.io.commands.HelloCommand; @@ -203,7 +204,7 @@ covered by FullServerTest protected void handleCommand(BinaryProtocolServer.Packet packet, TcpIoStream stream) throws IOException { super.handleCommand(packet, stream); - if (packet.getPacket()[0] == Fields.TS_OUTPUT_COMMAND) { + if (packet.getPacket()[0] == Integration.TS_OUTPUT_COMMAND) { GetOutputsCommand.sendOutput(stream); } } diff --git a/java_tools/proxy_server/src/test/java/com/rusefi/proxy/client/LocalApplicationProxyTest.java b/java_tools/proxy_server/src/test/java/com/rusefi/proxy/client/LocalApplicationProxyTest.java index c5f8efc6f7..745a3e1f21 100644 --- a/java_tools/proxy_server/src/test/java/com/rusefi/proxy/client/LocalApplicationProxyTest.java +++ b/java_tools/proxy_server/src/test/java/com/rusefi/proxy/client/LocalApplicationProxyTest.java @@ -4,6 +4,7 @@ import com.rusefi.BackendTestHelper; import com.rusefi.TestHelper; import com.rusefi.Timeouts; import com.rusefi.config.generated.Fields; +import com.rusefi.config.generated.Integration; import com.rusefi.io.IoStream; import com.rusefi.io.commands.GetOutputsCommand; import com.rusefi.io.commands.HelloCommand; @@ -29,7 +30,7 @@ import static com.rusefi.TestHelper.*; import static com.rusefi.Timeouts.SECOND; import static com.rusefi.binaryprotocol.BinaryProtocol.findCommand; import static com.rusefi.binaryprotocol.BinaryProtocol.sleep; -import static com.rusefi.config.generated.Fields.TS_PROTOCOL; +import static com.rusefi.config.generated.Integration.TS_PROTOCOL; import static com.rusefi.io.tcp.BinaryProtocolServer.getPacketLength; import static com.rusefi.io.tcp.TcpConnector.LOCALHOST; import static com.rusefi.core.FileUtil.close; @@ -78,14 +79,14 @@ public class LocalApplicationProxyTest { byte[] protocolResponse = new byte[TS_PROTOCOL.length()]; // request - applicationConnection.write(new byte[] {Fields.TS_COMMAND_F}); + applicationConnection.write(new byte[] {Integration.TS_COMMAND_F}); applicationConnection.flush(); // response applicationConnection.getDataBuffer().read(protocolResponse); assertArrayEquals(protocolResponse, TS_PROTOCOL.getBytes()); // request again - applicationConnection.write(new byte[] {Fields.TS_COMMAND_F}); + applicationConnection.write(new byte[] {Integration.TS_COMMAND_F}); applicationConnection.flush(); // response again applicationConnection.getDataBuffer().read(protocolResponse); @@ -93,7 +94,7 @@ public class LocalApplicationProxyTest { // TODO: why is this logic duplicated from BinaryProtocol? byte[] commandPacket = new byte[5]; - commandPacket[0] = Fields.TS_OUTPUT_COMMAND; + commandPacket[0] = Integration.TS_OUTPUT_COMMAND; System.arraycopy(GetOutputsCommand.createRequest(), 0, commandPacket, 1, 4); applicationConnection.sendPacket(commandPacket);