parent
5c1e3a2536
commit
a03c220629
|
@ -63,10 +63,11 @@ public class Elm327Connector implements Closeable {
|
||||||
return tsStream;
|
return tsStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(String msg) {
|
public boolean start(String msg) {
|
||||||
log.info("* Elm327.start()");
|
log.info("* Elm327.start()");
|
||||||
|
|
||||||
if (initConnection(msg)) {
|
boolean initConnection = initConnection(msg);
|
||||||
|
if (initConnection) {
|
||||||
// reset to defaults
|
// reset to defaults
|
||||||
sendCommand("ATD", "OK");
|
sendCommand("ATD", "OK");
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ public class Elm327Connector implements Closeable {
|
||||||
String voltage = sendCommand("ATRV", "([0-9\\.]+)V");
|
String voltage = sendCommand("ATRV", "([0-9\\.]+)V");
|
||||||
log.info("* Ignition voltage = " + voltage);
|
log.info("* Ignition voltage = " + voltage);
|
||||||
}
|
}
|
||||||
|
return initConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class IsoTpCanDecoder {
|
||||||
}
|
}
|
||||||
byte[] bytes = Arrays.copyOfRange(data, dataOffset, dataOffset + numBytesAvailable);
|
byte[] bytes = Arrays.copyOfRange(data, dataOffset, dataOffset + numBytesAvailable);
|
||||||
if (log.debugEnabled())
|
if (log.debugEnabled())
|
||||||
log.debug(numBytesAvailable + " bytes(s) arrived in this packet: " + IoStream.printHexBinary(bytes));
|
log.debug(numBytesAvailable + " bytes(s) arrived in this packet: " + IoStream.printByteArray(bytes));
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,9 @@ public class Elm327Sandbox {
|
||||||
BaudRateHolder.INSTANCE.baudRate = ELM327_DEFAULT_BAUDRATE;
|
BaudRateHolder.INSTANCE.baudRate = ELM327_DEFAULT_BAUDRATE;
|
||||||
String serialPort = "COM7";
|
String serialPort = "COM7";
|
||||||
Elm327Connector connector = new Elm327Connector(SerialIoStream.openPort(serialPort));
|
Elm327Connector connector = new Elm327Connector(SerialIoStream.openPort(serialPort));
|
||||||
connector.start(serialPort);
|
boolean initConnection = connector.start(serialPort);
|
||||||
|
if (!initConnection)
|
||||||
|
return;
|
||||||
|
|
||||||
IoStream tsStream = connector.getTsStream();
|
IoStream tsStream = connector.getTsStream();
|
||||||
|
|
||||||
|
@ -68,7 +70,7 @@ public class Elm327Sandbox {
|
||||||
byte[] fResponse = new byte[3];
|
byte[] fResponse = new byte[3];
|
||||||
dataBuffer.waitForBytes("CRC", System.currentTimeMillis(), fResponse.length);
|
dataBuffer.waitForBytes("CRC", System.currentTimeMillis(), fResponse.length);
|
||||||
dataBuffer.getData(fResponse);
|
dataBuffer.getData(fResponse);
|
||||||
System.out.println(" Got CRC response " + IoStream.printHexBinary(fResponse));
|
System.out.println(" Got CRC response " + IoStream.printByteArray(fResponse));
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkManager linkManager = new LinkManager();
|
LinkManager linkManager = new LinkManager();
|
||||||
|
@ -94,7 +96,7 @@ public class Elm327Sandbox {
|
||||||
byte[] fResponse = new byte[3];
|
byte[] fResponse = new byte[3];
|
||||||
dataBuffer.waitForBytes("hello", System.currentTimeMillis(), fResponse.length);
|
dataBuffer.waitForBytes("hello", System.currentTimeMillis(), fResponse.length);
|
||||||
dataBuffer.getData(fResponse);
|
dataBuffer.getData(fResponse);
|
||||||
System.out.println(prefix + " Got F response " + IoStream.printHexBinary(fResponse));
|
System.out.println(prefix + " Got F response " + IoStream.printByteArray(fResponse));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue