Skip to content

Commit

Permalink
inspection: misc
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Nov 26, 2023
1 parent 77d6129 commit e90f3b7
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,31 +357,6 @@ private static int extractCode(byte[] response) {
return response[0] & 0xff;
}

public int getCrcFromController(int configSize) {
byte[] packet = createCrcCommand(configSize);
byte[] response = executeCommand(Fields.TS_CRC_CHECK_COMMAND, packet, "get CRC32");

if (checkResponseCode(response, (byte) Fields.TS_RESPONSE_OK) && response.length == 5) {
ByteBuffer bb = ByteBuffer.wrap(response, 1, 4);
// that's unusual - most of the protocol is LITTLE_ENDIAN
bb.order(ByteOrder.BIG_ENDIAN);
int crc32FromController = bb.getInt();
short crc16FromController = (short) crc32FromController;

log.info(String.format("rusEFI says tune CRC32 0x%x %d\n", crc32FromController, crc32FromController));
log.info(String.format("rusEFI says tune CRC16 0x%x %d\n", crc16FromController, crc16FromController));
return crc32FromController;
} else {
return -1;
}
}

public static byte[] createCrcCommand(int size) {
byte[] packet = new byte[4];
ByteRange.packOffsetAndSize(0, size, packet);
return packet;
}

public byte[] executeCommand(char opcode, String msg) {
return executeCommand(opcode, null, msg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class IoHelper {
}

public static int getCrc32(byte[] packet) {
return getCrc32(packet, 0, packet.length);
return getCrc32(packet, packet.length);
}

private static int getCrc32(byte[] packet, int offset, int length) {
private static int getCrc32(byte[] packet, int length) {
CRC32 c = new CRC32();
c.update(packet, offset, length);
c.update(packet, 0, length);
return (int) c.getValue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,6 @@ public void onConnectionFailed(String s) {
return ci;
}

static void verifyCrcNoPending(IoStream tsStream, LinkManager linkManager) {
BinaryProtocol bp = new BinaryProtocol(linkManager, tsStream);
linkManager.COMMUNICATION_EXECUTOR.submit(() -> {
if (tsStream.getDataBuffer().dropPending() != 0)
log.info("ERROR Extra data before CRC");
bp.getCrcFromController(Fields.TOTAL_CONFIG_SIZE);
// bp.getCrcFromController(Fields.TOTAL_CONFIG_SIZE);
// bp.getCrcFromController(Fields.TOTAL_CONFIG_SIZE);
if (tsStream.getDataBuffer().dropPending() != 0)
throw new IllegalStateException("ERROR Extra data after CRC");
});
}

static void verifySignature(IoStream tsStream, String prefix, String suffix) throws IOException {
String signature = BinaryProtocol.getSignature(tsStream);
log.info(prefix + "Got " + signature + " signature via " + suffix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ public UpDownImage(EngineReport wr, String name) {
translator = createTranslator();
}

public UpDownImage setTranslator(TimeAxisTranslator translator) {
public void setTranslator(TimeAxisTranslator translator) {
this.translator = translator;
return this;
}

private final TimeAxisTranslator _translator = new TimeAxisTranslator() {
Expand Down

This file was deleted.

0 comments on commit e90f3b7

Please sign in to comment.