From 1a797bfd99b1a77906040b64976b17ec3f12dd96 Mon Sep 17 00:00:00 2001 From: Alexey Esaulenko Date: Tue, 25 Mar 2025 11:48:32 +0400 Subject: [PATCH] Fix parsing complicated DBCs --- .../main/java/com/rusefi/can/reader/dbc/DbcFile.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/reader/src/main/java/com/rusefi/can/reader/dbc/DbcFile.java b/reader/src/main/java/com/rusefi/can/reader/dbc/DbcFile.java index 9c59162..53acf7d 100644 --- a/reader/src/main/java/com/rusefi/can/reader/dbc/DbcFile.java +++ b/reader/src/main/java/com/rusefi/can/reader/dbc/DbcFile.java @@ -41,7 +41,7 @@ public class DbcFile { while ((line = reader.readLine()) != null) { lineIndex++; line = line.trim(); - if (line.startsWith("BO_")) { + if (line.startsWith("BO_ ")) { purgePacket(currentPacket); line = line.replaceAll(":", ""); String[] tokens = line.split(" "); @@ -56,7 +56,7 @@ public class DbcFile { } String packetName = tokens[2]; currentPacket = new DbcPacket((int) decId, packetName); - } else if (line.startsWith("CM_")) { + } else if (line.startsWith("CM_ ")) { purgePacket(currentPacket); line = replaceSpecialWithSpaces(line); String[] tokens = line.split(" "); @@ -64,6 +64,10 @@ public class DbcFile { // skipping header line continue; } + if (!tokens[1].equals("SG_")) { + // will parse only signal descriptions + continue; + } if (tokens.length < 4) throw new IllegalStateException("Failing to parse comment: " + line + " at " + lineIndex); int id = Integer.parseInt(tokens[2]); @@ -74,7 +78,7 @@ public class DbcFile { packet.replaceName(originalName, niceName); - } else if (line.startsWith("SG_")) { + } else if (line.startsWith("SG_ ")) { DbcField field; try { field = DbcField.parseField(currentPacket, line);