문제

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?

도움이 되었습니까?

해결책

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.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top