diff --git a/usbSerialForAndroid/src/androidTest/java/com/hoho/android/usbserial/util/UsbWrapper.java b/usbSerialForAndroid/src/androidTest/java/com/hoho/android/usbserial/util/UsbWrapper.java index 932bdb19..5bf114d7 100644 --- a/usbSerialForAndroid/src/androidTest/java/com/hoho/android/usbserial/util/UsbWrapper.java +++ b/usbSerialForAndroid/src/androidTest/java/com/hoho/android/usbserial/util/UsbWrapper.java @@ -12,6 +12,7 @@ import android.util.Log; import com.hoho.android.usbserial.driver.CdcAcmSerialDriver; +import com.hoho.android.usbserial.driver.CommonUsbSerialPort; import com.hoho.android.usbserial.driver.UsbSerialDriver; import com.hoho.android.usbserial.driver.UsbSerialPort; @@ -53,6 +54,7 @@ public UsbWrapper(Context context, UsbSerialDriver serialDriver, int devicePort) this.serialDriver = serialDriver; this.devicePort = devicePort; serialPort = serialDriver.getPorts().get(devicePort); + CommonUsbSerialPort.DEBUG = true; } public void setUp() throws Exception { diff --git a/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/driver/CommonUsbSerialPort.java b/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/driver/CommonUsbSerialPort.java index 278cc4de..fb601b07 100644 --- a/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/driver/CommonUsbSerialPort.java +++ b/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/driver/CommonUsbSerialPort.java @@ -26,6 +26,7 @@ public abstract class CommonUsbSerialPort implements UsbSerialPort { private static final String TAG = CommonUsbSerialPort.class.getSimpleName(); + public static boolean DEBUG = false; private static final int DEFAULT_WRITE_BUFFER_SIZE = 16 * 1024; private static final int MAX_READ_SIZE = 16 * 1024; // = old bulkTransfer limit @@ -238,7 +239,9 @@ public void write(final byte[] src, final int timeout) throws IOException { actualLength = mConnection.bulkTransfer(mWriteEndpoint, writeBuffer, requestLength, requestTimeout); } } - Log.d(TAG, "Wrote " + actualLength + "/" + requestLength + " offset " + offset + "/" + src.length + " timeout " + requestTimeout); + if (DEBUG) { + Log.d(TAG, "Wrote " + actualLength + "/" + requestLength + " offset " + offset + "/" + src.length + " timeout " + requestTimeout); + } if (actualLength <= 0) { if (timeout != 0 && MonotonicClock.millis() >= endTime) { SerialTimeoutException ex = new SerialTimeoutException("Error writing " + requestLength + " bytes at offset " + offset + " of total " + src.length + ", rc=" + actualLength); diff --git a/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/util/SerialInputOutputManager.java b/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/util/SerialInputOutputManager.java index 439b3dea..8e11e923 100644 --- a/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/util/SerialInputOutputManager.java +++ b/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/util/SerialInputOutputManager.java @@ -223,7 +223,9 @@ private void step() throws IOException { } int len = mSerialPort.read(buffer, mReadTimeout); if (len > 0) { - if (DEBUG) Log.d(TAG, "Read data len=" + len); + if (DEBUG) { + Log.d(TAG, "Read data len=" + len); + } final Listener listener = getListener(); if (listener != null) { final byte[] data = new byte[len];