mirror of
				https://github.com/mik3y/usb-serial-for-android
				synced 2025-10-31 10:27:27 +00:00 
			
		
		
		
	cdc: Special case read timout == Integer.MAX_VALUE.
Some systems return 0 from read() when the device has been disconnected. The only way to detect this is to 'never' expect a timeout.
This commit is contained in:
		
							parent
							
								
									8e8ded4a9c
								
							
						
					
					
						commit
						6ef85d04c1
					
				| @ -30,8 +30,6 @@ import android.hardware.usb.UsbRequest; | ||||
| import android.os.Build; | ||||
| import android.util.Log; | ||||
| 
 | ||||
| import com.hoho.android.usbserial.util.HexDump; | ||||
| 
 | ||||
| import java.io.IOException; | ||||
| import java.nio.ByteBuffer; | ||||
| import java.util.Collections; | ||||
| @ -197,6 +195,10 @@ public class CdcAcmSerialDriver implements UsbSerialDriver { | ||||
|                     // We *should* use UsbRequest, except it has a bug/api oversight | ||||
|                     // where there is no way to determine the number of bytes read | ||||
|                     // in response :\ -- http://b.android.com/28023 | ||||
|                     if (timeoutMillis == Integer.MAX_VALUE) { | ||||
|                         // Hack: Special case "~infinite timeout" as an error. | ||||
|                         return -1; | ||||
|                     } | ||||
|                     return 0; | ||||
|                 } | ||||
|                 System.arraycopy(mReadBuffer, 0, dest, 0, numBytesRead); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user