Skip to content

Commit

Permalink
Let's use unique field names
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed May 27, 2024
1 parent 2698a8f commit bd90ce8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions reader/src/main/java/com/rusefi/can/reader/dbc/DbcFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void read(BufferedReader reader) throws IOException {
DbcPacket currentPacket = null;
String line;
int lineIndex = -1;
Set<String> fieldNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
while ((line = reader.readLine()) != null) {
lineIndex++;
line = line.trim();
Expand Down Expand Up @@ -72,11 +73,19 @@ public void read(BufferedReader reader) throws IOException {


} 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
Expand Down

0 comments on commit bd90ce8

Please sign in to comment.