already time for some clean-up
This commit is contained in:
parent
b4d1560abe
commit
c147907aa4
|
@ -1,7 +1,8 @@
|
|||
package com.rusefi.can;
|
||||
|
||||
import com.rusefi.can.decoders.PacketDecoder;
|
||||
import com.rusefi.can.decoders.bmw.BmwRegistry;
|
||||
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;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.rusefi.can;
|
||||
|
||||
import com.rusefi.can.decoders.AbstractPacketDecoder;
|
||||
import com.rusefi.util.BitMathUtil;
|
||||
|
||||
import static com.rusefi.can.Utils.bytesToHexWithSpaces;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class CANPacket {
|
|||
if (shift + bitIndex > 8) {
|
||||
value = value + getUnsigned(byteIndex + 1) * 256;
|
||||
}
|
||||
return value >> shift & AbstractPacketDecoder.mask(bitWidth);
|
||||
return value >> shift & BitMathUtil.mask(bitWidth);
|
||||
}
|
||||
|
||||
public double getTimeStamp() {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.rusefi.can;
|
||||
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
|
||||
public class SensorValue {
|
||||
private final SensorType type;
|
||||
private final double value;
|
||||
|
|
|
@ -3,7 +3,6 @@ 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;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
package com.rusefi.can;
|
||||
package com.rusefi.can.deprecated;
|
||||
|
||||
import com.rusefi.can.SensorValue;
|
||||
|
||||
public class PacketPayload {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.rusefi.can;
|
||||
package com.rusefi.can.deprecated;
|
||||
|
||||
public enum SensorType {
|
||||
RPM,
|
|
@ -1,9 +1,7 @@
|
|||
package com.rusefi.can.decoders;
|
||||
package com.rusefi.can.deprecated.decoders;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.rusefi.can.Utils.bytesToHexWithSpaces;
|
||||
|
||||
public abstract class AbstractPacketDecoder implements PacketDecoder {
|
||||
|
@ -13,10 +11,6 @@ public abstract class AbstractPacketDecoder implements PacketDecoder {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public static int mask(int bitWidth) {
|
||||
return (1 << bitWidth) - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
|
@ -1,7 +1,7 @@
|
|||
package com.rusefi.can.decoders;
|
||||
package com.rusefi.can.deprecated.decoders;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.PacketPayload;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
|
||||
public interface PacketDecoder {
|
||||
PacketPayload decode(CANPacket packet);
|
|
@ -1,10 +1,10 @@
|
|||
package com.rusefi.can.decoders.bmw;
|
||||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.PacketPayload;
|
||||
import com.rusefi.can.SensorType;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.decoders.AbstractPacketDecoder;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
public class Bmw0A9 extends AbstractPacketDecoder {
|
||||
public static final AbstractPacketDecoder INSTANCE = new Bmw0A9();
|
|
@ -1,10 +1,10 @@
|
|||
package com.rusefi.can.decoders.bmw;
|
||||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.PacketPayload;
|
||||
import com.rusefi.can.SensorType;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.decoders.AbstractPacketDecoder;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
public class Bmw0AA extends AbstractPacketDecoder {
|
||||
public static final int ID = 0xAA;
|
|
@ -1,10 +1,10 @@
|
|||
package com.rusefi.can.decoders.bmw;
|
||||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.PacketPayload;
|
||||
import com.rusefi.can.SensorType;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.decoders.AbstractPacketDecoder;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
public class Bmw0B5 extends AbstractPacketDecoder {
|
||||
public static final AbstractPacketDecoder INSTANCE = new Bmw0B5();
|
|
@ -1,8 +1,8 @@
|
|||
package com.rusefi.can.decoders.bmw;
|
||||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.PacketPayload;
|
||||
import com.rusefi.can.decoders.AbstractPacketDecoder;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
public class Bmw0B6 extends AbstractPacketDecoder {
|
||||
public static final AbstractPacketDecoder INSTANCE = new Bmw0B6();
|
|
@ -1,10 +1,10 @@
|
|||
package com.rusefi.can.decoders.bmw;
|
||||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.PacketPayload;
|
||||
import com.rusefi.can.SensorType;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.decoders.AbstractPacketDecoder;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
public class Bmw0BA extends AbstractPacketDecoder {
|
||||
public static final int ID = 0x0BA;
|
|
@ -1,10 +1,10 @@
|
|||
package com.rusefi.can.decoders.bmw;
|
||||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.PacketPayload;
|
||||
import com.rusefi.can.SensorType;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.decoders.AbstractPacketDecoder;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
/**
|
||||
* Gear change request
|
|
@ -1,10 +1,10 @@
|
|||
package com.rusefi.can.decoders.bmw;
|
||||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.PacketPayload;
|
||||
import com.rusefi.can.SensorType;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.SensorValue;
|
||||
import com.rusefi.can.decoders.AbstractPacketDecoder;
|
||||
import com.rusefi.can.deprecated.decoders.AbstractPacketDecoder;
|
||||
|
||||
public class Bmw1D0 extends AbstractPacketDecoder {
|
||||
public Bmw1D0() {
|
|
@ -1,6 +1,6 @@
|
|||
package com.rusefi.can.decoders.bmw;
|
||||
package com.rusefi.can.deprecated.decoders.bmw;
|
||||
|
||||
import com.rusefi.can.decoders.PacketDecoder;
|
||||
import com.rusefi.can.deprecated.decoders.PacketDecoder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
|
@ -1,11 +1,9 @@
|
|||
package com.rusefi.can.reader;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.ReaderTypeHolder;
|
||||
import com.rusefi.can.TrcToMlq;
|
||||
import com.rusefi.can.reader.impl.CANoeReader;
|
||||
import com.rusefi.can.reader.impl.CanHackerReader;
|
||||
import com.rusefi.can.reader.impl.PcanTrcReader;
|
||||
import com.rusefi.can.reader.impl.PcanTrcReader1_1;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
@ -16,7 +14,8 @@ import java.util.function.Consumer;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
public interface CANLineReader {
|
||||
char FLOAT_DIVIDER = new Double(0).toString().charAt(1);
|
||||
// locale drama is here? todo: more flexibility?
|
||||
char FLOAT_DIVIDER = Double.toString(0).charAt(1);
|
||||
|
||||
static byte[] readHexArray(String[] tokens, int start, int size) {
|
||||
byte[] data = new byte[size];
|
||||
|
@ -33,7 +32,7 @@ public interface CANLineReader {
|
|||
return CanHackerReader.INSTANCE;
|
||||
case PCAN:
|
||||
default:
|
||||
return new PcanTrcReader();
|
||||
return new PcanTrcReader1_1();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Reading logic for multiple formats of CAN trace logs
|
|
@ -1,11 +1,11 @@
|
|||
package com.rusefi.can;
|
||||
package com.rusefi.can.reader;
|
||||
|
||||
import com.rusefi.can.reader.ReaderType;
|
||||
import com.rusefi.can.TrcToMlq;
|
||||
|
||||
public enum ReaderTypeHolder {
|
||||
INSTANCE;
|
||||
|
||||
ReaderType type;
|
||||
public ReaderType type;
|
||||
|
||||
public ReaderType getType() {
|
||||
if (type == null)
|
|
@ -3,10 +3,18 @@ package com.rusefi.can.reader.impl;
|
|||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.reader.CANLineReader;
|
||||
|
||||
public class PcanTrcReader implements CANLineReader {
|
||||
import static com.rusefi.can.reader.impl.PcanTrcReader2_0.FILEVERSION;
|
||||
|
||||
/**
|
||||
* @see PcanTrcReader2_0 for version 2.0 format
|
||||
* TODO: merge these two?
|
||||
*/
|
||||
public class PcanTrcReader1_1 implements CANLineReader {
|
||||
@Override
|
||||
public CANPacket readLine(String line) {
|
||||
line = line.trim();
|
||||
if (line.startsWith(FILEVERSION) && !line.startsWith(FILEVERSION + "=1.1"))
|
||||
throw new IllegalStateException("Unexpected fileversion " + line);
|
||||
if (line.startsWith(";"))
|
||||
return null;
|
||||
String[] tokens = line.split("\\s+");
|
|
@ -3,12 +3,20 @@ package com.rusefi.can.reader.impl;
|
|||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.reader.CANLineReader;
|
||||
|
||||
public enum PcanReader implements CANLineReader {
|
||||
/**
|
||||
* @see PcanTrcReader1_1 for version 1.1 format
|
||||
* TODO: merge these two?
|
||||
*/
|
||||
public enum PcanTrcReader2_0 implements CANLineReader {
|
||||
INSTANCE;
|
||||
|
||||
public static final String FILEVERSION = ";$FILEVERSION";
|
||||
|
||||
@Override
|
||||
public CANPacket readLine(String line) {
|
||||
line = line.trim();
|
||||
if (line.startsWith(FILEVERSION) && !line.startsWith(FILEVERSION + "=2.0"))
|
||||
throw new IllegalStateException("Unexpected fileversion " + line);
|
||||
if (line.startsWith(";"))
|
||||
return null;
|
||||
String[] tokens = line.split("\\s+");
|
|
@ -0,0 +1,7 @@
|
|||
package com.rusefi.util;
|
||||
|
||||
public class BitMathUtil {
|
||||
public static int mask(int bitWidth) {
|
||||
return (1 << bitWidth) - 1;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package com.rusefi.can;
|
||||
|
||||
import com.rusefi.can.decoders.bmw.Bmw0A9;
|
||||
import com.rusefi.can.decoders.bmw.Bmw0AA;
|
||||
import com.rusefi.can.decoders.bmw.Bmw0B5;
|
||||
import com.rusefi.can.decoders.bmw.Bmw1D0;
|
||||
import com.rusefi.can.deprecated.PacketPayload;
|
||||
import com.rusefi.can.deprecated.SensorType;
|
||||
import com.rusefi.can.deprecated.decoders.bmw.Bmw0A9;
|
||||
import com.rusefi.can.deprecated.decoders.bmw.Bmw0AA;
|
||||
import com.rusefi.can.deprecated.decoders.bmw.Bmw0B5;
|
||||
import com.rusefi.can.deprecated.decoders.bmw.Bmw1D0;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.rusefi.can.analysis.ByteRateOfChange;
|
|||
import com.rusefi.can.analysis.ByteRateOfChangeReports;
|
||||
import com.rusefi.can.reader.CANLineReader;
|
||||
import com.rusefi.can.reader.ReaderType;
|
||||
import com.rusefi.can.reader.ReaderTypeHolder;
|
||||
import com.rusefi.util.FolderUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.rusefi.can;
|
||||
package com.rusefi.can.deprecated;
|
||||
|
||||
import com.rusefi.can.reader.CANLineReader;
|
||||
import com.rusefi.can.reader.impl.PcanReader;
|
||||
import com.rusefi.can.reader.impl.PcanTrcReader2_0;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class PcanCanValidator {
|
||||
public class BmwPcanCanValidatorSandbox {
|
||||
public static void main(String[] args) throws IOException {
|
||||
CANLineReader reader = PcanReader.INSTANCE;
|
||||
CANLineReader reader = PcanTrcReader2_0.INSTANCE;
|
||||
|
||||
// CANoeCanValidator.validate("C:\\stuff\\rusefi_documentation\\OEM-Docs\\Bmw\\2003_7_Series_e65\\HeinrichG-V12-E65_ReverseEngineering\\E65-760-andrey-2021-feb-21-engine-off-acc-on.trc", reader);
|
||||
// CANoeCanValidator.validate("C:\\stuff\\rusefi_documentation\\OEM-Docs\\Bmw\\2003_7_Series_e65\\HeinrichG-V12-E65_ReverseEngineering\\E65-760-andrey-2021-feb-21-engine-off-inpa-tcu-reset-codes.trc", reader);
|
|
@ -1,7 +1,8 @@
|
|||
package com.rusefi.can;
|
||||
package com.rusefi.can.deprecated;
|
||||
|
||||
import com.rusefi.can.decoders.bmw.Bmw0BA;
|
||||
import com.rusefi.can.decoders.bmw.Bmw192;
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.deprecated.decoders.bmw.Bmw0BA;
|
||||
import com.rusefi.can.deprecated.decoders.bmw.Bmw192;
|
||||
import com.rusefi.can.reader.CANLineReader;
|
||||
import com.rusefi.can.reader.impl.CANoeReader;
|
||||
|
||||
|
@ -10,6 +11,9 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* this code looks to validate BMW logs against hard-coded BMW packet logic? dead stuff since we've moved to DBC approach?
|
||||
*/
|
||||
public class CANoeCanValidator {
|
||||
public static void main(String[] args) throws IOException {
|
||||
CANLineReader reader = CANoeReader.INSTANCE;
|
||||
|
@ -18,8 +22,8 @@ public class CANoeCanValidator {
|
|||
|
||||
}
|
||||
|
||||
public static void validate(String fileName, CANLineReader reader) throws IOException {
|
||||
List<CANPacket> packetList = reader.readFile(fileName);
|
||||
public static void validate(String inputFileName, CANLineReader reader) throws IOException {
|
||||
List<CANPacket> packetList = reader.readFile(inputFileName);
|
||||
|
||||
TreeMap<Integer, Object> allIds = new TreeMap<>();
|
||||
|
||||
|
@ -34,7 +38,9 @@ public class CANoeCanValidator {
|
|||
|
||||
}
|
||||
|
||||
try (FileWriter fw = new FileWriter("all_ids.txt")) {
|
||||
String outputFileName = "all_ids.txt";
|
||||
System.out.println("Writing to " + outputFileName);
|
||||
try (FileWriter fw = new FileWriter(outputFileName)) {
|
||||
for (Integer id : allIds.keySet()) {
|
||||
fw.write(Integer.toHexString(id) + "\r\n");
|
||||
}
|
|
@ -2,7 +2,6 @@ package com.rusefi.can.reader.impl;
|
|||
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.reader.impl.CANoeReader;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
|
|
|
@ -31,7 +31,7 @@ public class GetValueFromTrc {
|
|||
|
||||
String trcLine = " 3769) 2117.7 Rx 0280 8 01 1D DF 12 1E 00 1A 1E ";
|
||||
|
||||
PcanTrcReader reader = new PcanTrcReader();
|
||||
PcanTrcReader1_1 reader = new PcanTrcReader1_1();
|
||||
CANPacket packet = reader.readLine(trcLine);
|
||||
assertEquals(8, packet.getData().length);
|
||||
assertEquals(640, packet.getId());
|
||||
|
|
|
@ -20,7 +20,7 @@ public class ParseDbcFieldTest {
|
|||
assertEquals(0.75, iatField.getMult(), EPS);
|
||||
assertEquals(-48, iatField.getOffset(), EPS);
|
||||
|
||||
CANPacket packet = new PcanTrcReader().readLine(" 2197) 1234.8 Rx 0380 8 00 62 FA 00 22 00 00 FA");
|
||||
CANPacket packet = new PcanTrcReader1_1().readLine(" 2197) 1234.8 Rx 0380 8 00 62 FA 00 22 00 00 FA");
|
||||
assertEquals(8, packet.getData().length);
|
||||
|
||||
assertEquals(25.5, iatField.getValue(packet), EPS);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.rusefi.can.reader.impl;
|
||||
|
||||
import com.rusefi.can.CANPacket;
|
||||
import com.rusefi.can.decoders.bmw.Bmw192;
|
||||
import com.rusefi.can.deprecated.decoders.bmw.Bmw192;
|
||||
import com.rusefi.can.reader.CANLineReader;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import static junit.framework.TestCase.assertEquals;
|
|||
public class PcanReaderTest {
|
||||
@Test
|
||||
public void testLine() {
|
||||
CANLineReader reader = PcanReader.INSTANCE;
|
||||
CANLineReader reader = PcanTrcReader2_0.INSTANCE;
|
||||
CANPacket packet = reader.readLine(" 15883 77333097.212 DT 0192 Rx 4 2D 04 80 F9 ");
|
||||
assertEquals(4, packet.getData().length);
|
||||
assertEquals(Bmw192.ID, packet.getId());
|
||||
|
|
|
@ -23,7 +23,7 @@ public class TrcToMlqSandbox {
|
|||
dbc.read(reader);
|
||||
}
|
||||
|
||||
List<CANPacket> packets = new PcanTrcReader().readFile(trcFileName);
|
||||
List<CANPacket> packets = new PcanTrcReader1_1().readFile(trcFileName);
|
||||
System.out.println(packets.size() + " packets");
|
||||
|
||||
LoggingStrategy.writeLog(dbc, packets, "gauges.mlg");
|
||||
|
|
Loading…
Reference in New Issue