From 5d91702272418bf5bfd76eb955fd2e8d752e1b76 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sat, 25 Jul 2020 15:37:42 -0400 Subject: [PATCH] helping Android --- android/app/src/main/java/com/rusefi/app/AndroidSerial.java | 2 +- java_console/io/src/main/java/com/rusefi/io/ByteReader.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/java/com/rusefi/app/AndroidSerial.java b/android/app/src/main/java/com/rusefi/app/AndroidSerial.java index 3d5e67bdd2..9ceafd107f 100644 --- a/android/app/src/main/java/com/rusefi/app/AndroidSerial.java +++ b/android/app/src/main/java/com/rusefi/app/AndroidSerial.java @@ -49,7 +49,7 @@ public class AndroidSerial extends AbstractIoStream { @Override public void setInputListener(DataListener listener) { ByteReader reader = buffer -> usbSerialPort.read(buffer, 5000); - ByteReader.runReaderLoop("", listener, reader, TcpIoStream.DisconnectListener.VOID); + ByteReader.runReaderLoop("", listener, reader, TcpIoStream.DisconnectListener.VOID, this); } @Override diff --git a/java_console/io/src/main/java/com/rusefi/io/ByteReader.java b/java_console/io/src/main/java/com/rusefi/io/ByteReader.java index 0bd04e5a0c..83968f5d53 100644 --- a/java_console/io/src/main/java/com/rusefi/io/ByteReader.java +++ b/java_console/io/src/main/java/com/rusefi/io/ByteReader.java @@ -4,6 +4,7 @@ import com.devexperts.logging.Logging; import com.opensr5.io.DataListener; import com.rusefi.NamedThreadFactory; import com.rusefi.config.generated.Fields; +import com.rusefi.io.serial.AbstractIoStream; import com.rusefi.io.tcp.TcpIoStream; import java.io.IOException; @@ -19,7 +20,7 @@ public interface ByteReader { Logging log = getLogging(ByteReader.class); - static void runReaderLoop(String loggingPrefix, DataListener listener, ByteReader reader, TcpIoStream.DisconnectListener disconnectListener, TcpIoStream tcpIoStream) { + static void runReaderLoop(String loggingPrefix, DataListener listener, ByteReader reader, TcpIoStream.DisconnectListener disconnectListener, AbstractIoStream ioStream) { /** * Threading of the whole input/output does not look healthy at all! * @@ -31,7 +32,7 @@ public interface ByteReader { log.info(loggingPrefix + "Running TCP connection loop"); byte inputBuffer[] = new byte[Fields.BLOCKING_FACTOR * 2]; - while (!tcpIoStream.isClosed()) { + while (!ioStream.isClosed()) { try { int result = reader.read(inputBuffer); if (result == -1)