mirror of https://github.com/FOME-Tech/fome-fw.git
mostly logging improvements
This commit is contained in:
parent
458f3a854d
commit
1935749e27
|
@ -231,7 +231,7 @@ public class BinaryProtocol {
|
||||||
public boolean connectAndReadConfiguration(DataListener listener) {
|
public boolean connectAndReadConfiguration(DataListener listener) {
|
||||||
try {
|
try {
|
||||||
signature = getSignature(stream);
|
signature = getSignature(stream);
|
||||||
System.out.println("BinaryProtocol: Got " + signature + " signature");
|
log.info("Got " + signature + " signature");
|
||||||
SignatureHelper.downloadIfNotAvailable(SignatureHelper.getUrl(signature));
|
SignatureHelper.downloadIfNotAvailable(SignatureHelper.getUrl(signature));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -378,8 +378,8 @@ public class BinaryProtocol {
|
||||||
byte[] response = executeCommand(packet, "load image offset=" + offset);
|
byte[] response = executeCommand(packet, "load image offset=" + offset);
|
||||||
|
|
||||||
if (!checkResponseCode(response, (byte) Fields.TS_RESPONSE_OK) || response.length != requestSize + 1) {
|
if (!checkResponseCode(response, (byte) Fields.TS_RESPONSE_OK) || response.length != requestSize + 1) {
|
||||||
String code = (response == null || response.length == 0) ? "empty" : "code " + getCode(response);
|
String code = (response == null || response.length == 0) ? "empty" : "ERROR_CODE=" + getCode(response);
|
||||||
String info = response == null ? "NO RESPONSE" : (code + " size " + response.length);
|
String info = response == null ? "NO RESPONSE" : (code + " length=" + response.length);
|
||||||
log.info("readImage: ERROR UNEXPECTED Something is wrong, retrying... " + info);
|
log.info("readImage: ERROR UNEXPECTED Something is wrong, retrying... " + info);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -411,6 +411,8 @@ public class BinaryProtocol {
|
||||||
return "OUT_OF_RANGE";
|
return "OUT_OF_RANGE";
|
||||||
case TS_RESPONSE_FRAMING_ERROR:
|
case TS_RESPONSE_FRAMING_ERROR:
|
||||||
return "FRAMING_ERROR";
|
return "FRAMING_ERROR";
|
||||||
|
case TS_RESPONSE_UNDERRUN:
|
||||||
|
return "TS_RESPONSE_UNDERRUN";
|
||||||
}
|
}
|
||||||
return Integer.toString(b);
|
return Integer.toString(b);
|
||||||
}
|
}
|
||||||
|
@ -438,9 +440,9 @@ public class BinaryProtocol {
|
||||||
// that's unusual - most of the protocol is LITTLE_ENDIAN
|
// that's unusual - most of the protocol is LITTLE_ENDIAN
|
||||||
bb.order(ByteOrder.BIG_ENDIAN);
|
bb.order(ByteOrder.BIG_ENDIAN);
|
||||||
int crcFromController = bb.getInt();
|
int crcFromController = bb.getInt();
|
||||||
log.info(String.format("From rusEFI tune CRC32 0x%x %d\n", crcFromController, crcFromController));
|
log.info(String.format("rusEFI says tune CRC32 0x%x %d\n", crcFromController, crcFromController));
|
||||||
short crc16FromController = (short) crcFromController;
|
short crc16FromController = (short) crcFromController;
|
||||||
log.info(String.format("From rusEFI tune CRC16 0x%x %d\n", crc16FromController, crc16FromController));
|
log.info(String.format("rusEFI says tune CRC16 0x%x %d\n", crc16FromController, crc16FromController));
|
||||||
if (crcOfLocallyCachedConfiguration == crcFromController) {
|
if (crcOfLocallyCachedConfiguration == crcFromController) {
|
||||||
return localCached;
|
return localCached;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ public class IncomingDataBuffer {
|
||||||
log.error("dropPending: Unexpected pending data: " + pending + " byte(s)");
|
log.error("dropPending: Unexpected pending data: " + pending + " byte(s)");
|
||||||
byte[] bytes = new byte[pending];
|
byte[] bytes = new byte[pending];
|
||||||
cbb.get(bytes);
|
cbb.get(bytes);
|
||||||
log.error("data: " + Arrays.toString(bytes));
|
log.error("DROPPED FROM BUFFER: " + IoStream.printByteArray(bytes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class IsoTpCanDecoder {
|
||||||
case ISO_TP_FRAME_CONSECUTIVE:
|
case ISO_TP_FRAME_CONSECUTIVE:
|
||||||
frameIdx = data[0] & 0xf;
|
frameIdx = data[0] & 0xf;
|
||||||
if (this.waitingForNumBytes < 0 || this.waitingForFrameIndex != frameIdx) {
|
if (this.waitingForNumBytes < 0 || this.waitingForFrameIndex != frameIdx) {
|
||||||
throw new IllegalStateException("ISO_TP_FRAME_CONSECUTIVE: That's an abnormal situation, and we probably should react? " + waitingForNumBytes + " " + waitingForFrameIndex + " " + frameIdx);
|
throw new IllegalStateException("ISO_TP_FRAME_CONSECUTIVE: That's an abnormal situation, and we probably should react? waitingForNumBytes=" + waitingForNumBytes + " waitingForFrameIndex=" + waitingForFrameIndex + " frameIdx=" + frameIdx);
|
||||||
}
|
}
|
||||||
this.waitingForFrameIndex = (this.waitingForFrameIndex + 1) & 0xf;
|
this.waitingForFrameIndex = (this.waitingForFrameIndex + 1) & 0xf;
|
||||||
numBytesAvailable = Math.min(this.waitingForNumBytes, 7);
|
numBytesAvailable = Math.min(this.waitingForNumBytes, 7);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.devexperts.logging.Logging;
|
||||||
import com.rusefi.io.IoStream;
|
import com.rusefi.io.IoStream;
|
||||||
|
|
||||||
public abstract class IsoTpConnector {
|
public abstract class IsoTpConnector {
|
||||||
private final static Logging log = Logging.getLogging(Elm327Connector.class);
|
private final static Logging log = Logging.getLogging(IsoTpConnector.class);
|
||||||
|
|
||||||
public static void sendStrategy(byte[] bytes, IsoTpConnector connector) {
|
public static void sendStrategy(byte[] bytes, IsoTpConnector connector) {
|
||||||
log.info("-------sendBytesToCan " + bytes.length + " byte(s):");
|
log.info("-------sendBytesToCan " + bytes.length + " byte(s):");
|
||||||
|
|
|
@ -44,7 +44,6 @@ public class PCanIoStream extends AbstractIoStream {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveData() {
|
public void receiveData() {
|
||||||
System.out.println("empty receiveData");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,7 +90,7 @@ public class PCanIoStream extends AbstractIoStream {
|
||||||
byte[] decode = canDecoder.decodePacket(rx.getData());
|
byte[] decode = canDecoder.decodePacket(rx.getData());
|
||||||
listener.onDataArrived(decode);
|
listener.onDataArrived(decode);
|
||||||
|
|
||||||
System.out.println("Decoded " + IoStream.printByteArray(decode));
|
// System.out.println("Decoded " + IoStream.printByteArray(decode));
|
||||||
} else {
|
} else {
|
||||||
// System.out.println(new Date() + ": Receive " + status);
|
// System.out.println(new Date() + ": Receive " + status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
package com.rusefi.binaryprotocol.test;
|
package com.rusefi.binaryprotocol.test;
|
||||||
|
|
||||||
|
import com.opensr5.ConfigurationImage;
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
import com.rusefi.binaryprotocol.BinaryProtocol;
|
||||||
|
import com.rusefi.binaryprotocol.BinaryProtocolState;
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
|
import com.rusefi.io.ConnectionStateListener;
|
||||||
|
import com.rusefi.io.LinkManager;
|
||||||
|
import com.rusefi.io.serial.StreamConnector;
|
||||||
import peak.can.basic.*;
|
import peak.can.basic.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Elm327Sandbox
|
||||||
|
*/
|
||||||
public class PCanSandbox {
|
public class PCanSandbox {
|
||||||
|
|
||||||
public static final TPCANHandle CHANNEL = TPCANHandle.PCAN_USBBUS1;
|
public static final TPCANHandle CHANNEL = TPCANHandle.PCAN_USBBUS1;
|
||||||
|
@ -22,7 +30,7 @@ public class PCanSandbox {
|
||||||
|
|
||||||
PCanIoStream tsStream = new PCanIoStream(can);
|
PCanIoStream tsStream = new PCanIoStream(can);
|
||||||
|
|
||||||
|
/*
|
||||||
{
|
{
|
||||||
String signature = BinaryProtocol.getSignature(tsStream);
|
String signature = BinaryProtocol.getSignature(tsStream);
|
||||||
System.out.println("Got " + signature + " signature via PCAN");
|
System.out.println("Got " + signature + " signature via PCAN");
|
||||||
|
@ -41,5 +49,29 @@ public class PCanSandbox {
|
||||||
System.out.println("****************************************");
|
System.out.println("****************************************");
|
||||||
System.out.println("********* PCAN LOOKS GREAT ***********");
|
System.out.println("********* PCAN LOOKS GREAT ***********");
|
||||||
System.out.println("****************************************");
|
System.out.println("****************************************");
|
||||||
|
*/
|
||||||
|
LinkManager linkManager = new LinkManager();
|
||||||
|
StreamConnector streamConnector = new StreamConnector(linkManager, () -> tsStream);
|
||||||
|
linkManager.setConnector(streamConnector);
|
||||||
|
streamConnector.connectAndReadConfiguration(new ConnectionStateListener() {
|
||||||
|
@Override
|
||||||
|
public void onConnectionEstablished() {
|
||||||
|
System.out.println("onConnectionEstablished");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConnectionFailed() {
|
||||||
|
System.out.println("onConnectionFailed");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
BinaryProtocol currentStreamState = linkManager.getCurrentStreamState();
|
||||||
|
if (currentStreamState == null) {
|
||||||
|
System.out.println("No BinaryProtocol");
|
||||||
|
} else {
|
||||||
|
BinaryProtocolState binaryProtocolState = currentStreamState.getBinaryProtocolState();
|
||||||
|
ConfigurationImage ci = binaryProtocolState.getControllerConfiguration();
|
||||||
|
System.out.println("Got ConfigurationImage " + ci);
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue