Compare commits
No commits in common. "1e9efdfa6df2ab7e1730454ff36893d939499409" and "77459117ece0b8d32ff65b453ab0c7b15c26bac1" have entirely different histories.
1e9efdfa6d
...
77459117ec
|
@ -1,9 +1,3 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'java-library'
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api rootProject
|
|
||||||
api project(':peak-can-basic')
|
|
||||||
}
|
}
|
|
@ -1,34 +0,0 @@
|
||||||
package com.rusefi.can;
|
|
||||||
|
|
||||||
import com.rusefi.io.can.PCanHelper;
|
|
||||||
import peak.can.basic.PCANBasic;
|
|
||||||
import peak.can.basic.TPCANStatus;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CanPacketSender {
|
|
||||||
public static void sendMessagesOut(List<CANPacket> logFileContent, PCANBasic pcan) throws InterruptedException {
|
|
||||||
int okCounter = 0;
|
|
||||||
|
|
||||||
for (CANPacket packet : logFileContent) {
|
|
||||||
TPCANStatus status = PCanHelper.send(pcan, packet.getId(), packet.getData());
|
|
||||||
if (status == TPCANStatus.PCAN_ERROR_XMTFULL || status == TPCANStatus.PCAN_ERROR_QXMTFULL) {
|
|
||||||
Thread.sleep(10);
|
|
||||||
// System.out.println(String.format("Let's retry ID=%x", packet.getId()) + " OK=" + okCounter);
|
|
||||||
status = PCanHelper.send(pcan, packet.getId(), packet.getData());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == TPCANStatus.PCAN_ERROR_OK) {
|
|
||||||
okCounter++;
|
|
||||||
} else {
|
|
||||||
System.out.println("Error sending " + status);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (okCounter % 1000 == 0) {
|
|
||||||
System.out.println(new Date() + ": Total " + okCounter + " OK messages");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package com.rusefi.io.can;
|
|
||||||
|
|
||||||
|
|
||||||
import peak.can.basic.*;
|
|
||||||
|
|
||||||
import static peak.can.basic.TPCANMessageType.PCAN_MESSAGE_STANDARD;
|
|
||||||
|
|
||||||
public class PCanHelper {
|
|
||||||
public static final TPCANHandle CHANNEL = TPCANHandle.PCAN_USBBUS1;
|
|
||||||
|
|
||||||
// @NotNull
|
|
||||||
public static PCANBasic create() {
|
|
||||||
PCANBasic can = new PCANBasic();
|
|
||||||
can.initializeAPI();
|
|
||||||
return can;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TPCANStatus init(PCANBasic can) {
|
|
||||||
return can.Initialize(CHANNEL, TPCANBaudrate.PCAN_BAUD_500K, TPCANType.PCAN_TYPE_NONE, 0, (short) 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TPCANStatus send(PCANBasic can, int id, byte[] payLoad) {
|
|
||||||
//log.info(String.format("Sending id=%x %s", id, HexBinary.printByteArray(payLoad)));
|
|
||||||
TPCANMsg msg = new TPCANMsg(id, PCAN_MESSAGE_STANDARD.getValue(),
|
|
||||||
(byte) payLoad.length, payLoad);
|
|
||||||
return can.Write(CHANNEL, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PCANBasic createAndInit() {
|
|
||||||
PCANBasic pcan = create();
|
|
||||||
TPCANStatus initStatus = init(pcan);
|
|
||||||
if (initStatus != TPCANStatus.PCAN_ERROR_OK) {
|
|
||||||
System.out.println("TPCANStatus " + initStatus);
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
return pcan;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue