From f65cc7d6e7c5c4adc689a329847a4a29be337275 Mon Sep 17 00:00:00 2001 From: rusEFI LLC Date: Sat, 7 Sep 2024 19:41:56 -0400 Subject: [PATCH] Console should get much smarter around compatibility with older units #6845 --- .../tools/tune/WriteSimulatorConfiguration.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/WriteSimulatorConfiguration.java b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/WriteSimulatorConfiguration.java index ad58232580..84b6387805 100644 --- a/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/WriteSimulatorConfiguration.java +++ b/java_tools/tune-tools/src/main/java/com/rusefi/tools/tune/WriteSimulatorConfiguration.java @@ -82,17 +82,18 @@ public class WriteSimulatorConfiguration { } private static void readBinaryWriteXmlTune(String iniFileName, String inputBinaryTuneFileName, String outputXmlFileName) throws JAXBException, IOException { - byte[] fileContent = Files.readAllBytes(new File(ROOT_FOLDER + inputBinaryTuneFileName).toPath()); - System.out.println("Got " + fileContent.length + " from " + inputBinaryTuneFileName + " while expecting " + Fields.TOTAL_CONFIG_SIZE); - if (fileContent.length != Fields.TOTAL_CONFIG_SIZE) - throw new IllegalStateException("Unexpected image size " + fileContent.length + " while expecting " + Fields.TOTAL_CONFIG_SIZE); - ConfigurationImage configuration = new ConfigurationImage(fileContent); - System.out.println("Got " + Objects.requireNonNull(configuration, "configuration")); // we have to use board-specific .ini to account for all the board-specific offsets // INI_FILE_FOR_SIMULATOR is just not universal enough IniFileModel ini = new IniFileModel().readIniFile(iniFileName); if (ini == null) throw new IllegalStateException("Not found " + iniFileName); + byte[] fileContent = Files.readAllBytes(new File(ROOT_FOLDER + inputBinaryTuneFileName).toPath()); + int pageSize = ini.getMetaInfo().getTotalSize(); + log.info("Got " + fileContent.length + " from " + inputBinaryTuneFileName + " while expecting " + pageSize); + if (fileContent.length != pageSize) + throw new IllegalStateException("Unexpected image size " + fileContent.length + " while expecting " + pageSize); + ConfigurationImage configuration = new ConfigurationImage(fileContent); + log.info("Got " + Objects.requireNonNull(configuration, "configuration")); Msq m = MsqFactory.valueOf(configuration, ini); String name = Fields.KNOCKNOISERPMBINS.getName(); Constant noiseRpmBins = m.page.get(1).getConstantsAsMap().get(name); @@ -101,6 +102,6 @@ public class WriteSimulatorConfiguration { m.writeXmlFile(ROOT_FOLDER + outputXmlFileName); Msq newTuneJustToValidate = Msq.readTune(ROOT_FOLDER + outputXmlFileName); - System.out.println("Looks valid " + newTuneJustToValidate); + log.info("Looks valid " + newTuneJustToValidate); } }