When called by an OBD connection, handle a null stopRequest gracefully

This commit is contained in:
Dale Schultz 2021-12-30 12:53:56 -05:00
parent 908ca238e0
commit 6ad0f4357a
No known key found for this signature in database
GPG Key ID: EA2C8AD6CB5C2AF2
1 changed files with 9 additions and 7 deletions

View File

@ -55,7 +55,7 @@ public final class J2534ConnectionISO15765 implements ConnectionManager {
@Override
public void open(byte[] start, byte[] stop) {
checkNotNull(start, "start");
checkNotNull(start, "stop");
checkNotNull(stop, "stop");
this.stopRequest = stop;
LOGGER.debug(String.format("Start Diagnostics Request ---> %s",
asHex(start)));
@ -94,12 +94,14 @@ public final class J2534ConnectionISO15765 implements ConnectionManager {
@Override
public void close() {
LOGGER.debug(String.format("Stop Diagnostics Request ---> %s",
asHex(stopRequest)));
api.writeMsg(channelId, stopRequest, timeout, TxFlags.ISO15765_FRAME_PAD);
final byte[] response = api.readMsg(channelId, 1, timeout);
LOGGER.debug(String.format("Stop Diagnostics Response <--- %s",
asHex(response)));
if (stopRequest != null) { // OBD has no open or close procedure
LOGGER.debug(String.format("Stop Diagnostics Request ---> %s",
asHex(stopRequest)));
api.writeMsg(channelId, stopRequest, timeout, TxFlags.ISO15765_FRAME_PAD);
final byte[] response = api.readMsg(channelId, 1, timeout);
LOGGER.debug(String.format("Stop Diagnostics Response <--- %s",
asHex(response)));
}
stopFcFilter();
disconnectChannel();
closeDevice();