refactoring
This commit is contained in:
parent
97675bd89d
commit
f4a0da5cf1
|
@ -1,6 +1,5 @@
|
||||||
package com.rusefi.binaryprotocol.test;
|
package com.rusefi.binaryprotocol.test;
|
||||||
|
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
|
||||||
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
||||||
import com.rusefi.config.generated.Fields;
|
import com.rusefi.config.generated.Fields;
|
||||||
import com.rusefi.io.IoStream;
|
import com.rusefi.io.IoStream;
|
||||||
|
@ -34,22 +33,11 @@ public class Elm327Sandbox {
|
||||||
runFcommand("Second time", tsStream);
|
runFcommand("Second time", tsStream);
|
||||||
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
||||||
*/
|
*/
|
||||||
{
|
|
||||||
String signature = BinaryProtocol.getSignature(tsStream);
|
|
||||||
System.out.println("Got " + signature + " signature via CAN/ELM327");
|
|
||||||
if (signature == null || !signature.startsWith(Fields.PROTOCOL_SIGNATURE_PREFIX))
|
|
||||||
throw new IllegalStateException("Unexpected S " + signature);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
SandboxCommon.verifySignature(tsStream, "", "ELM");
|
||||||
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
||||||
|
|
||||||
{
|
SandboxCommon.verifySignature(tsStream, "Let's do it again! ", "ELM");
|
||||||
String signature = BinaryProtocol.getSignature(tsStream);
|
|
||||||
System.out.println("Let's do it again! Got " + signature + " signature via CAN/ELM327");
|
|
||||||
if (signature == null || !signature.startsWith(Fields.PROTOCOL_SIGNATURE_PREFIX))
|
|
||||||
throw new IllegalStateException("Unexpected S " + signature);
|
|
||||||
}
|
|
||||||
|
|
||||||
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.rusefi.io.IoStream;
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
import com.rusefi.io.serial.StreamConnector;
|
import com.rusefi.io.serial.StreamConnector;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
@ -60,4 +61,11 @@ public class SandboxCommon {
|
||||||
System.out.println("ERROR Extra data after CRC");
|
System.out.println("ERROR Extra data after CRC");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void verifySignature(IoStream tsStream, String prefix, String suffix) throws IOException {
|
||||||
|
String signature = BinaryProtocol.getSignature(tsStream);
|
||||||
|
System.out.println(prefix + "Got " + signature + " signature via " + suffix);
|
||||||
|
if (signature == null || !signature.startsWith(Fields.PROTOCOL_SIGNATURE_PREFIX))
|
||||||
|
throw new IllegalStateException("Unexpected S " + signature);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue