Mac OS X access devices with the same Vendor ID and different Product IDs
I am writing an application that opens USB devices and transfers some data. I am following UsbSimpleNotificationExample from developer examples. This example adds notifications and assigns callbacks for the unique Vendor ID and Product ID. But for my application, I have multiple PIDs and one VID. How to add a dictionary with one Vid and multiple PIDs? If I use CFDictionarySetValue with 2 PIDs, the second call to Pid overwrites the first value of the dictionary. Because of this, I am unable to respond correctly to IOServiceAddMatchingNotification calls. What other options can I try?
+1
NeoPatrick
source
to share
2 answers
6 years later ... sorry.
This is how you do it:
CFMutableDictionaryRef matchingDict = IOServiceMatching ( kIOUSBDeviceClassName );
if ( matchingDict )
{
UInt32 usbVendor = k_MyVendorID;
CFNumberRef refVendorId = CFNumberCreate ( kCFAllocatorDefault, kCFNumberIntType, &usbVendor );
CFDictionarySetValue ( matchingDict, CFSTR ( kUSBVendorID ), refVendorId );
CFRelease ( refVendorID );
CFDictionarySetValue ( matchingDict, CFSTR ( kUSBProductID ), CFSTR ( "*" ) ); // This is a wildcard, so we find any device.
}
Pay attention to the pattern.
0
source to share