Merge pull request #2 from esaulenka/fix_DCB_parser
Fix parsing complicated DBCs
This commit is contained in:
commit
853addb1eb
|
@ -41,7 +41,7 @@ public class DbcFile {
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
lineIndex++;
|
lineIndex++;
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
if (line.startsWith("BO_")) {
|
if (line.startsWith("BO_ ")) {
|
||||||
purgePacket(currentPacket);
|
purgePacket(currentPacket);
|
||||||
line = line.replaceAll(":", "");
|
line = line.replaceAll(":", "");
|
||||||
String[] tokens = line.split(" ");
|
String[] tokens = line.split(" ");
|
||||||
|
@ -56,7 +56,7 @@ public class DbcFile {
|
||||||
}
|
}
|
||||||
String packetName = tokens[2];
|
String packetName = tokens[2];
|
||||||
currentPacket = new DbcPacket((int) decId, packetName);
|
currentPacket = new DbcPacket((int) decId, packetName);
|
||||||
} else if (line.startsWith("CM_")) {
|
} else if (line.startsWith("CM_ ")) {
|
||||||
purgePacket(currentPacket);
|
purgePacket(currentPacket);
|
||||||
line = replaceSpecialWithSpaces(line);
|
line = replaceSpecialWithSpaces(line);
|
||||||
String[] tokens = line.split(" ");
|
String[] tokens = line.split(" ");
|
||||||
|
@ -64,6 +64,10 @@ public class DbcFile {
|
||||||
// skipping header line
|
// skipping header line
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!tokens[1].equals("SG_")) {
|
||||||
|
// will parse only signal descriptions
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (tokens.length < 4)
|
if (tokens.length < 4)
|
||||||
throw new IllegalStateException("Failing to parse comment: " + line + " at " + lineIndex);
|
throw new IllegalStateException("Failing to parse comment: " + line + " at " + lineIndex);
|
||||||
int id = Integer.parseInt(tokens[2]);
|
int id = Integer.parseInt(tokens[2]);
|
||||||
|
@ -74,7 +78,7 @@ public class DbcFile {
|
||||||
packet.replaceName(originalName, niceName);
|
packet.replaceName(originalName, niceName);
|
||||||
|
|
||||||
|
|
||||||
} else if (line.startsWith("SG_")) {
|
} else if (line.startsWith("SG_ ")) {
|
||||||
DbcField field;
|
DbcField field;
|
||||||
try {
|
try {
|
||||||
field = DbcField.parseField(currentPacket, line);
|
field = DbcField.parseField(currentPacket, line);
|
||||||
|
|
Loading…
Reference in New Issue