Skip to content

Commit

Permalink
applyOrderForStartOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Nov 6, 2024
1 parent d7cfa66 commit c9580ea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class DbcField {

public DbcField(String name, int startOffset, int length, double mult, double offset, String category, boolean isBigEndian) {
this.name = name;
this.startOffset = startOffset;
this.startOffset = isBigEndian && DbcFile.applyOrderForStartOffset ? startOffset - length + 1 : startOffset;
this.length = length;
this.mult = mult;
this.offset = offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class DbcFile {
public final LinkedHashMap<Integer, DbcPacket> packets = new LinkedHashMap<>();

public static final boolean debugEnabled = false;
public static boolean applyOrderForStartOffset;

private List<BinaryLogEntry> list;

Expand Down
20 changes: 20 additions & 0 deletions reader/src/test/java/com/rusefi/can/reader/impl/ParseDBCTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,24 @@ public void parse() throws IOException {
assertEquals(0.25, rpm.getMult());
assertEquals("Motor_1", rpm.getCategory());
}

@Test
public void parseMoto() throws IOException {
String moto = "BO_ 100 P: 8 ECM_HS\n" +
" SG_ OAT : 63|8@0+ (1,0) [0|8] \"deg C\" VICS";

BufferedReader reader = new BufferedReader(new StringReader(moto));


DbcFile dbc = new DbcFile(false);
DbcFile.applyOrderForStartOffset = true;
dbc.read(reader);

assertEquals(dbc.packets.size(), 1);
DbcPacket packet = dbc.packets.get(100);
assertNotNull(packet);

DbcField f = packet.getFields().get(0);
assertEquals(56, f.getStartOffset());
}
}

0 comments on commit c9580ea

Please sign in to comment.