I have an issue with an app that monitors the USB bus for changes. Specifically if I want to get a list of attached USB sevices, I am using the code below. What is strange is that some users (and nautally not my machines) do not see one or two devices.
Those devices DO show up in the IORegistryExplorer, and show registered.
The machines for which this is not working are also running 10.6 and are also MacBook Pros.
CFMutableDictionaryRef service_properties = CFDictionaryCreateMutable(NULL, 0, NULL,NULL);
CFMutableDictionaryRef child_props = CFDictionaryCreateMutable(NULL, 0, NULL,NULL);
kr = IOServiceGetMatchingServices(kIOMasterPortDefault,
IOServiceNameMatching("AppleUSBEHCI"), &io_objects);
if(kr != KERN_SUCCESS)
exit(1);
while((io_service= IOIteratorNext(io_objects)))
{
kr = IORegistryEntryCreateCFProperties(io_service, &service_properties, kCFAllocatorDefault, kNilOptions);
io_iterator_t iter;
kr = IORegistryEntryGetChildIterator(io_service, kIOServicePlane, &iter);
io_registry_entry_t child;
while( (child = IOIteratorNext( iter )))
{
kr = IORegistryEntryCreateCFProperties(child, &child_props, kCFAllocatorDefault, kNilOptions );
NSLog(@"%@",child_props);
}
IOObjectRelease(io_service);
}
It turns out that you need to poll all the bus types: