Will Will - 1 year ago 218
Linux Question

Unable to claim interface: Resource busy

I am working with USB4Java (the low-level version) and am basically working from this code here.
I'm working in Ubuntu, and I was running into a problem about permissions but was able to resolve by running eclipse using gksu from the terminal.

Now I am having a new problem:
When I get to the point in the code here:

public static void claimDevice(DeviceHandle handle, int interfaceNum){
int r = LibUsb.claimInterface(handle, interfaceNum);

I'm getting an exception telling me that the "Resource is Busy":

USB error 6: Unable to claim interface: Resource busy

I've used Ubuntu before (but never for development so I'm really new to this).
If this isn't where this question should be handled then please tell me where to take it so I can get an answer.

Specifically, the question is, what does this mean and how can I resolve it?
My goal, in this case, this being a custom USB device, is to create a low-level cross-platform... java based... "driver" (using that term loosely). I'm working with Ubuntu right now because the terminal lsusb command gives a good amount of information on the device in question.

Answer Source

I was able (thanks to some coaxing) to find the answer by Google: For anyone else who comes across this error and doesn't want to dig, in the context with which I was working I was required to detach the interface from the kernel before I could claim it, like so:

public static void claimDevice(DeviceHandle handle, int interfaceNum){
    int r = LibUsb.detachKernelDriver(handle, interfaceNum);
    if (r != LibUsb.SUCCESS && 
        r != LibUsb.ERROR_NOT_SUPPORTED && 
        r != LibUsb.ERROR_NOT_FOUND) throw new LibUsbException("Unable to detach kernel     driver", r);

Hope this helps you too.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download