Code example for UsbDeviceConnection

Methods: bulkTransfer

0
    @Override 
    protected int ioRead(byte[] buffer, int offset, int count) throws IOException {
        if (mConnection == null) {
            throw new IOException("Connection was closed.");
        } 
        return mConnection.bulkTransfer(mBulkInEndpoint, buffer, offset, count, -1);
    } 
 
    @Override 
    protected void ioWrite(byte[] buffer, int offset, int count) throws IOException {
        if (mConnection == null) {
            throw new IOException("Connection was closed.");
        } 
        int result = mConnection.bulkTransfer(mBulkOutEndpoint,
                buffer, offset, count, TIMEOUT_MILLIS);
        if (result < 0) {
            throw new IOException("Bulk transfer failed.");
        } 
    } 
}