refactoring
This commit is contained in:
parent
34b34bbe4a
commit
9774c74f42
|
@ -40,7 +40,7 @@ public class SerialAutoChecker implements Runnable {
|
||||||
IncomingDataBuffer incomingData = stream.getDataBuffer();
|
IncomingDataBuffer incomingData = stream.getDataBuffer();
|
||||||
try {
|
try {
|
||||||
HelloCommand.send(stream);
|
HelloCommand.send(stream);
|
||||||
byte[] response = incomingData.getPacket("", false);
|
byte[] response = incomingData.getPacket("");
|
||||||
if (!checkResponseCode(response, BinaryProtocolCommands.RESPONSE_OK))
|
if (!checkResponseCode(response, BinaryProtocolCommands.RESPONSE_OK))
|
||||||
return;
|
return;
|
||||||
String signature = new String(response, 1, response.length - 1);
|
String signature = new String(response, 1, response.length - 1);
|
||||||
|
|
|
@ -46,6 +46,10 @@ public class IncomingDataBuffer {
|
||||||
return incomingData;
|
return incomingData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] getPacket(String msg) throws EOFException {
|
||||||
|
return getPacket(msg, false, System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] getPacket(String msg, boolean allowLongResponse) throws EOFException {
|
public byte[] getPacket(String msg, boolean allowLongResponse) throws EOFException {
|
||||||
return getPacket(msg, allowLongResponse, System.currentTimeMillis());
|
return getPacket(msg, allowLongResponse, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class HelloCommand implements Command {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String getHelloResponse(IncomingDataBuffer incomingData) throws EOFException {
|
public static String getHelloResponse(IncomingDataBuffer incomingData) throws EOFException {
|
||||||
byte[] response = incomingData.getPacket("[hello]", false);
|
byte[] response = incomingData.getPacket("[hello]");
|
||||||
if (!checkResponseCode(response, BinaryProtocolCommands.RESPONSE_OK))
|
if (!checkResponseCode(response, BinaryProtocolCommands.RESPONSE_OK))
|
||||||
return null;
|
return null;
|
||||||
return new String(response, 1, response.length - 1);
|
return new String(response, 1, response.length - 1);
|
||||||
|
|
|
@ -34,6 +34,7 @@ import static com.rusefi.config.generated.Fields.*;
|
||||||
* This class makes rusEfi console a proxy for other tuning software, this way we can have two tools connected via same
|
* This class makes rusEfi console a proxy for other tuning software, this way we can have two tools connected via same
|
||||||
* serial port simultaneously
|
* serial port simultaneously
|
||||||
*
|
*
|
||||||
|
* See BinaryProtocolServerSandbox
|
||||||
* @author Andrey Belomutskiy
|
* @author Andrey Belomutskiy
|
||||||
* 11/24/15
|
* 11/24/15
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue