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 7ff2475..36da5e2 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 @@ -35,6 +35,7 @@ public class DbcFile { DbcPacket currentPacket = null; String line; int lineIndex = -1; + Set fieldNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); while ((line = reader.readLine()) != null) { lineIndex++; line = line.trim(); @@ -72,11 +73,19 @@ public class DbcFile { } else if (line.startsWith("SG_")) { - DbcField field = DbcField.parseField(currentPacket, line); + DbcField field; + try { + field = DbcField.parseField(currentPacket, line); + } catch (Throwable e) { + throw new IllegalStateException("During [" + line + "]", e); + } if (debugEnabled) System.out.println("Found " + field); - if (field != null) + if (field != null) { + if (!fieldNames.add(field.getName())) + throw new IllegalArgumentException("Let's use unique field names: " + field.getName()); currentPacket.add(field); + } } else { // skipping useless line