diff --git a/firmware/config/boards/kinetis/config/!gen_enum_to_string.bat b/firmware/config/boards/kinetis/config/!gen_enum_to_string.bat index 888837aba4..5c72f7c59f 100644 --- a/firmware/config/boards/kinetis/config/!gen_enum_to_string.bat +++ b/firmware/config/boards/kinetis/config/!gen_enum_to_string.bat @@ -4,7 +4,8 @@ rem This batch files reads rusefi_enums.h and produses auto_generated_enums.* fi cd ../../../.. -java -jar ../java_tools/enum2string.jar ^ +java -DSystemOut.name=gen_enum_to_string_kinetis ^ + -jar ../java_tools/enum2string.jar ^ -inputPath . ^ -outputPath config/boards/kinetis/config/controllers/algo ^ -enumInputFile controllers/algo/rusefi_enums.h ^ diff --git a/java_console/logging/src/com/rusefi/util/SystemOut.java b/java_console/logging/src/com/rusefi/util/SystemOut.java index 820b8d963b..c1a264f570 100644 --- a/java_console/logging/src/com/rusefi/util/SystemOut.java +++ b/java_console/logging/src/com/rusefi/util/SystemOut.java @@ -28,6 +28,13 @@ public class SystemOut { String fileName = System.getProperty("SystemOut.name", "rusefi_tool") + LOG; System.out.println("Opening " + fileName); logFile = new PrintWriter(new FileWriter(fileName, true)); + Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { + @Override + public void run() { + close(); + System.out.println("SystemOut Hook done!"); + } + })); } @SuppressWarnings("ThrowablePrintedToSystemOut") @@ -45,8 +52,10 @@ public class SystemOut { println(object == null ? "(null)" : object.toString()); } - public static void close() { - logFile.close(); + public synchronized static void close() { + if (logFile != null) { + logFile.close(); + } logFile = null; } } diff --git a/java_tools/configuration_definition/.idea/modules.xml b/java_tools/configuration_definition/.idea/modules.xml index 11feaea009..2fcba563b6 100644 --- a/java_tools/configuration_definition/.idea/modules.xml +++ b/java_tools/configuration_definition/.idea/modules.xml @@ -4,6 +4,7 @@ + \ No newline at end of file diff --git a/java_tools/configuration_definition/build.xml b/java_tools/configuration_definition/build.xml index b9fc4b5cc5..722f38e89e 100644 --- a/java_tools/configuration_definition/build.xml +++ b/java_tools/configuration_definition/build.xml @@ -14,8 +14,9 @@ debug="true" target="${javac.target}" destdir="build/classes" - classpath="lib/junit.jar:lib/annotations.jar:lib/snakeyaml.jar"> + classpath="lib/junit.jar:../../java_console/lib/annotations.jar:lib/snakeyaml.jar"> + diff --git a/java_tools/configuration_definition/src/com/rusefi/board_generator/BoardReader.java b/java_tools/configuration_definition/src/com/rusefi/board_generator/BoardReader.java index af6c1822fa..6c869694df 100644 --- a/java_tools/configuration_definition/src/com/rusefi/board_generator/BoardReader.java +++ b/java_tools/configuration_definition/src/com/rusefi/board_generator/BoardReader.java @@ -25,7 +25,6 @@ public class BoardReader { ); return; } - String boardName = null; String firmwarePath = "firmware"; String outputPath = "."; @@ -44,20 +43,24 @@ public class BoardReader { } Yaml yaml = new Yaml(); - Map data = yaml.load(new FileReader(firmwarePath + "/config/boards/" + boardName + "/mapping.yaml")); - Objects.requireNonNull(data, "mapping for " + boardName); - SystemOut.println(data); + String fileName = firmwarePath + "/config/boards/" + boardName + "/mapping.yaml"; + Map data = yaml.load(new FileReader(fileName)); + if (data == null) { + SystemOut.println("Null yaml for " + fileName); + } else { + SystemOut.println(data); + BufferedWriter bw = new BufferedWriter(new FileWriter(outputPath + File.separator + boardName + "_prefix.txt")); - BufferedWriter bw = new BufferedWriter(new FileWriter(outputPath + File.separator + boardName + "_prefix.txt")); + bw.write(processSection(data, "brain_pin_e", "output_pin_e", "outputs", "GPIO_UNASSIGNED")); + bw.write(processSection(data, "adc_channel_e", "adc_channel_e", "analog_inputs", "EFI_ADC_NONE")); - bw.write(processSection(data, "brain_pin_e", "output_pin_e", "outputs", "GPIO_UNASSIGNED")); - bw.write(processSection(data, "adc_channel_e", "adc_channel_e", "analog_inputs", "EFI_ADC_NONE")); + bw.write(processSection(data, "brain_pin_e", "brain_input_pin_e", "event_inputs", "GPIO_UNASSIGNED")); + bw.write(processSection(data, "brain_pin_e", "switch_input_pin_e", "switch_inputs", "GPIO_UNASSIGNED")); - bw.write(processSection(data, "brain_pin_e", "brain_input_pin_e", "event_inputs", "GPIO_UNASSIGNED")); - bw.write(processSection(data, "brain_pin_e", "switch_input_pin_e", "switch_inputs", "GPIO_UNASSIGNED")); - - bw.close(); + bw.close(); + } + SystemOut.close(); } private static String processSection(Map data, String headerEnumName, String outputEnumName, String sectionName, String NOTHING_NAME) {