Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to recover from a stall in chrome.usb?

I'm sending an out bulk transfer, and I stall it in the device (I write the code on both end of the cable) to abort the action. I'm sending a home-made control transfert SET_FEATURE ENDPOINT_HALT to the endpoint and when the abort is complete, I follow up with a CLEAR_FEATURE ENDPOINT_HALT to recover the endpoint and use it again. In the embedded debugger I can confirm it has been cleared in the device. But in the browser, any subsequent transfer on the endpoint will end up with the very unhelpful "Transfer failed" message (code 1).

if (errorCode == 4) {
    var ENDPOINT_HALT = 0;
    var CLEAR_FEATURE = 0x01;
    controlTransfer(currentDevice, {direction: 'out', recipient: 'endpoint', requestType: 'standard',
    request: CLEAR_FEATURE, value: ENDPOINT_HALT, index: 1, data: new ArrayBuffer(0)}, genericErrorFilter());
}

From what I found on the Internet, libusb has a special function for clearing a stall on the host side, to tell the kernel that the endpoint has been recovered, and it should reflect that in its internal structures. This function is not exposed in chrome.usb.

Is there a way to recover from a stall in Chrome? Or is there an alternative recoverable way from the device to stop an ongoing out bulk transfer?

I'm using Mac OS X and Chrome Canary.

like image 660
nraynaud Avatar asked Dec 17 '13 23:12

nraynaud


1 Answers

You can try a interruptTransfer on your catched stall message

chrome.experimental.usb.interruptTransfer(integer device,
string direction,
integer endpoint,
string data,
function callback)
like image 160
RecycleRobot Avatar answered Nov 14 '22 10:11

RecycleRobot