diff --git a/src/main/java/com/rusefi/can/TrcToMlq.java b/src/main/java/com/rusefi/can/TrcToMlq.java index 894a060..d6dbdbf 100644 --- a/src/main/java/com/rusefi/can/TrcToMlq.java +++ b/src/main/java/com/rusefi/can/TrcToMlq.java @@ -10,7 +10,10 @@ import static com.rusefi.can.reader.CANLineReader.getReader; public class TrcToMlq { public static ReaderType getCurrentReaderType() { - return ReaderType.PCAN; + String property = System.getProperty("TRACE_READER", "PCAN"); + ReaderType readerType = ReaderType.valueOf(property); + System.out.println("getCurrentReaderType: " + readerType + " for [" + property + "]"); + return readerType; } public static void main(String[] args) throws IOException { diff --git a/src/main/java/com/rusefi/can/reader/dbc/DbcField.java b/src/main/java/com/rusefi/can/reader/dbc/DbcField.java index 9f004a6..81a888f 100644 --- a/src/main/java/com/rusefi/can/reader/dbc/DbcField.java +++ b/src/main/java/com/rusefi/can/reader/dbc/DbcField.java @@ -23,6 +23,8 @@ public class DbcField { public static DbcField parseField(DbcPacket parent, String line) { line = DbcFile.replaceSpecialWithSpaces(line); String[] tokens = line.split(" "); + if (tokens.length < 2) + return null; String name = tokens[1]; int index = 1; while (!tokens[index - 1].equals(":")) diff --git a/src/main/java/com/rusefi/can/reader/dbc/DbcFile.java b/src/main/java/com/rusefi/can/reader/dbc/DbcFile.java index 4623046..180a678 100644 --- a/src/main/java/com/rusefi/can/reader/dbc/DbcFile.java +++ b/src/main/java/com/rusefi/can/reader/dbc/DbcFile.java @@ -44,9 +44,17 @@ public class DbcFile { purgePacket(currentPacket); line = line.replaceAll(":", ""); String[] tokens = line.split(" "); - int decId = Integer.parseInt(tokens[1]); + if (tokens.length < 3) { + // skipping header line + continue; + } + long decId = Long.parseLong(tokens[1]); + if (decId > 2_000_000_000) { + System.err.println("Huh? Skipping ID=" + decId); + continue; + } String packetName = tokens[2]; - currentPacket = new DbcPacket(decId, packetName); + currentPacket = new DbcPacket((int) decId, packetName); } else if (line.startsWith("CM_")) { purgePacket(currentPacket); line = replaceSpecialWithSpaces(line); @@ -69,7 +77,8 @@ public class DbcFile { DbcField field = DbcField.parseField(currentPacket, line); if (debugEnabled) System.out.println("Found " + field); - currentPacket.add(field); + if (field != null) + currentPacket.add(field); } else { // skipping useless line diff --git a/src/main/java/com/rusefi/can/reader/impl/CANoeReader.java b/src/main/java/com/rusefi/can/reader/impl/CANoeReader.java index e6d241d..1cd21f8 100644 --- a/src/main/java/com/rusefi/can/reader/impl/CANoeReader.java +++ b/src/main/java/com/rusefi/can/reader/impl/CANoeReader.java @@ -4,12 +4,7 @@ import com.rusefi.can.CANPacket; import com.rusefi.can.reader.CANLineReader; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; import java.util.List; -import java.util.function.Consumer; -import java.util.stream.Stream; public enum CANoeReader implements CANLineReader { INSTANCE; diff --git a/src/main/java/com/rusefi/can/reader/impl/CanHackerReader.java b/src/main/java/com/rusefi/can/reader/impl/CanHackerReader.java index a43b4f5..581c81c 100644 --- a/src/main/java/com/rusefi/can/reader/impl/CanHackerReader.java +++ b/src/main/java/com/rusefi/can/reader/impl/CanHackerReader.java @@ -11,7 +11,6 @@ public enum CanHackerReader implements CANLineReader { line = line.trim(); if (line.startsWith("@")) return null; - System.out.println("readLine " + line); String[] tokens = line.split("\\s+"); double timeStamp = Double.parseDouble(CANLineReader.attemptToFixLocalization(tokens[0]));