new API & coverage
This commit is contained in:
parent
5f8e344c15
commit
6a04166862
|
@ -123,4 +123,13 @@ public class DbcField {
|
|||
name = niceName;
|
||||
isNiceName = true;
|
||||
}
|
||||
|
||||
public boolean coversByte(int byteIndex) {
|
||||
int startBit = byteIndex * 8;
|
||||
if (startOffset>startBit)
|
||||
return false;
|
||||
if (startOffset + length < byteIndex + 8)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,4 +102,11 @@ public class DbcPacket {
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
public DbcField getFieldAtByte(int byteIndex) {
|
||||
for (DbcField field : fields) {
|
||||
if (field.coversByte(byteIndex))
|
||||
return field;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.can.reader.impl;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.reader.dbc.DbcPacket;
|
||||
import com.rusefi.mlv.LoggingStrategy;
|
||||
import com.rusefi.can.reader.dbc.DbcField;
|
||||
import com.rusefi.can.reader.dbc.DbcFile;
|
||||
|
@ -52,7 +53,11 @@ public class GetValueFromTrcTest {
|
|||
BufferedReader reader = new BufferedReader(new StringReader(VAG_MOTOR_1));
|
||||
dbc.read(reader);
|
||||
}
|
||||
assertNotNull(dbc.findPacket(640));
|
||||
DbcPacket packet640 = dbc.findPacket(640);
|
||||
assertNotNull(packet640);
|
||||
DbcField byte1 = packet640.getFieldAtByte(1);
|
||||
assertNotNull(byte1);
|
||||
assertEquals("inneres_Motor_Moment", byte1.getName());
|
||||
assertNull(dbc.findPacket(1640));
|
||||
|
||||
String trcLine = " 3769) 2117.7 Rx 0280 8 01 1D DF 12 1E 00 1A 1E ";
|
||||
|
|
Loading…
Reference in New Issue