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