tune via CAN #3361

sandbox progress
This commit is contained in:
rusefillc 2021-12-05 21:21:24 -05:00
parent dbb3de3618
commit 14a622160c
2 changed files with 25 additions and 3 deletions

View File

@ -82,7 +82,7 @@ public class BinaryProtocol {
private boolean isCompositeLoggerEnabled;
private long lastLowRpmTime = System.currentTimeMillis();
private List<StreamFile> compositeLogs = new ArrayList<>();
private final List<StreamFile> compositeLogs = new ArrayList<>();
public static boolean DISABLE_LOCAL_CACHE;
public static String findCommand(byte command) {

View File

@ -3,10 +3,13 @@ package com.rusefi.binaryprotocol.test;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.binaryprotocol.IncomingDataBuffer;
import com.rusefi.config.generated.Fields;
import com.rusefi.io.ConnectionStateListener;
import com.rusefi.io.IoStream;
import com.rusefi.io.LinkManager;
import com.rusefi.io.can.Elm327Connector;
import com.rusefi.io.serial.BaudRateHolder;
import com.rusefi.io.serial.SerialIoStream;
import com.rusefi.io.serial.StreamConnector;
import java.io.IOException;
@ -18,12 +21,12 @@ public class Elm327Sandbox {
BaudRateHolder.INSTANCE.baudRate = ELM327_DEFAULT_BAUDRATE;
String serialPort = "COM7";
Elm327Connector connector = new Elm327Connector(SerialIoStream.openPort(serialPort));
connector.start("sandbox");
connector.start(serialPort);
IoStream tsStream = connector.getTsStream();
IncomingDataBuffer dataBuffer = tsStream.getDataBuffer();
System.out.println("Hello new connection " + dataBuffer.getPendingCount());
System.out.println("Hello new ELM327 connection, pending=" + dataBuffer.getPendingCount());
runFcommand("First time", tsStream);
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
@ -34,6 +37,8 @@ public class Elm327Sandbox {
{
String signature = BinaryProtocol.getSignature(tsStream);
System.out.println("Got " + signature + " signature via CAN/ELM327");
if (signature == null)
return;
}
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
@ -41,6 +46,8 @@ public class Elm327Sandbox {
{
String signature = BinaryProtocol.getSignature(tsStream);
System.out.println("Let's do it again! Got " + signature + " signature via CAN/ELM327");
if (signature == null)
return;
}
Elm327Connector.whyDoWeNeedToSleepBetweenCommands();
@ -64,6 +71,21 @@ public class Elm327Sandbox {
System.out.println(" Got CRC response " + IoStream.printHexBinary(fResponse));
}
LinkManager linkManager = new LinkManager();
StreamConnector streamConnector = new StreamConnector(linkManager, () -> tsStream);
linkManager.setConnector(streamConnector);
streamConnector.connectAndReadConfiguration(new ConnectionStateListener() {
@Override
public void onConnectionEstablished() {
System.out.println("onConnectionEstablished");
}
@Override
public void onConnectionFailed() {
System.out.println("onConnectionFailed");
}
});
}
private static void runFcommand(String prefix, IoStream tsStream) throws IOException {