Fields.java is a mess #6711

only:new home for protocol constants
This commit is contained in:
Andrey 2024-07-13 22:39:36 -04:00
parent 4229eed646
commit 6ca8f80025
27 changed files with 249 additions and 195 deletions

View File

@ -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"

View File

@ -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

View File

@ -168,7 +168,7 @@ public class IoUtil {
}
public static void realHardwareConnect(LinkManager linkManager, String port) {
linkManager.getEngineState().registerStringValueAction(Fields.PROTOCOL_OUTPIN, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
linkManager.getEngineState().registerStringValueAction(Integration.PROTOCOL_OUTPIN, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
linkManager.getEngineState().registerStringValueAction(AverageAnglesUtil.KEY, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
try {

View File

@ -131,7 +131,7 @@ public class TestingUtils {
final AtomicReference<String> result = new AtomicReference<>();
FileLog.MAIN.logLine("waiting for next chart");
commandQueue.getLinkManager().getEngineState().replaceStringValueAction(Fields.PROTOCOL_ENGINE_SNIFFER, new EngineState.ValueCallback<String>() {
commandQueue.getLinkManager().getEngineState().replaceStringValueAction(Integration.PROTOCOL_ENGINE_SNIFFER, new EngineState.ValueCallback<String>() {
@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<String>) EngineState.ValueCallback.VOID);
commandQueue.getLinkManager().getEngineState().replaceStringValueAction(Integration.PROTOCOL_ENGINE_SNIFFER, (EngineState.ValueCallback<String>) EngineState.ValueCallback.VOID);
}
}

View File

@ -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));

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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);
}
/**

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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

View File

@ -26,7 +26,7 @@ public class PTraceHelper {
@NotNull
private static List<Entry> 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);

View File

@ -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();

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -34,4 +34,4 @@ class BinaryProtocolServerSandbox {
linkManager.setConnector(LinkConnector.getDetachedConnector(state));
new BinaryProtocolServer().start(linkManager);
}
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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");
});
}
});

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);