better logging

This commit is contained in:
rusefi 2021-12-18 19:33:50 -05:00
parent 40aad18135
commit 5da5c2d15f
3 changed files with 7 additions and 7 deletions

View File

@ -131,7 +131,7 @@ public class IncomingDataBuffer {
while (cbb.length() < count) {
int timeout = (int) (startTimestamp + timeoutMs - System.currentTimeMillis());
if (timeout <= 0) {
log.info(loggingMessage + ": timeout. Got only " + cbb.length() + " while expecting " + count);
log.info(loggingMessage + ": timeout " + timeoutMs + "ms. Got only " + cbb.length() + " while expecting " + count);
return true; // timeout. Sad face.
}
try {

View File

@ -59,7 +59,7 @@ public class IsoTpCanDecoder {
dataOffset = 1;
waitingForNumBytes -= numBytesAvailable;
if (log.debugEnabled())
log.debug("ISO_TP_FRAME_CONSECUTIVE Got " + numBytesAvailable + ", still expecting: " + waitingForNumBytes);
log.debug("ISO_TP_FRAME_CONSECUTIVE Got " + numBytesAvailable + " byte(s), still expecting: " + waitingForNumBytes + " byte(s)");
break;
case ISO_TP_FRAME_FLOW_CONTROL:
int flowStatus = data[0] & 0xf;

View File

@ -37,7 +37,7 @@ public class PCanIoStream extends AbstractIoStream {
log.info("-------sendIsoTp " + total.length + " byte(s):");
System.out.println(IoStream.printHexBinary(total));
log.info(IoStream.printHexBinary(total));
sendCanPacket(total);
}
@ -53,7 +53,7 @@ public class PCanIoStream extends AbstractIoStream {
can.initializeAPI();
TPCANStatus status = can.Initialize(CHANNEL, TPCANBaudrate.PCAN_BAUD_500K, TPCANType.PCAN_TYPE_NONE, 0, (short) 0);
if (status != TPCANStatus.PCAN_ERROR_OK) {
System.err.println("Error initializing PCAN: " + status);
log.info("Error initializing PCAN: " + status);
return null;
}
System.out.println("Hello PCAN!");
@ -65,10 +65,10 @@ public class PCanIoStream extends AbstractIoStream {
(byte) payLoad.length, payLoad);
TPCANStatus status = can.Write(CHANNEL, msg);
if (status != TPCANStatus.PCAN_ERROR_OK) {
System.out.println("Unable to write the CAN message: " + status);
log.info("Unable to write the CAN message: " + status);
System.exit(0);
}
// System.out.println("Send OK! length=" + payLoad.length);
// log.info("Send OK! length=" + payLoad.length);
}
private DataListener listener;
@ -99,7 +99,7 @@ public class PCanIoStream extends AbstractIoStream {
TPCANMsg rx = new TPCANMsg();
TPCANStatus status = can.Read(CHANNEL, rx, null);
if (status == TPCANStatus.PCAN_ERROR_OK) {
System.out.println(rx + " id=" + rx.getID() + " len=" + rx.getLength() + ": " + IoStream.printByteArray(rx.getData()));
log.info(rx + " id=" + rx.getID() + " len=" + rx.getLength() + ": " + IoStream.printByteArray(rx.getData()));
byte[] decode = canDecoder.decodePacket(rx.getData());
listener.onDataArrived(decode);