Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jthemis

macrumors newbie
Original poster
Jun 22, 2018
4
0
USA
I have been unable to figure out why the call UsbDeviceOpen() returns kIOReturnExclusiveAccess after I unplug and replug.

Design: 1. On thread running the CFRunLoop() that detects the adds/removes of devices 2. 2nd Thread that does the Async reads and writes.

When thread 1 receives the kIOMessageServiceIsTerminated event, I AbortPipe(), USBInterfaceClose(), Interface->Release(), USBDeviceClose(), DeviceInterface->Release() and IOObectRelease(notification).

All calls returns kIOReturnSuccess except the USBDeviceClose(). It returns kIOReturnNoDevice. This makes sense because the device has been removed. But when I replug, the OS still seems to think a thread/task/process has the device open (returns kIOReturnExclusiveAccess to the USBDeviceOpen()). On a very rare occasion, the replug will work.

I am relatively new to programming on a Mac, and I have found their documentation to be lacking.

Thank you, Jim
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.