One SID per file
This commit is contained in:
parent
e822e36c23
commit
da6ef4d19d
|
@ -53,7 +53,11 @@ public class ByteRateOfChange {
|
|||
}
|
||||
|
||||
public static String dualSid(int sid) {
|
||||
return String.format("%d/0x%x", sid, sid);
|
||||
return dualSid(sid, "/");
|
||||
}
|
||||
|
||||
public static String dualSid(int sid, String separator) {
|
||||
return String.format("%d%s0x%x", sid, separator, sid);
|
||||
}
|
||||
|
||||
public static class ByteStatistics {
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
package com.rusefi.can.analysis;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.writer.SteveWriter;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static com.rusefi.can.analysis.ByteRateOfChange.dualSid;
|
||||
|
||||
public class PerSidDump {
|
||||
public static void handle(List<CANPacket> packets, String simpleFileName) {
|
||||
public static void handle(List<CANPacket> packets, String simpleFileName) throws IOException {
|
||||
TreeSet<Integer> sids = new TreeSet<>();
|
||||
// todo: one day I will let streams into my heart
|
||||
for (CANPacket packet : packets)
|
||||
|
@ -14,10 +21,19 @@ public class PerSidDump {
|
|||
|
||||
// O(n*M) is not so bad
|
||||
for (int sid : sids) {
|
||||
|
||||
PrintWriter pw = new PrintWriter(new FileOutputStream(simpleFileName + "_filtered_" + dualSid(sid, "_") + ".txt"));
|
||||
|
||||
for (CANPacket packet : packets) {
|
||||
if (packet.getId() != sid)
|
||||
continue;
|
||||
|
||||
// no reason to use SteveWriter just need any human-readable writer here
|
||||
SteveWriter.append(pw, packet);
|
||||
|
||||
|
||||
}
|
||||
pw.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,9 @@ import java.io.FileWriter;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This seems to be about https://github.com/brent-stone/CAN_Reverse_Engineering
|
||||
*/
|
||||
public class SteveWriter implements CANTextWriter {
|
||||
private final String fileName;
|
||||
|
||||
|
|
Loading…
Reference in New Issue