can-log-tools/src/main/java/com/rusefi/can/reader/impl/CANoeReader.java

31 lines
871 B
Java
Raw Normal View History

2022-02-15 13:17:28 -08:00
package com.rusefi.can.reader.impl;
2022-02-02 16:48:51 -08:00
import com.rusefi.can.CANPacket;
2022-02-15 13:17:28 -08:00
import com.rusefi.can.reader.CANLineReader;
2022-02-02 16:48:51 -08:00
2022-02-02 19:37:29 -08:00
import java.io.IOException;
import java.util.List;
2022-02-15 13:17:28 -08:00
public enum CANoeReader implements CANLineReader {
INSTANCE;
2022-02-02 19:37:29 -08:00
@Override
2023-12-15 07:38:17 -08:00
public CANPacket readLine(String line, String fileName, int lineIndex) {
2022-02-02 19:37:29 -08:00
if (line.contains("ErrorFrame"))
return null;
String[] tokens = line.trim().split("\\s+");
2022-02-02 16:48:51 -08:00
double timeStamp = Double.parseDouble(tokens[0]);
int sid = Integer.parseInt(tokens[2], 16);
2022-02-15 13:17:28 -08:00
int size = Integer.parseInt(tokens[5]);
2022-02-02 16:48:51 -08:00
2022-02-15 13:17:28 -08:00
byte[] data = CANLineReader.readHexArray(tokens, 6, size);
2022-02-02 16:48:51 -08:00
return new CANPacket(timeStamp, sid, data);
2022-02-02 19:37:29 -08:00
}
2022-02-02 16:48:51 -08:00
2022-02-15 13:17:28 -08:00
@Override
2022-02-02 19:37:29 -08:00
public List<CANPacket> readFile(String fileName) throws IOException {
2022-09-12 23:01:23 -07:00
return skipHeaderAndRead(fileName, 5);
2022-02-02 16:48:51 -08:00
}
}