7

I've searched for hours with no avail. I've seen it everywhere that libusb_detach_kernel_driver isn't supported on Mac OS X, but I haven't been able to find a patch or alternative for it.

libusb_claim_interface returns this: libusb: 0.863377 error [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access

How can I detach the USB device from the kernel?

George Morgan
  • 669
  • 10
  • 23
  • Hi George! Have you ever found a solution for this? I'm having the same USBInterfaceOpen error on Mac OS X, Mavericks. No matter what I try, I can't claim my CDC device's interface. – josef.van.niekerk Nov 27 '13 at 21:11
  • Unfortunately I have not. If you figure something out, please let us know here! – George Morgan Nov 28 '13 at 22:00
  • The closest solution I got is someone telling me to write my own .kext driver file. Also, you might find some help on my StackOverflow question here: http://stackoverflow.com/questions/20253350/unable-to-claim-usb-interface-with-c-libusb-on-mac-os-x Best way is to try the serial communication route, which I'm trying out here: http://www.microchip.com/forums/tm.aspx?high=&m=762247&mpage=1#762269 – josef.van.niekerk Nov 29 '13 at 05:23
  • Yeah, that's exactly what I ended up doing. If you write that `kext`, let me know. If you need some help, maybe we could figure something out. – George Morgan Nov 30 '13 at 05:56

1 Answers1

3

Many devices automatically have a driver attached to the USB device they are recognised as by OSX and you will not be able to claim the device unless you force the system to detach the device manually before you can run your code and claim the device. If for example it attached the AppleUSBCDC device to some unique usb device you plugged in you'd have to do:

sudo kextunload -b com.apple.driver.AppleUSBCDC

before running your application which tries to claim the interface.

ckolivas
  • 128
  • 7
  • In my case it was `sudo kextunload -b com.apple.driver.AppleUSBFTDI` that fixed the problem. Is there any way to know which driver is actually holding the device? – Ákos Vandra-Meyer Sep 19 '15 at 06:21
  • I am playing with an arduino nano and wanted to talk to the usb via an android emulator on my mac. Got the same sort of error and found the OS had attached the nano as an FTDI device, so: sudo kextunload -b com.apple.driver.AppleUSBFTDI worked for me. – Eurospoofer Mar 18 '18 at 21:03
  • For macOS Mojave: `sudo kextunload -b com.apple.driver.usb.cdc.acm` – Gamadril Dec 18 '18 at 06:30
  • 1
    None of above extensions were found on Mojave 10.14.6 (18G87) – Vadim Filin Mar 12 '20 at 16:39
  • This is one of three methods discussed in the libusb docs now: https://github.com/libusb/libusb/wiki/FAQ#How_can_I_run_libusb_applications_under_Mac_OS_X_if_there_is_already_a_kernel_extension_installed_for_the_device – Matt May 03 '20 at 22:15