only:code duplication
This commit is contained in:
parent
faaabd5e2b
commit
1dc0cab4a9
|
@ -46,7 +46,7 @@ public class SerialAutoChecker {
|
|||
try {
|
||||
HelloCommand.send(stream);
|
||||
byte[] response = incomingData.getPacket("auto detect");
|
||||
if (!checkResponseCode(response, (byte) Fields.TS_RESPONSE_OK))
|
||||
if (!checkResponseCode(response))
|
||||
return null;
|
||||
String signature = new String(response, 1, response.length - 1);
|
||||
if (!signature.startsWith(Fields.PROTOCOL_SIGNATURE_PREFIX)) {
|
||||
|
|
|
@ -30,7 +30,7 @@ public class HelloCommand implements Command {
|
|||
@Nullable
|
||||
public static String getStringResponse(String msg, IncomingDataBuffer incomingData) throws EOFException {
|
||||
byte[] response = incomingData.getPacket(msg);
|
||||
if (!checkResponseCode(response, (byte) Fields.TS_RESPONSE_OK))
|
||||
if (!checkResponseCode(response))
|
||||
return null;
|
||||
return new String(response, 1, response.length - 1);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class Elm327Sandbox {
|
|||
{
|
||||
tsStream.sendPacket(new byte[]{Fields.TS_HELLO_COMMAND});
|
||||
byte[] response = dataBuffer.getPacket("[hello command]");
|
||||
if (!checkResponseCode(response, (byte) Fields.TS_RESPONSE_OK))
|
||||
if (!checkResponseCode(response))
|
||||
return;
|
||||
String signature = new String(response, 1, response.length - 1);
|
||||
System.out.println(Fields.TS_HELLO_COMMAND + " returned " + signature);
|
||||
|
|
Loading…
Reference in New Issue