Gaurav Gupta
Gaurav Gupta

Reputation: 4691

Timeout Error (errno: 2) while reading data from usb

I am getting LIBUSB_TRANSFER_TIMED_OUT error (errcode: 2) when trying to read data from usb. I am using this module.

function onUsbAttached(device) {
    console.log('you gotta usb.\n');
    device.open();  // open the device. 
    // console.log(device.interfaces);
    var syncInterface = device.interfaces[0];   // sync interface
    var asyncInterface = device.interfaces[1];  // async interface
    // console.log('incomingEndpoint', incomingEndpoint);
    if(syncInterface.isKernelDriverActive()){
        console.log('Kernel driver is active. Detaching kernel driver.');
        syncInterface.detachKernelDriver();
    }
    console.log('Claiming interface');
    syncInterface.claim();

    var INendpoint = syncInterface.endpoints[0];
    var OUTendpoint = syncInterface.endpoints[1];

    // .controlTransfer(bmRequestType, bRequest, wValue, wIndex, data_or_length, callback(error, data))
    device.controlTransfer(0xC0, 0x32, 0, 0, 1, function (err, data) {
        if(err){
            console.log('Error while getting data', err);
            return ;
        }
        console.log('Got some data.', data);
    });
};

If someone can point out my mistake then it would be great !!

Upvotes: 1

Views: 370

Answers (0)

Related Questions