Compare commits
6 Commits
6697d24878
...
b9aa256c38
Author | SHA1 | Date |
---|---|---|
rusefillc | b9aa256c38 | |
rusefillc | 833c3056b9 | |
rusefillc | fe48468748 | |
rusefillc | 475448f771 | |
rusefillc | 40fa6e8574 | |
rusefillc | 9364e0ee0a |
11
README.md
11
README.md
|
@ -1,3 +1,5 @@
|
|||
# CAN decoding
|
||||
|
||||
CAN log file utilities to help me work with https://github.com/brent-stone/CAN_Reverse_Engineering and https://github.com/HeinrichG-V12/E65_ReverseEngineering
|
||||
|
||||
|
||||
|
@ -10,4 +12,11 @@ CAN log file utilities to help me work with https://github.com/brent-stone/CAN_R
|
|||
* ignition on, engine not running, brake pedal three times
|
||||
* ignition on, engine not running, throttle pedal from 0% to 50%, to 0%, to 100%, to 0%
|
||||
* engine running, rev from 1500 rpm to 3000 rpm
|
||||
*
|
||||
|
||||
|
||||
# CAN playback
|
||||
|
||||
``
|
||||
gradlew :playback:shadowJar
|
||||
java -jar playback/build/libs/playback-all.jar playback/src/main/resources/atlas.trc
|
||||
``
|
||||
|
|
|
@ -13,11 +13,6 @@ allprojects {
|
|||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation libs.snakeyaml
|
||||
testImplementation libs.junit
|
||||
}
|
||||
|
||||
defaultTasks 'jar'
|
||||
|
||||
jar {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 5bfc8e4c4c00f51996a0d1a501cbfc6e27c04ca7
|
||||
Subproject commit 8370f2a253a3f71a197bc20d102e76750fd08083
|
|
@ -1 +1,4 @@
|
|||
javaCanVersion=3.2.4
|
||||
javaCanVersion=3.2.4
|
||||
|
||||
shadowVersion=8.1.1
|
||||
org.gradle.warning.mode=all
|
||||
|
|
|
@ -1,14 +1,21 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'java-library'
|
||||
id 'com.github.johnrengelman.shadow' version "${shadowVersion}"
|
||||
}
|
||||
|
||||
apply from: '../dependencies.gradle'
|
||||
|
||||
dependencies {
|
||||
api rootProject
|
||||
api project(':reader')
|
||||
api project(':peak-can-basic')
|
||||
api libs.annotations
|
||||
api group: 'tel.schich', name: 'javacan-core', version: "$javaCanVersion"
|
||||
api group: 'tel.schich', name: 'javacan-core', version: "$javaCanVersion", classifier: 'x86_64'
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
manifest {
|
||||
attributes(
|
||||
'Main-Class': 'com.rusefi.io.can.SenderSandbox'
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.rusefi.io.can;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.CanPacketSender;
|
||||
import com.rusefi.can.reader.CANLineReader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import peak.can.basic.HackLoadLibraryFlag;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class SenderSandbox {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String fileName = args.length > 0 ? args[0] : getFullResourceFileName("resources/atlas.trc");
|
||||
|
||||
List<CANPacket> packets = CANLineReader.getReader().readFile(fileName);
|
||||
System.out.println("Got " + packets.size() + " packet(s)");
|
||||
|
||||
if (isWindows()) {
|
||||
HackLoadLibraryFlag.LOAD_LIBRARY = false;
|
||||
//System.load(getFullResourceFileName("PCANBasic_JNI.dll"));
|
||||
System.load(new File("ext/peak-can-basic/src/main/resources/PCANBasic_JNI.dll").getAbsolutePath());
|
||||
}
|
||||
|
||||
CanSender sender = isWindows() ? PCanHelper.create() : SocketCANHelper.create();
|
||||
|
||||
while (true) {
|
||||
CanPacketSender.sendMessagesOut(packets, sender);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getFullResourceFileName(String resourceName) throws URISyntaxException {
|
||||
URL resource = SenderSandbox.class.getResource("/" + resourceName);
|
||||
System.out.println(Objects.requireNonNull(resource, "URL for " + resourceName));
|
||||
String fullResourceFileName = Paths.get(resource.toURI()).toString();
|
||||
return fullResourceFileName;
|
||||
}
|
||||
|
||||
private static String getOsName() {
|
||||
return System.getProperty("os.name");
|
||||
}
|
||||
|
||||
private static boolean isWindows() {
|
||||
return getOsName().contains("Windows");
|
||||
}
|
||||
}
|
|
@ -28,13 +28,9 @@ public class SocketCANHelper {
|
|||
return socket;
|
||||
}
|
||||
|
||||
public static void send(int id, byte[] payload, RawCanChannel channel) {
|
||||
public static void send(int id, byte[] payload, RawCanChannel channel) throws IOException {
|
||||
CanFrame packet = CanFrame.create(id, FD_NO_FLAGS, payload);
|
||||
try {
|
||||
channel.write(packet);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
channel.write(packet);
|
||||
}
|
||||
|
||||
public static CanSender create() {
|
||||
|
@ -42,8 +38,12 @@ public class SocketCANHelper {
|
|||
return new CanSender() {
|
||||
@Override
|
||||
public boolean send(int id, byte[] payload) {
|
||||
SocketCANHelper.send(id, payload, canChannel);
|
||||
return true;
|
||||
try {
|
||||
SocketCANHelper.send(id, payload, canChannel);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,9 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'com.github.johnrengelman.shadow' version "${shadowVersion}"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation libs.snakeyaml
|
||||
testImplementation libs.junit
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package com.rusefi.can;
|
||||
|
||||
import com.rusefi.can.reader.impl.CANoeReader;
|
||||
import com.rusefi.can.deprecated.decoders.PacketDecoder;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.decoders.bmw.BmwRegistry;
|
||||
import com.rusefi.can.reader.impl.CANoeReader;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
|
@ -2,8 +2,6 @@ package com.rusefi.can;
|
|||
|
||||
import com.rusefi.util.BitMathUtil;
|
||||
|
||||
import static com.rusefi.can.Utils.bytesToHexWithSpaces;
|
||||
|
||||
public class CANPacket {
|
||||
private final double timeStamp;
|
||||
private final int id;
|
||||
|
@ -68,7 +66,7 @@ public class CANPacket {
|
|||
|
||||
public void assertThat(String msg, PackerAssertion assertion) {
|
||||
if (!assertion.test(this))
|
||||
throw new IllegalStateException("Not " + msg + " " + bytesToHexWithSpaces(data));
|
||||
throw new IllegalStateException("Not " + msg + " " + Utils.bytesToHexWithSpaces(data));
|
||||
}
|
||||
|
||||
public int getUnsignedInt(int index) {
|
|
@ -1,7 +1,7 @@
|
|||
package com.rusefi.can;
|
||||
|
||||
import com.rusefi.can.reader.CANLineReader;
|
||||
import com.rusefi.can.reader.dbc.DbcFile;
|
||||
import com.rusefi.can.reader.CANLineReader;
|
||||
import com.rusefi.mlv.LoggingStrategy;
|
||||
import com.rusefi.util.FolderUtil;
|
||||
|
|
@ -29,7 +29,7 @@ public class PerSidDump {
|
|||
// O(n*M) is not so bad
|
||||
for (int sid : sids) {
|
||||
|
||||
String outputFileName = filteredDestinationFolder + File.separator + simpleFileName + "_filtered_" + dualSid(sid, "_") + ".txt";
|
||||
String outputFileName = filteredDestinationFolder + File.separator + simpleFileName + "_filtered_" + ByteRateOfChange.dualSid(sid, "_") + ".txt";
|
||||
PrintWriter pw = new PrintWriter(new FileOutputStream(outputFileName));
|
||||
|
||||
List<CANPacket> filteredPackets = new ArrayList<>();
|
||||
|
@ -47,7 +47,7 @@ public class PerSidDump {
|
|||
int middleIndex = filteredPackets.size() / 2;
|
||||
CANPacket middlePacket = filteredPackets.get(middleIndex);
|
||||
|
||||
String middleOutputFileName = filteredDestinationFolder + File.separator + simpleFileName + "_filtered_" + dualSid(sid, "_") + "_middle.txt";
|
||||
String middleOutputFileName = filteredDestinationFolder + File.separator + simpleFileName + "_filtered_" + ByteRateOfChange.dualSid(sid, "_") + "_middle.txt";
|
||||
PrintWriter middle = new PrintWriter(new FileOutputStream(middleOutputFileName));
|
||||
|
||||
String decAndHex = middlePacket.getId() + "_" + Integer.toHexString(middlePacket.getId());
|
|
@ -1,8 +1,7 @@
|
|||
package com.rusefi.can.deprecated.decoders;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
|
||||
import static com.rusefi.can.Utils.bytesToHexWithSpaces;
|
||||
import com.rusefi.can.Utils;
|
||||
|
||||
public abstract class AbstractPacketDecoder implements PacketDecoder {
|
||||
private final int id;
|
||||
|
@ -21,6 +20,6 @@ public abstract class AbstractPacketDecoder implements PacketDecoder {
|
|||
}
|
||||
|
||||
protected IllegalStateException unexpected(String reason, CANPacket packet) {
|
||||
return new IllegalStateException(reason + ": " + bytesToHexWithSpaces(packet.getData()));
|
||||
return new IllegalStateException(reason + ": " + Utils.bytesToHexWithSpaces(packet.getData()));
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
public class Bmw0A9 extends AbstractPacketDecoder {
|
|
@ -1,9 +1,9 @@
|
|||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
public class Bmw0AA extends AbstractPacketDecoder {
|
|
@ -1,9 +1,9 @@
|
|||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
public class Bmw0B5 extends AbstractPacketDecoder {
|
|
@ -1,9 +1,9 @@
|
|||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
public class Bmw0BA extends AbstractPacketDecoder {
|
|
@ -1,9 +1,9 @@
|
|||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
/**
|
|
@ -1,9 +1,9 @@
|
|||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
public class Bmw1D0 extends AbstractPacketDecoder {
|
|
@ -1,9 +1,9 @@
|
|||
package com.rusefi.can.reader;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.reader.impl.AutoFormatReader;
|
||||
import com.rusefi.can.reader.impl.CANoeReader;
|
||||
import com.rusefi.can.reader.impl.CanHackerReader;
|
||||
import com.rusefi.can.reader.impl.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
|
@ -3,8 +3,6 @@ package com.rusefi.can.reader.impl;
|
|||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.reader.CANLineReader;
|
||||
|
||||
import static com.rusefi.can.reader.impl.PcanTrcReader2_0.FILEVERSION;
|
||||
|
||||
/**
|
||||
* @see PcanTrcReader2_0 for version 2.0 format
|
||||
* TODO: merge these two?
|
||||
|
@ -15,7 +13,7 @@ public class PcanTrcReader1_1 implements CANLineReader {
|
|||
@Override
|
||||
public CANPacket readLine(String line, String fileName, int lineIndex) {
|
||||
line = line.trim();
|
||||
if (line.startsWith(FILEVERSION) && !line.startsWith(FILEVERSION + "=1.1"))
|
||||
if (line.startsWith(PcanTrcReader2_0.FILEVERSION) && !line.startsWith(PcanTrcReader2_0.FILEVERSION + "=1.1"))
|
||||
throw new IllegalStateException("Unexpected fileversion " + line);
|
||||
if (line.startsWith(";"))
|
||||
return null;
|
|
@ -4,8 +4,6 @@ import java.io.*;
|
|||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static com.rusefi.sensor_logs.Fields.MLQ_FIELD_HEADER_NAME_OR_CATEGORY;
|
||||
|
||||
/**
|
||||
* MLV .mlq binary log file
|
||||
* https://www.efianalytics.com/TunerStudio/docs/MLG_Binary_LogFormat_1.0.pdf
|
||||
|
@ -123,7 +121,7 @@ public class BinarySensorLog<T extends BinaryLogEntry> implements SensorLog, Aut
|
|||
// 0000h type enum
|
||||
stream.write(7);
|
||||
// 0001h
|
||||
writeLine(stream, name, MLQ_FIELD_HEADER_NAME_OR_CATEGORY);
|
||||
writeLine(stream, name, Fields.MLQ_FIELD_HEADER_NAME_OR_CATEGORY);
|
||||
// 0023h
|
||||
writeLine(stream, unit, 10);
|
||||
stream.write(0); // Display Style, 0=Float
|
||||
|
@ -133,7 +131,7 @@ public class BinarySensorLog<T extends BinaryLogEntry> implements SensorLog, Aut
|
|||
stream.writeFloat(0);
|
||||
// 0036h precision digits
|
||||
stream.write(2);
|
||||
writeLine(stream, sensor.getCategory(), MLQ_FIELD_HEADER_NAME_OR_CATEGORY);
|
||||
writeLine(stream, sensor.getCategory(), Fields.MLQ_FIELD_HEADER_NAME_OR_CATEGORY);
|
||||
}
|
||||
if (stream.size() != infoDataStart)
|
||||
throw new IllegalStateException("We are doing something wrong :( stream.size=" + stream.size() + "/" + infoDataStart);
|
|
@ -1,5 +1,7 @@
|
|||
rootProject.name = 'can-log-tools'
|
||||
|
||||
include ':reader'
|
||||
project(':reader').projectDir = new File('reader')
|
||||
include ':playback'
|
||||
project(':playback').projectDir = new File('playback')
|
||||
include ':peak-can-basic'
|
||||
|
|
Loading…
Reference in New Issue