/**
* Performs a bulk transaction on the given endpoint.
* The direction of the transfer is determined by the direction of the endpoint.
*
* This method transfers data starting from index 0 in the buffer.
* To specify a different offset, use
* {@link #bulkTransfer(UsbEndpoint, byte[], int, int, int)}.
*
*
* @param endpoint the endpoint for this transaction
* @param buffer buffer for data to send or receive
* @param length the length of the data to send or receive
* @param timeout in milliseconds
* @return length of data transferred (or zero) for success,
* or negative value for failure
*/
public int bulkTransfer(UsbEndpoint endpoint, byte[] buffer, int length, int timeout);
mUsbInterface = mUsbDevice.getInterface(0); //设备的接口也需要在设备接口的描述符中获取
if(mUsbInterface == null)
return 2;
//从端点0
mInEndpoint = mUsbInterface.getEndpoint(0); //端点号,一般可以在HID设备的端点描述符中查到,并且可以确定输入输出端点号
if(mInEndpoint == null)
return 3;
//端点1
mOutEndpoint = mUsbInterface.getEndpoint(1);
if(mOutEndpoint == null)
return 4;
int outLength = mConnection.bulkTransfer(mOutEndpoint, outputStream, 64, timeOut);
int recLength = mConnection.bulkTransfer(mInEndpoint, inputStream, 64, timeOut);