Fields.java is a mess #6711

new home for protocol constants
This commit is contained in:
Andrey 2024-07-13 17:37:34 -04:00 committed by rusefillc
parent ebeed4e9ea
commit 25ab3b2cc1
10 changed files with 76 additions and 16 deletions

View File

@ -58,6 +58,7 @@ COMMON_GEN_CONFIG="
-signature tunerstudio/generated/signature_${SHORT_BOARD_NAME}.txt \
-signature_destination controllers/generated/signature_${SHORT_BOARD_NAME}.h \
-ts_output_name generated/${INI} \
-prepend integration/ts_protocol.txt \
-prepend integration/rusefi_config_trigger.txt \
-prepend ${BOARD_DIR}/prepend.txt \
-board ${BOARD_DIR}"

View File

@ -4,6 +4,10 @@ cd $(dirname "$0")
rm gen_live_documentation.log
java -DSystemOut.name=logs/gen_live_documentation \
-cp ../java_tools/configuration_definition_base/build/libs/config_definition_base-all.jar \
com.rusefi.SimpleDefinesProcessor integration/ts_protocol.txt
java -DSystemOut.name=logs/gen_live_documentation \
-cp ../java_tools/configuration_definition_base/build/libs/config_definition_base-all.jar \
com.rusefi.ldmp.LiveDataProcessor integration/LiveData.yaml${EXTRA_LIVE_DATA_FILE} integration/rusefi_config_trigger.txt ../unit_tests/test-framework/trigger_meta_generated.h ../java_tools/trigger-image/src/main/java/com/rusefi/config/generated/TriggerMeta.java

View File

@ -2396,10 +2396,6 @@ end_struct
#define TS_SIMULATE_CAN '>'
! 0x57 pageValueWrite
#define TS_SINGLE_WRITE_COMMAND 'W'
! 0x43 pageChunkWrite
#define TS_CHUNK_WRITE_COMMAND 'C'
! 0x42 burnCommand
#define TS_BURN_COMMAND 'B'
! 0x77
@ -2411,12 +2407,6 @@ end_struct
! Engine Sniffer time stamp unit, in microseconds
#define ENGINE_SNIFFER_UNIT_US 10
! These commands are used exclusively by the rusEFI console
! 0x74
#define TS_TEST_COMMAND 't'
! High speed logger commands
#define TS_SET_LOGGER_SWITCH 'l'
#define TS_COMPOSITE_ENABLE 1
#define TS_COMPOSITE_DISABLE 2

View File

@ -0,0 +1,11 @@
! 0x57 pageValueWrite
#define TS_SINGLE_WRITE_COMMAND 'W'
! 0x43 pageChunkWrite
#define TS_CHUNK_WRITE_COMMAND 'C'
! These commands are used exclusively by the rusEFI console
! 0x74
#define TS_TEST_COMMAND 't'
! High speed logger commands
#define TS_SET_LOGGER_SWITCH 'l'

View File

