mirror of
				https://github.com/mik3y/usb-serial-for-android
				synced 2025-10-31 02:17:23 +00:00 
			
		
		
		
	harmonize controlTransfer() result comparison
This commit is contained in:
		
							parent
							
								
									26a2f9363e
								
							
						
					
					
						commit
						1245293888
					
				| @ -118,7 +118,7 @@ public class Cp21xxSerialDriver implements UsbSerialDriver { | |||||||
|             byte[] buffer = new byte[1]; |             byte[] buffer = new byte[1]; | ||||||
|             int result = mConnection.controlTransfer(REQTYPE_DEVICE_TO_HOST, SILABSER_GET_MDMSTS_REQUEST_CODE, 0, |             int result = mConnection.controlTransfer(REQTYPE_DEVICE_TO_HOST, SILABSER_GET_MDMSTS_REQUEST_CODE, 0, | ||||||
|                     mPortNumber, buffer, buffer.length, USB_WRITE_TIMEOUT_MILLIS); |                     mPortNumber, buffer, buffer.length, USB_WRITE_TIMEOUT_MILLIS); | ||||||
|             if (result != 1) { |             if (result != buffer.length) { | ||||||
|                 throw new IOException("Control transfer failed: " + SILABSER_GET_MDMSTS_REQUEST_CODE + " / " + 0 + " -> " + result); |                 throw new IOException("Control transfer failed: " + SILABSER_GET_MDMSTS_REQUEST_CODE + " / " + 0 + " -> " + result); | ||||||
|             } |             } | ||||||
|             return buffer[0]; |             return buffer[0]; | ||||||
|  | |||||||
| @ -303,7 +303,7 @@ public class FtdiSerialDriver implements UsbSerialDriver { | |||||||
|             byte[] data = new byte[2]; |             byte[] data = new byte[2]; | ||||||
|             int result = mConnection.controlTransfer(REQTYPE_DEVICE_TO_HOST, GET_MODEM_STATUS_REQUEST, |             int result = mConnection.controlTransfer(REQTYPE_DEVICE_TO_HOST, GET_MODEM_STATUS_REQUEST, | ||||||
|                     0, mPortNumber+1, data, data.length, USB_WRITE_TIMEOUT_MILLIS); |                     0, mPortNumber+1, data, data.length, USB_WRITE_TIMEOUT_MILLIS); | ||||||
|             if (result != 2) { |             if (result != data.length) { | ||||||
|                 throw new IOException("Get modem status failed: result=" + result); |                 throw new IOException("Get modem status failed: result=" + result); | ||||||
|             } |             } | ||||||
|             return data[0]; |             return data[0]; | ||||||
| @ -419,7 +419,7 @@ public class FtdiSerialDriver implements UsbSerialDriver { | |||||||
|             byte[] data = new byte[1]; |             byte[] data = new byte[1]; | ||||||
|             int result = mConnection.controlTransfer(REQTYPE_DEVICE_TO_HOST, GET_LATENCY_TIMER_REQUEST, |             int result = mConnection.controlTransfer(REQTYPE_DEVICE_TO_HOST, GET_LATENCY_TIMER_REQUEST, | ||||||
|                     0, mPortNumber+1, data, data.length, USB_WRITE_TIMEOUT_MILLIS); |                     0, mPortNumber+1, data, data.length, USB_WRITE_TIMEOUT_MILLIS); | ||||||
|             if (result != 1) { |             if (result != data.length) { | ||||||
|                 throw new IOException("Get latency timer failed: result=" + result); |                 throw new IOException("Get latency timer failed: result=" + result); | ||||||
|             } |             } | ||||||
|             return data[0]; |             return data[0]; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user