Compare commits

...

2 Commits

Author SHA1 Message Date
rusefillc ba11705db0 filtered uses DBC 2024-03-22 12:01:05 -04:00
rusefillc e795581f6a ByteRateOfChangeReports shows relevant byte 2024-03-22 11:45:19 -04:00
4 changed files with 28 additions and 15 deletions

View File

@ -3,6 +3,7 @@ package com.rusefi.can.analysis;
import com.rusefi.can.CANPacket;
import com.rusefi.can.Launcher;
import com.rusefi.can.reader.CANLineReader;
import com.rusefi.can.reader.dbc.DbcField;
import com.rusefi.can.reader.dbc.DbcFile;
import com.rusefi.can.reader.dbc.DbcPacket;
import com.rusefi.util.FolderUtil;
@ -14,13 +15,7 @@ public class ByteRateOfChangeReports {
/**
* sweet baby O(n^2)
*/
public static void compareEachReportAgainstAllOthers(String reportDestinationFolder, List<ByteRateOfChange.TraceReport> reports, CanMetaDataContext context) throws IOException {
DbcFile dbc = null;
if (Launcher.dbcFileName != null) {
dbc = DbcFile.readFromFile(Launcher.dbcFileName);
}
public static void compareEachReportAgainstAllOthers(DbcFile dbc, String reportDestinationFolder, List<ByteRateOfChange.TraceReport> reports, CanMetaDataContext context) throws IOException {
for (int i = 0; i < reports.size(); i++) {
for (int j = i + 1; j < reports.size(); j++)
compareTwoReports(dbc, reportDestinationFolder, reports.get(i), reports.get(j), context);
@ -55,6 +50,9 @@ public class ByteRateOfChangeReports {
DbcPacket packet = dbc.packets.get(id.sid);
if (packet != null) {
prefix = packet.getName() + " ";
DbcField field = packet.getFieldAtByte(id.byteIndex);
if (field != null)
prefix += field.getName() + " ";
}
}
@ -109,6 +107,8 @@ public class ByteRateOfChangeReports {
public static void scanInputFolder(String inputFolderName, String fileNameSuffix) throws IOException {
String reportDestinationFolder = createOutputFolder(inputFolderName);
DbcFile dbc = getDbc();
CanMetaDataContext context = CanMetaDataContext.read(inputFolderName);
List<ByteRateOfChange.TraceReport> reports = new ArrayList<>();
@ -119,7 +119,7 @@ public class ByteRateOfChangeReports {
List<CANPacket> logFileContent = CANLineReader.getReader().readFile(fullInputFileName);
PerSidDump.handle(reportDestinationFolder, simpleFileName, logFileContent);
PerSidDump.handle(dbc, reportDestinationFolder, simpleFileName, logFileContent);
// at the moment we overwrite counter detection report after we process each file
CounterScanner.scanForCounters(reportDestinationFolder, simpleFileName, logFileContent);
ChecksumScanner.scanForChecksums(reportDestinationFolder, simpleFileName, logFileContent);
@ -136,7 +136,15 @@ public class ByteRateOfChangeReports {
System.out.println("Processing " + reports.size() + " report(s)");
compareEachReportAgainstAllOthers(reportDestinationFolder, reports, context);
compareEachReportAgainstAllOthers(dbc, reportDestinationFolder, reports, context);
}
private static DbcFile getDbc() throws IOException {
DbcFile dbc = null;
if (Launcher.dbcFileName != null) {
dbc = DbcFile.readFromFile(Launcher.dbcFileName);
}
return dbc;
}
static class ByteVariationDifference {

View File

@ -2,6 +2,8 @@ package com.rusefi.can.analysis;
import com.rusefi.can.CANPacket;
import com.rusefi.can.DualSid;
import com.rusefi.can.reader.dbc.DbcFile;
import com.rusefi.can.reader.dbc.DbcPacket;
import com.rusefi.can.writer.SteveWriter;
import java.io.File;
@ -16,7 +18,7 @@ import java.util.TreeSet;
* Write a separate file for each unique packet ID
*/
public class PerSidDump {
public static void handle(String reportDestinationFolder, String simpleFileName, List<CANPacket> packets) throws IOException {
public static void handle(DbcFile dbc, String reportDestinationFolder, String simpleFileName, List<CANPacket> packets) throws IOException {
String filteredDestinationFolder = reportDestinationFolder + File.separator + "filtered";
new File(filteredDestinationFolder).mkdirs();
@ -50,8 +52,10 @@ public class PerSidDump {
PrintWriter middle = new PrintWriter(new FileOutputStream(middleOutputFileName));
String decAndHex = middlePacket.getId() + "_" + Integer.toHexString(middlePacket.getId());
String payloadVariableName = "payload" + decAndHex;
String variableName = "CAN_" + decAndHex;
DbcPacket packet = dbc.packets.get(middlePacket.getId());
String payloadVariableName = "payload" + (packet == null ? decAndHex : packet.getName());
String variableName = packet == null ? "CAN_" + decAndHex : packet.getName();
String methodName = "on" + (packet == null ? ("Can" + decAndHex) : packet.getName());
StringBuilder payloadLine = middlePacket.asLua(payloadVariableName);
@ -62,7 +66,6 @@ public class PerSidDump {
middle.println();
middle.println(counterVariable + " = 0");
String methodName = "onMotor" + decAndHex;
middle.println("function " + methodName + "(bus, id, dlc, data)");
middle.println("\t" + counterVariable + " = (" + counterVariable + " + 1) % 256");
middle.println("\t" + payloadVariableName + "[x] = " + counterVariable);

View File

@ -126,9 +126,9 @@ public class DbcField {
public boolean coversByte(int byteIndex) {
int startBit = byteIndex * 8;
if (startOffset>startBit)
if (startOffset > startBit)
return false;
if (startOffset + length < byteIndex + 8)
if (startOffset + length < startBit + 8)
return false;
return true;
}

View File

@ -58,6 +58,8 @@ public class GetValueFromTrcTest {
DbcField byte1 = packet640.getFieldAtByte(1);
assertNotNull(byte1);
assertEquals("inneres_Motor_Moment", byte1.getName());
DbcField byte4 = packet640.getFieldAtByte(4);
assertNotNull(byte4);
assertNull(dbc.findPacket(1640));
String trcLine = " 3769) 2117.7 Rx 0280 8 01 1D DF 12 1E 00 1A 1E ";