Hi all,I have an app that searches for a specific usb device.I observe the usb plugin notification and tried to find its BSD name.
CFMutableDictionaryRef matchingDict;
CFRunLoopSourceRef runLoopSource;
matchingDict = IOServiceMatching(kIOUSBDeviceClassName);
if (!matchingDict)
{
printf("Couldn’t create a USB matching dictionary\n");
return NO;
}
IONotificationPortRef gNotifyPort;
io_iterator_t gRawAddedIter;
io_iterator_t gRawRemovedIter;
gNotifyPort = IONotificationPortCreate(kIOMasterPortDefault);
runLoopSource = IONotificationPortGetRunLoopSource(gNotifyPort);
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource,
kCFRunLoopDefaultMode);
matchingDict = (CFMutableDictionaryRef) CFRetain(matchingDict);
/
IOServiceAddMatchingNotification(gNotifyPort,
kIOFirstMatchNotification,
matchingDict,
onDeviceAdd,
NULL,
&gRawAddedIter);
In onDeviceAdd function ,
//some code here
while ((usbDevice = IOIteratorNext(iterator)))
{
//some code here
CFStringRef deviceBSDName_cf = ( CFStringRef ) IORegistryEntrySearchCFProperty (usbDevice,
kIOServicePlane,
CFSTR (kIOBSDNameKey ),
kCFAllocatorDefault,
kIORegistryIterateRecursively );
NSString *deviceBSDName = (NSString *)deviceBSDName_cf;
//some code here
}
This function IORegistryEntrySearchCFProperty works fine in OSX 10.10.4 with XCode 6.3 SDK 10.10(and older OSX versions ).
And it fails in OSX 10.11 beta1 and beta2 with Xcode 7.0 and SDK 10.11.It returns 0x0.
I don't find any changes about this function.
Can anyone help?
Thanks in advance!!