Linux is asking for SocketCAN ISO-TP console connector #4123
ooops we forgot about magic 300000... packet
This commit is contained in:
parent
2d37491c37
commit
40a9bf5c31
|
@ -10,6 +10,7 @@ import java.util.Arrays;
|
|||
* @see IsoTpConnector
|
||||
*/
|
||||
public class IsoTpCanDecoder {
|
||||
public static final byte[] FLOW_CONTROL = {0x30, 0, 0, 0, 0, 0, 0, 0};
|
||||
private static final Logging log = Logging.getLogging(IsoTpCanDecoder.class);
|
||||
|
||||
static {
|
||||
|
|
|
@ -29,7 +29,7 @@ public class PCanIoStream extends AbstractIoStream {
|
|||
private final IsoTpCanDecoder canDecoder = new IsoTpCanDecoder() {
|
||||
@Override
|
||||
protected void onTpFirstFrame() {
|
||||
sendCanPacket(new byte[]{0x30, 0, 0, 0, 0, 0, 0, 0});
|
||||
sendCanPacket(FLOW_CONTROL);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -38,10 +38,6 @@ public class PCanIoStream extends AbstractIoStream {
|
|||
public void sendCanData(byte[] hdr, byte[] data, int dataOffset, int dataLength) {
|
||||
byte[] total = combineArrays(hdr, data, dataOffset, dataLength);
|
||||
|
||||
log.info("-------sendIsoTp " + total.length + " byte(s):");
|
||||
|
||||
log.info("Sending " + IoStream.printHexBinary(total));
|
||||
|
||||
sendCanPacket(total);
|
||||
}
|
||||
|
||||
|
@ -64,6 +60,10 @@ public class PCanIoStream extends AbstractIoStream {
|
|||
}
|
||||
|
||||
private void sendCanPacket(byte[] payLoad) {
|
||||
log.info("-------sendIsoTp " + payLoad.length + " byte(s):");
|
||||
|
||||
log.info("Sending " + IoStream.printHexBinary(payLoad));
|
||||
|
||||
TPCANMsg msg = new TPCANMsg(Fields.CAN_ECU_SERIAL_RX_ID, PCAN_MESSAGE_STANDARD.getValue(),
|
||||
(byte) payLoad.length, payLoad);
|
||||
TPCANStatus status = can.Write(CHANNEL, msg);
|
||||
|
|
|
@ -29,23 +29,19 @@ public class SocketCANIoStream extends AbstractIoStream {
|
|||
private final IncomingDataBuffer dataBuffer;
|
||||
private final RawCanChannel socket;
|
||||
|
||||
private final IsoTpCanDecoder canDecoder = new IsoTpCanDecoder();
|
||||
private final IsoTpCanDecoder canDecoder = new IsoTpCanDecoder() {
|
||||
@Override
|
||||
protected void onTpFirstFrame() {
|
||||
sendCanPacket(FLOW_CONTROL);
|
||||
}
|
||||
};
|
||||
|
||||
private final IsoTpConnector isoTpConnector = new IsoTpConnector() {
|
||||
@Override
|
||||
public void sendCanData(byte[] hdr, byte[] data, int dataOffset, int dataLength) {
|
||||
byte[] total = combineArrays(hdr, data, dataOffset, dataLength);
|
||||
|
||||
log.info("-------sendIsoTp " + total.length + " byte(s):");
|
||||
|
||||
log.info("Sending " + IoStream.printHexBinary(total));
|
||||
|
||||
CanFrame packet = CanFrame.create(Fields.CAN_ECU_SERIAL_RX_ID, FD_NO_FLAGS, total);
|
||||
try {
|
||||
socket.write(packet);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
sendCanPacket(total);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,6 +49,19 @@ public class SocketCANIoStream extends AbstractIoStream {
|
|||
}
|
||||
};
|
||||
|
||||
private void sendCanPacket(byte[] total) {
|
||||
log.info("-------sendIsoTp " + total.length + " byte(s):");
|
||||
|
||||
log.info("Sending " + IoStream.printHexBinary(total));
|
||||
|
||||
CanFrame packet = CanFrame.create(Fields.CAN_ECU_SERIAL_RX_ID, FD_NO_FLAGS, total);
|
||||
try {
|
||||
socket.write(packet);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public SocketCANIoStream() {
|
||||
try {
|
||||
NetworkDevice canInterface = NetworkDevice.lookup("can0");
|
||||
|
|
Loading…
Reference in New Issue