console connectivity on specific Win11 device #3923
This commit is contained in:
parent
857c653bc2
commit
076960c419
|
@ -8,6 +8,7 @@ import com.rusefi.ConfigurationImageDiff;
|
|||
import com.rusefi.NamedThreadFactory;
|
||||
import com.rusefi.SignatureHelper;
|
||||
import com.rusefi.Timeouts;
|
||||
import com.rusefi.binaryprotocol.test.Bug3923;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
import com.rusefi.core.Pair;
|
||||
import com.rusefi.core.SensorCentral;
|
||||
|
@ -422,7 +423,8 @@ public class BinaryProtocol {
|
|||
try {
|
||||
linkManager.assertCommunicationThread();
|
||||
dropPending();
|
||||
|
||||
if (Bug3923.obscene)
|
||||
log.info("Sending opcode " + opcode + " payload " + packet.length);
|
||||
sendPacket(fullRequest);
|
||||
return receivePacket(msg);
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.jcip.annotations.ThreadSafe;
|
|||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.devexperts.logging.Logging.getLogging;
|
||||
|
@ -53,8 +54,11 @@ public class IncomingDataBuffer {
|
|||
*/
|
||||
public byte[] getPacket(String msg, long start) throws EOFException {
|
||||
boolean isTimeout = waitForBytes(msg + " header", start, 2);
|
||||
if (isTimeout)
|
||||
if (isTimeout) {
|
||||
if (Bug3923.obscene)
|
||||
log.info("Timeout waiting for header");
|
||||
return null;
|
||||
}
|
||||
|
||||
int packetSize = swap16(getShort());
|
||||
// if (log.debugEnabled())
|
||||
|
@ -78,6 +82,8 @@ public class IncomingDataBuffer {
|
|||
log.warn(errorMessage);
|
||||
return null;
|
||||
}
|
||||
if (Bug3923.obscene && packet.length < 10)
|
||||
log.info("got packet: " + Arrays.toString(packet));
|
||||
|
||||
onPacketArrived();
|
||||
// if (log.debugEnabled())
|
||||
|
@ -100,7 +106,7 @@ public class IncomingDataBuffer {
|
|||
cbb.notifyAll();
|
||||
}
|
||||
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);
|
||||
synchronized (cbb) {
|
||||
int result = cbb.getShort();
|
||||
if (log.debugEnabled())
|
||||
log.debug("Consumed some, " + cbb.length() + " remaining");
|
||||
if (log.debugEnabled() || Bug3923.obscene)
|
||||
log.info("Consumed short, " + cbb.length() + " remaining");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -174,13 +180,18 @@ public class IncomingDataBuffer {
|
|||
public int getInt() throws EOFException {
|
||||
streamStats.onArrived(4);
|
||||
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) {
|
||||
synchronized (cbb) {
|
||||
cbb.get(packet);
|
||||
if (log.debugEnabled() || Bug3923.obscene)
|
||||
log.info(packet.length + " consumed, " + cbb.length() + " remaining");
|
||||
}
|
||||
streamStats.onArrived(packet.length);
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ public class SerialIoStream extends AbstractIoStream {
|
|||
|
||||
@Override
|
||||
public void write(byte[] bytes) {
|
||||
if (Bug3923.obscene)
|
||||
log.info("Writing " + bytes.length + " byte(s)");
|
||||
sp.writeBytes(bytes, bytes.length);
|
||||
}
|
||||
|
||||
|
@ -78,7 +80,7 @@ public class SerialIoStream extends AbstractIoStream {
|
|||
@Override
|
||||
public void serialEvent(SerialPortEvent event) {
|
||||
if (Bug3923.obscene)
|
||||
System.out.println("serialEvent " + event);
|
||||
log.info("serialEvent " + event);
|
||||
if (event.getEventType() != SerialPort.LISTENING_EVENT_DATA_AVAILABLE)
|
||||
return;
|
||||
if (isFirstEvent) {
|
||||
|
@ -96,10 +98,7 @@ public class SerialIoStream extends AbstractIoStream {
|
|||
byte[] data = new byte[numRead];
|
||||
System.arraycopy(newData, 0, data, 0, numRead);
|
||||
listener.onDataArrived(data);
|
||||
//System.out.println("Read " + numRead + " bytes.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue