console connectivity on specific Win11 device #3923

This commit is contained in:
rusefillc 2022-02-11 22:59:53 -05:00
parent 857c653bc2
commit 076960c419
3 changed files with 22 additions and 10 deletions

View File

@ -8,6 +8,7 @@ import com.rusefi.ConfigurationImageDiff;
import com.rusefi.NamedThreadFactory; import com.rusefi.NamedThreadFactory;
import com.rusefi.SignatureHelper; import com.rusefi.SignatureHelper;
import com.rusefi.Timeouts; import com.rusefi.Timeouts;
import com.rusefi.binaryprotocol.test.Bug3923;
import com.rusefi.config.generated.Fields; import com.rusefi.config.generated.Fields;
import com.rusefi.core.Pair; import com.rusefi.core.Pair;
import com.rusefi.core.SensorCentral; import com.rusefi.core.SensorCentral;
@ -422,7 +423,8 @@ public class BinaryProtocol {
try { try {
linkManager.assertCommunicationThread(); linkManager.assertCommunicationThread();
dropPending(); dropPending();
if (Bug3923.obscene)
log.info("Sending opcode " + opcode + " payload " + packet.length);
sendPacket(fullRequest); sendPacket(fullRequest);
return receivePacket(msg); return receivePacket(msg);
} catch (IOException e) { } catch (IOException e) {

View File

@ -10,6 +10,7 @@ import net.jcip.annotations.ThreadSafe;
import java.io.EOFException; import java.io.EOFException;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
import static com.devexperts.logging.Logging.getLogging; import static com.devexperts.logging.Logging.getLogging;
@ -53,8 +54,11 @@ public class IncomingDataBuffer {
*/ */
public byte[] getPacket(String msg, long start) throws EOFException { public byte[] getPacket(String msg, long start) throws EOFException {
boolean isTimeout = waitForBytes(msg + " header", start, 2); boolean isTimeout = waitForBytes(msg + " header", start, 2);
if (isTimeout) if (isTimeout) {
if (Bug3923.obscene)
log.info("Timeout waiting for header");
return null; return null;
}
int packetSize = swap16(getShort()); int packetSize = swap16(getShort());
// if (log.debugEnabled()) // if (log.debugEnabled())
@ -78,6 +82,8 @@ public class IncomingDataBuffer {
log.warn(errorMessage); log.warn(errorMessage);
return null; return null;
} }
if (Bug3923.obscene && packet.length < 10)
log.info("got packet: " + Arrays.toString(packet));
onPacketArrived(); onPacketArrived();
// if (log.debugEnabled()) // if (log.debugEnabled())
@ -100,7 +106,7 @@ public class IncomingDataBuffer {
cbb.notifyAll(); cbb.notifyAll();
} }
if (log.debugEnabled() || Bug3923.obscene) if (log.debugEnabled() || Bug3923.obscene)
log.debug(freshData.length + " byte(s) arrived, total " + cbb.length()); log.info(freshData.length + " byte(s) arrived, total " + cbb.length());
} }
/** /**
@ -165,8 +171,8 @@ public class IncomingDataBuffer {
streamStats.onArrived(2); streamStats.onArrived(2);
synchronized (cbb) { synchronized (cbb) {
int result = cbb.getShort(); int result = cbb.getShort();
if (log.debugEnabled()) if (log.debugEnabled() || Bug3923.obscene)
log.debug("Consumed some, " + cbb.length() + " remaining"); log.info("Consumed short, " + cbb.length() + " remaining");
return result; return result;
} }
} }
@ -174,13 +180,18 @@ public class IncomingDataBuffer {
public int getInt() throws EOFException { public int getInt() throws EOFException {
streamStats.onArrived(4); streamStats.onArrived(4);
synchronized (cbb) { synchronized (cbb) {
return cbb.getInt(); int result = cbb.getInt();
if (log.debugEnabled() || Bug3923.obscene)
log.info("Consumed int, " + cbb.length() + " remaining");
return result;
} }
} }
public void getData(byte[] packet) { public void getData(byte[] packet) {
synchronized (cbb) { synchronized (cbb) {
cbb.get(packet); cbb.get(packet);
if (log.debugEnabled() || Bug3923.obscene)
log.info(packet.length + " consumed, " + cbb.length() + " remaining");
} }
streamStats.onArrived(packet.length); streamStats.onArrived(packet.length);
} }

View File

@ -54,6 +54,8 @@ public class SerialIoStream extends AbstractIoStream {
@Override @Override
public void write(byte[] bytes) { public void write(byte[] bytes) {
if (Bug3923.obscene)
log.info("Writing " + bytes.length + " byte(s)");
sp.writeBytes(bytes, bytes.length); sp.writeBytes(bytes, bytes.length);
} }
@ -78,7 +80,7 @@ public class SerialIoStream extends AbstractIoStream {
@Override @Override
public void serialEvent(SerialPortEvent event) { public void serialEvent(SerialPortEvent event) {
if (Bug3923.obscene) if (Bug3923.obscene)
System.out.println("serialEvent " + event); log.info("serialEvent " + event);
if (event.getEventType() != SerialPort.LISTENING_EVENT_DATA_AVAILABLE) if (event.getEventType() != SerialPort.LISTENING_EVENT_DATA_AVAILABLE)
return; return;
if (isFirstEvent) { if (isFirstEvent) {
@ -96,10 +98,7 @@ public class SerialIoStream extends AbstractIoStream {
byte[] data = new byte[numRead]; byte[] data = new byte[numRead];
System.arraycopy(newData, 0, data, 0, numRead); System.arraycopy(newData, 0, data, 0, numRead);
listener.onDataArrived(data); listener.onDataArrived(data);
//System.out.println("Read " + numRead + " bytes.");
} }
}); });
} }
} }