mirror of
				https://github.com/mik3y/usb-serial-for-android
				synced 2025-10-30 18:07:21 +00:00 
			
		
		
		
	more configurable debug log, disabled by default (#389)
This commit is contained in:
		
							parent
							
								
									d319879386
								
							
						
					
					
						commit
						76f9198c02
					
				| @ -12,6 +12,7 @@ import android.net.Uri; | ||||
| 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 class UsbWrapper implements SerialInputOutputManager.Listener { | ||||
|         this.serialDriver = serialDriver; | ||||
|         this.devicePort = devicePort; | ||||
|         serialPort = serialDriver.getPorts().get(devicePort); | ||||
|         CommonUsbSerialPort.DEBUG = true; | ||||
|     } | ||||
| 
 | ||||
|     public void setUp() throws Exception { | ||||
|  | ||||
| @ -26,6 +26,7 @@ import java.util.EnumSet; | ||||
| 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 abstract class CommonUsbSerialPort implements UsbSerialPort { | ||||
|                     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); | ||||
|  | ||||
| @ -223,7 +223,9 @@ public class SerialInputOutputManager implements Runnable { | ||||
|         } | ||||
|         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]; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user