parent
5c1e3a2536
commit
a03c220629
|
@ -63,10 +63,11 @@ public class Elm327Connector implements Closeable {
|
|||
return tsStream;
|
||||
}
|
||||
|
||||
public void start(String msg) {
|
||||
public boolean start(String msg) {
|
||||
log.info("* Elm327.start()");
|
||||
|
||||
if (initConnection(msg)) {
|
||||
boolean initConnection = initConnection(msg);
|
||||
if (initConnection) {
|
||||
// reset to defaults
|
||||
sendCommand("ATD", "OK");
|
||||
|
||||
|
@ -109,7 +110,7 @@ public class Elm327Connector implements Closeable {
|
|||
String voltage = sendCommand("ATRV", "([0-9\\.]+)V");
|
||||
log.info("* Ignition voltage = " + voltage);
|
||||
}
|
||||
|
||||
return initConnection;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -69,7 +69,7 @@ public class IsoTpCanDecoder {
|
|||
}
|
||||
byte[] bytes = Arrays.copyOfRange(data, dataOffset, dataOffset + numBytesAvailable);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,9 @@ public class Elm327Sandbox {
|
|||
BaudRateHolder.INSTANCE.baudRate = ELM327_DEFAULT_BAUDRATE;
|
||||
String serialPort = "COM7";
|
||||
Elm327Connector connector = new Elm327Connector(SerialIoStream.openPort(serialPort));
|
||||
connector.start(serialPort);
|
||||
boolean initConnection = connector.start(serialPort);
|
||||
if (!initConnection)
|
||||
return;
|
||||
|
||||
IoStream tsStream = connector.getTsStream();
|
||||
|
||||
|
@ -68,7 +70,7 @@ public class Elm327Sandbox {
|
|||
byte[] fResponse = new byte[3];
|
||||
dataBuffer.waitForBytes("CRC", System.currentTimeMillis(), fResponse.length);
|
||||
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();
|
||||
|
@ -94,7 +96,7 @@ public class Elm327Sandbox {
|
|||
byte[] fResponse = new byte[3];
|
||||
dataBuffer.waitForBytes("hello", System.currentTimeMillis(), fResponse.length);
|
||||
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