Code example for UsbDeviceConnection

Methods: controlTransfer

0
 
        byte[] buffer = new byte[length];
        buffer[0] = 0x02; //Report ID = 2
        buffer[1] = 0x02; //Set the zero flag
 
        connection.controlTransfer(requestType, request, value, index, buffer, length, 2000);
    } 
 
    private String getUnitDisplayString(int unitConstant) {
        switch (unitConstant) {
            case UNITS_MILLIGRAM:
                return "Milligrams"; 
            case UNITS_GRAM:
                return "Grams"; 
            case UNITS_KILOGRAM:
                return "Kilograms"; 
            case UNITS_CARAT:
                return "Carats"; 
            case UNITS_TAEL:
                return "Taels"; 
            case UNITS_GRAIN: