mirror of https://github.com/FOME-Tech/fome-fw.git
inspection: misc
This commit is contained in:
parent
77d6129016
commit
e90f3b754b
|
@ -357,31 +357,6 @@ public class BinaryProtocol {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -59,19 +59,6 @@ public class SandboxCommon {
|
|||
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);
|
||||
|
|
|
@ -85,9 +85,8 @@ public class UpDownImage extends JPanel {
|
|||
translator = createTranslator();
|
||||
}
|
||||
|
||||
public UpDownImage setTranslator(TimeAxisTranslator translator) {
|
||||
public void setTranslator(TimeAxisTranslator translator) {
|
||||
this.translator = translator;
|
||||
return this;
|
||||
}
|
||||
|
||||
private final TimeAxisTranslator _translator = new TimeAxisTranslator() {
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package com.rusefi.test;
|
||||
|
||||
//import com.rusefi.ui.widgets.PotCommand;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
public class VoltageDividerTest extends TestCase {
|
||||
|
||||
@Test
|
||||
public void testR1() {
|
||||
// assertEquals(2000.0, PotCommand.getR1InVoltageDivider3(1, 5, 10000));
|
||||
//
|
||||
// assertEquals(2040.816326530612, PotCommand.getR1InVoltageDivider3(1, 4.9, 10000));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue