Я минимально знаком с xcode и фреймворком I / Okit. Я видел дескриптор устройства и дескриптор конфигурации USB-устройства в USB-пробере.
Я написал программу xcode с использованием инфраструктуры набора ввода-вывода, которая выдает имя USB-устройства в качестве вывода, когда мы указываем идентификатор продукта и идентификатор поставщика этого устройства в качестве входных данных.
/*Take the vendor and product id from console*/
printf("\nEnter the vendor id : ");
scanf("%lx",&usbVendor);
printf("\nEnter the product id :");
scanf("%lx",&usbProduct);
/* Set up a matching dictionary for the class */
matchingDict = IOServiceMatching(kIOUSBDeviceClassName);
if (matchingDict == NULL)
{
return -1; // fail
}
// Create a CFNumber for the idVendor and set the value in the dictionary
numberRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &usbVendor);
CFDictionarySetValue(matchingDict,
CFSTR(kUSBVendorID),
numberRef);
CFRelease(numberRef);
// Create a CFNumber for the idProduct and set the value in the dictionary
numberRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &usbProduct);
CFDictionarySetValue(matchingDict,
CFSTR(kUSBProductID),
numberRef);
CFRelease(numberRef);
numberRef = NULL;
/*Get an iterator.*/
kr = IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &iter);
if (kr != KERN_SUCCESS)
{
return -1;// fail
}
/* iterate */
while ((device = IOIteratorNext(iter)))
{
/*Display the device names */
io_name_t deviceName;
kr = IORegistryEntryGetName(device, deviceName);
if (KERN_SUCCESS != kr) {
deviceName[0] = '\0';
}
printf("\ndeviceName:%s",deviceName);
/*Free the reference taken before continuing to the next item */
IOObjectRelease(device);
}
/*Release the iterator */
IOObjectRelease(iter);
return 0;
}
Мне нужно изменить это, чтобы при предоставлении идентификатора поставщика и продукта USB-устройства я получал дескриптор устройства и дескриптор конфигурации (как показано в USB-пробере) в качестве вывода.
Здесь я только что привел пример, код может измениться, но на выходе должен быть дескриптор (по крайней мере, дескриптор устройства).
Заранее спасибо...