@ -7,6 +7,7 @@ import com.opensr5.io.ConfigurationImageFile;
import com.opensr5.io.DataListener;
import com.rusefi.ConfigurationImageDiff;
import com.rusefi.NamedThreadFactory;
import com.rusefi.config.generated.Integration;
import com.rusefi.core.SignatureHelper;
import com.rusefi.Timeouts;
import com.rusefi.binaryprotocol.test.Bug3923;
@ -89,7 +90,7 @@ public class BinaryProtocol {
return "TS_GET_TEXT";
case Fields.TS_GET_FIRMWARE_VERSION:
return "GET_FW_VERSION";
case Fields.TS_CHUNK_WRITE_COMMAND:
case Integration.TS_CHUNK_WRITE_COMMAND:
return "WRITE_CHUNK";
case Fields.TS_OUTPUT_COMMAND:
return "TS_OUTPUT_COMMAND";
@ -511,7 +512,7 @@ public class BinaryProtocol {
long start = System.currentTimeMillis();
while (!isClosed && (System.currentTimeMillis() - start < Timeouts.BINARY_IO_TIMEOUT)) {
byte[] response = executeCommand(Fields.TS_CHUNK_WRITE_COMMAND, packet, "writeImage");
byte[] response = executeCommand(Integration.TS_CHUNK_WRITE_COMMAND, packet, "writeImage");
if (!checkResponseCode(response) || response.length != 1) {
log.error("writeData: Something is wrong, retrying...");
continue;

View File

@ -6,6 +6,7 @@ import com.rusefi.Timeouts;
import com.rusefi.composite.CompositeEvent;
import com.rusefi.composite.CompositeParser;
import com.rusefi.config.generated.Fields;
import com.rusefi.config.generated.Integration;
import com.rusefi.core.Sensor;
import com.rusefi.core.SensorCentral;
import com.rusefi.io.LinkManager;
@ -78,7 +79,7 @@ public class BinaryProtocolLogger {
if (needCompositeLogger) {
getComposite(binaryProtocol);
} else if (isCompositeLoggerEnabled) {
binaryProtocol.executeCommand(Fields.TS_SET_LOGGER_SWITCH, new byte[]{Fields.TS_COMPOSITE_DISABLE}, "disable composite");
binaryProtocol.executeCommand(Integration.TS_SET_LOGGER_SWITCH, new byte[]{Fields.TS_COMPOSITE_DISABLE}, "disable composite");
isCompositeLoggerEnabled = false;
closeComposites();
}

View File

@ -11,6 +11,7 @@ import com.rusefi.binaryprotocol.BinaryProtocolState;
import com.rusefi.binaryprotocol.IncomingDataBuffer;
import com.rusefi.binaryprotocol.IoHelper;
import com.rusefi.config.generated.Fields;
import com.rusefi.config.generated.Integration;
import com.rusefi.util.HexBinary;
import com.rusefi.io.LinkManager;
import com.rusefi.io.commands.ByteRange;
@ -172,7 +173,7 @@ public class BinaryProtocolServer {
} else if (command == Fields.TS_READ_COMMAND) {
ByteRange byteRange = ByteRange.valueOf(payload);
handleRead(linkManager, byteRange, stream);
} else if (command == Fields.TS_CHUNK_WRITE_COMMAND) {
} 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) {

View File

@ -6,6 +6,7 @@ import com.rusefi.Listener;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.binaryprotocol.IncomingDataBuffer;
import com.rusefi.config.generated.Fields;
import com.rusefi.config.generated.Integration;
import com.rusefi.config.generated.TsOutputs;
import com.rusefi.io.IoStream;
import com.rusefi.io.commands.ByteRange;
@ -101,7 +102,7 @@ public class TcpServerSandbox {
stream.sendPacket(TS_OK.getBytes());
} else if (command == Fields.TS_CRC_CHECK_COMMAND) {
stream.sendPacket(BinaryProtocolServer.createCrcResponse(TOTALLY_EMPTY_CONFIGURATION));
} else if (command == Fields.TS_SET_LOGGER_SWITCH) {
} else if (command == Integration.TS_SET_LOGGER_SWITCH) {
if (payload[1] == Fields.TS_COMPOSITE_READ) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(TS_OK.charAt(0));
@ -143,7 +144,7 @@ public class TcpServerSandbox {
response[0] = (byte) TS_OK.charAt(0);
stream.sendPacket(response);
} else if (command == Fields.TS_CHUNK_WRITE_COMMAND) {
} else if (command == Integration.TS_CHUNK_WRITE_COMMAND) {
ByteRange byteRange = ByteRange.valueOf(payload);
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());

View File

@ -0,0 +1,8 @@
package com.rusefi.config.generated;
public class Integration {
public static final char TS_CHUNK_WRITE_COMMAND = 'C';
public static final char TS_SET_LOGGER_SWITCH = 'l';
public static final char TS_SINGLE_WRITE_COMMAND = 'W';
public static final char TS_TEST_COMMAND = 't';
}

View File

@ -0,0 +1,42 @@
package com.rusefi;
import com.rusefi.ldmp.LiveDataProcessor;
import com.rusefi.output.FileJavaFieldsConsumer;
import com.rusefi.util.LazyFile;
import java.io.BufferedReader;
import java.io.IOException;
import static com.rusefi.ToolUtil.EOL;
public class SimpleDefinesProcessor {
public static void main(String[] args) throws IOException {
if (args.length != 1)
throw new IllegalStateException("Arguments expected");
VariableRegistry variableRegistry = new VariableRegistry();
String definitionInputFile = args[0];
read(variableRegistry, definitionInputFile);
String className = "Integration";
LazyFile javaFields = LazyFile.REAL.create(LiveDataProcessor.JAVA_DESTINATION + className + ".java");
FileJavaFieldsConsumer.writePackageLine(javaFields);
FileJavaFieldsConsumer.writeClassOpenLine(javaFields, className);
javaFields.write(variableRegistry.getJavaConstants());
javaFields.write("}" + EOL);
javaFields.close();
}
private static void read(VariableRegistry variableRegistry, String definitionInputFile) throws IOException {
String fileNameWithRoot = RootHolder.ROOT + definitionInputFile;
try (BufferedReader definitionReader = new BufferedReader(ReaderProvider.REAL.read(fileNameWithRoot))) {
String line;
while ((line = definitionReader.readLine()) != null) {
if (VariableRegistry.looksLikeDefineLine(line))
variableRegistry.processLine(line);
}
}
}
}