can-log-tools/reader/src/test/java/com/rusefi/can/deprecated/CANoeCanValidator.java

50 lines
1.8 KiB
Java
Raw Normal View History

2022-11-12 19:13:12 -08:00
package com.rusefi.can.deprecated;
2022-02-14 21:45:27 -08:00
2022-11-12 19:13:12 -08:00
import com.rusefi.can.CANPacket;
import com.rusefi.can.deprecated.decoders.bmw.Bmw0BA;
import com.rusefi.can.deprecated.decoders.bmw.Bmw192;
2022-02-15 13:17:28 -08:00
import com.rusefi.can.reader.CANLineReader;
import com.rusefi.can.reader.impl.CANoeReader;
2022-02-14 21:45:27 -08:00
2022-02-20 19:26:49 -08:00
import java.io.FileWriter;
2022-02-14 21:45:27 -08:00
import java.io.IOException;
import java.util.List;
2022-02-20 19:26:49 -08:00
import java.util.TreeMap;
2022-02-14 21:45:27 -08:00
2022-11-12 19:13:12 -08:00
/**
* this code looks to validate BMW logs against hard-coded BMW packet logic? dead stuff since we've moved to DBC approach?
*/
2022-02-15 13:17:28 -08:00
public class CANoeCanValidator {
2022-02-14 21:45:27 -08:00
public static void main(String[] args) throws IOException {
2022-02-15 13:17:28 -08:00
CANLineReader reader = CANoeReader.INSTANCE;
validate("C:\\stuff\\rusefi_documentation\\OEM-Docs\\Bmw\\2003_7_Series_e65\\HeinrichG-V12-E65_ReverseEngineering\\Log1.log", reader);
validate("C:\\stuff\\rusefi_documentation\\OEM-Docs\\Bmw\\2003_7_Series_e65\\HeinrichG-V12-E65_ReverseEngineering\\Log2.log", reader);
2022-02-14 21:45:27 -08:00
}
2022-11-12 19:13:12 -08:00
public static void validate(String inputFileName, CANLineReader reader) throws IOException {
List<CANPacket> packetList = reader.readFile(inputFileName);
2022-02-14 21:45:27 -08:00
2022-02-20 19:26:49 -08:00
TreeMap<Integer, Object> allIds = new TreeMap<>();
2022-02-14 21:45:27 -08:00
for (CANPacket packet : packetList) {
2022-02-20 19:26:49 -08:00
allIds.put(packet.getId(), packet.getId());
2022-02-14 21:45:27 -08:00
if (packet.getId() == Bmw192.ID)
2022-02-15 15:28:45 -08:00
Bmw192.INSTANCE.decode(packet);
if (packet.getId() == Bmw0BA.ID)
Bmw0BA.INSTANCE.decode(packet);
2022-02-14 21:45:27 -08:00
}
2022-02-20 19:26:49 -08:00
2022-11-12 19:13:12 -08:00
String outputFileName = "all_ids.txt";
2023-07-30 21:01:10 -07:00
System.out.println("CANoeCanValidator: Writing to " + outputFileName);
2022-11-12 19:13:12 -08:00
try (FileWriter fw = new FileWriter(outputFileName)) {
2022-02-20 19:26:49 -08:00
for (Integer id : allIds.keySet()) {
fw.write(Integer.toHexString(id) + "\r\n");
}
}
2022-02-14 21:45:27 -08:00
}
}