can-log-tools/reader/src/main/java/com/rusefi/can/deprecated/decoders/AbstractPacketDecoder.java

26 lines
656 B
Java
Raw Normal View History

2022-11-12 19:13:12 -08:00
package com.rusefi.can.deprecated.decoders;
2022-02-02 21:03:56 -08:00
2022-02-14 21:45:27 -08:00
import com.rusefi.can.CANPacket;
2024-01-12 22:08:24 -08:00
import com.rusefi.can.Utils;
2022-02-14 21:45:27 -08:00
2022-02-02 21:03:56 -08:00
public abstract class AbstractPacketDecoder implements PacketDecoder {
private final int id;
public AbstractPacketDecoder(int id) {
this.id = id;
}
@Override
public int getId() {
return id;
}
2022-02-14 21:45:27 -08:00
protected void throwUnexpected(String reason, CANPacket packet) {
2022-02-15 15:28:45 -08:00
throw unexpected(reason, packet);
}
protected IllegalStateException unexpected(String reason, CANPacket packet) {
2024-01-12 22:08:24 -08:00
return new IllegalStateException(reason + ": " + Utils.bytesToHexWithSpaces(packet.getData()));
2022-02-14 21:45:27 -08:00
}
2022-02-02 21:03:56 -08:00
}