refactoring

This commit is contained in:
rusefillc 2021-12-06 22:53:17 -05:00
parent d23b029b5c
commit ad55620c86
2 changed files with 14 additions and 10 deletions

View File

@ -84,14 +84,4 @@ public class Elm327Sandbox {
*/
}
private static void runFcommand(String prefix, IoStream tsStream) throws IOException {
IncomingDataBuffer dataBuffer = tsStream.getDataBuffer();
tsStream.write(new byte[]{Fields.TS_COMMAND_F});
tsStream.flush();
byte[] fResponse = new byte[3];
dataBuffer.waitForBytes("hello", System.currentTimeMillis(), fResponse.length);
dataBuffer.getData(fResponse);
System.out.println(prefix + " Got F response " + IoStream.printByteArray(fResponse));
}
}

View File

@ -3,6 +3,7 @@ package com.rusefi.binaryprotocol.test;
import com.opensr5.ConfigurationImage;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.binaryprotocol.BinaryProtocolState;
import com.rusefi.binaryprotocol.IncomingDataBuffer;
import com.rusefi.config.generated.Fields;
import com.rusefi.io.ConnectionStateListener;
import com.rusefi.io.IoStream;
@ -10,6 +11,7 @@ import com.rusefi.io.LinkManager;
import com.rusefi.io.serial.StreamConnector;
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
@ -68,4 +70,16 @@ public class SandboxCommon {
if (signature == null || !signature.startsWith(Fields.PROTOCOL_SIGNATURE_PREFIX))
throw new IllegalStateException("Unexpected S " + signature);
}
static void runFcommand(String prefix, IoStream tsStream) throws IOException {
IncomingDataBuffer dataBuffer = tsStream.getDataBuffer();
tsStream.write(new byte[]{Fields.TS_COMMAND_F});
tsStream.flush();
byte[] fResponse = new byte[3];
dataBuffer.waitForBytes("hello", System.currentTimeMillis(), fResponse.length);
dataBuffer.getData(fResponse);
System.out.println(prefix + " Got F response " + IoStream.printByteArray(fResponse));
if (fResponse[0] != '0' || fResponse[1] != '0' || fResponse[2] != '1')
throw new IllegalStateException("Unexpected TS_COMMAND_F response " + Arrays.toString(fResponse));
}
}