Code example for UsbDeviceConnection

Methods: closecontrolTransfer

    private static final int LENGTH = 64;
    private void getDeviceStatus(UsbDevice device) {
        UsbDeviceConnection connection = mUsbManager.openDevice(device);
        //Create a sufficiently large buffer for incoming data 
        byte[] buffer = new byte[LENGTH];
        connection.controlTransfer(REQUEST_TYPE, REQUEST, REQ_VALUE, REQ_INDEX,
                buffer, LENGTH, 2000);
        //Parse received data into a description 
        String description = parseConfigDescriptor(buffer);
     * Parse the USB configuration descriptor response per the 
     * USB Specification.  Return a printable description of 
     * the connected device. 
    private static final int DESC_SIZE_CONFIG = 9;
    private String parseConfigDescriptor(byte[] buffer) {