I am super confused :( looks great with signature
This commit is contained in:
parent
65e2b2a2c0
commit
31c7172f68
|
@ -3,13 +3,10 @@ package com.rusefi.binaryprotocol.test;
|
||||||
import com.rusefi.binaryprotocol.BinaryProtocol;
|
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.ConnectionStateListener;
|
|
||||||
import com.rusefi.io.IoStream;
|
import com.rusefi.io.IoStream;
|
||||||
import com.rusefi.io.LinkManager;
|
|
||||||
import com.rusefi.io.can.Elm327Connector;
|
import com.rusefi.io.can.Elm327Connector;
|
||||||
import com.rusefi.io.serial.BaudRateHolder;
|
import com.rusefi.io.serial.BaudRateHolder;
|
||||||
import com.rusefi.io.serial.SerialIoStream;
|
import com.rusefi.io.serial.SerialIoStream;
|
||||||
import com.rusefi.io.serial.StreamConnector;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -30,17 +27,18 @@ public class Elm327Sandbox {
|
||||||
IncomingDataBuffer dataBuffer = tsStream.getDataBuffer();
|
IncomingDataBuffer dataBuffer = tsStream.getDataBuffer();
|
||||||
System.out.println("Hello new ELM327 connection, pending=" + dataBuffer.getPendingCount());
|
System.out.println("Hello new ELM327 connection, pending=" + dataBuffer.getPendingCount());
|
||||||
|
|
||||||
|
/*
|
||||||
runFcommand("First time", tsStream);
|
runFcommand("First time", tsStream);
|
||||||
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
||||||
|
|
||||||
runFcommand("Second time", tsStream);
|
runFcommand("Second time", tsStream);
|
||||||
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
String signature = BinaryProtocol.getSignature(tsStream);
|
String signature = BinaryProtocol.getSignature(tsStream);
|
||||||
System.out.println("Got " + signature + " signature via CAN/ELM327");
|
System.out.println("Got " + signature + " signature via CAN/ELM327");
|
||||||
if (signature == null)
|
if (signature == null || !signature.startsWith(Fields.PROTOCOL_SIGNATURE_PREFIX))
|
||||||
return;
|
throw new IllegalStateException("Unexpected S " + signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
||||||
|
@ -48,8 +46,8 @@ public class Elm327Sandbox {
|
||||||
{
|
{
|
||||||
String signature = BinaryProtocol.getSignature(tsStream);
|
String signature = BinaryProtocol.getSignature(tsStream);
|
||||||
System.out.println("Let's do it again! Got " + signature + " signature via CAN/ELM327");
|
System.out.println("Let's do it again! Got " + signature + " signature via CAN/ELM327");
|
||||||
if (signature == null)
|
if (signature == null || !signature.startsWith(Fields.PROTOCOL_SIGNATURE_PREFIX))
|
||||||
return;
|
throw new IllegalStateException("Unexpected S " + signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
||||||
|
@ -61,10 +59,18 @@ public class Elm327Sandbox {
|
||||||
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);
|
||||||
|
|
||||||
|
if (!signature.startsWith(Fields.PROTOCOL_SIGNATURE_PREFIX))
|
||||||
|
throw new IllegalStateException("Unexpected S " + signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
|
||||||
|
System.out.println("***********************************");
|
||||||
|
System.out.println("***** LOOKS GREAT ************");
|
||||||
|
System.out.println("***********************************");
|
||||||
|
System.exit(-1);
|
||||||
|
|
||||||
|
/*
|
||||||
{
|
{
|
||||||
tsStream.sendPacket(BinaryProtocol.createCrcCommand(1000));
|
tsStream.sendPacket(BinaryProtocol.createCrcCommand(1000));
|
||||||
byte[] fResponse = new byte[3];
|
byte[] fResponse = new byte[3];
|
||||||
|
@ -87,7 +93,7 @@ public class Elm327Sandbox {
|
||||||
System.out.println("onConnectionFailed");
|
System.out.println("onConnectionFailed");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void runFcommand(String prefix, IoStream tsStream) throws IOException {
|
private static void runFcommand(String prefix, IoStream tsStream) throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue