Question

I have a USB "watcher" that loads device descriptors for certain devices, and tracks them in an NSMutableArray.

When a new device is added, I get the callback, and can iterate through the list of devices that I have, comparing locationIDs (unique session IDs).

If the locationID of the device is not found (should always be the case), then I add it to the array.

Now, when the device is removed, I get another callback. This has the service ID, which is NOT the same as the one used when the device was added.

Since the device is gone, I can't get a device descriptor for it (thus, no locationID).

How do I match this service ID to the devices I have in my array?

Was it helpful?

Solution

Have you tried using IORegistryEntryGetRegistryEntryID to get the device's service object's unique ID when it connects, and use the ID you get when it disappears to match the device in your array? As far as I know that should work. (IOService is a subclass of IORegistryEntry, so you can use IORegistryEntryGetRegistryEntryID on any IOService object.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top