-
-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can not get the product ID and vendor ID #121
Comments
I'm seeing the same thing when I disconnect the USB device and connect it again. Works fine for the first connection. |
Anyone else been able to fix this? |
Based on https://stackoverflow.com/questions/34464672/make-a-list-of-serial-usb-device-with-specific-ids - (int)VendorID
{
// Variable declaration
int vid;
CFTypeRef cf_vendor;
vid = -1;
// Search properties among parents of the current port
cf_vendor = IORegistryEntrySearchCFProperty(_IOKitDevice, kIOServicePlane,
CFSTR(kUSBVendorID),
kCFAllocatorDefault,
kIORegistryIterateRecursively | kIORegistryIterateParents);
// Decode & print VID
if (cf_vendor && CFNumberGetValue(cf_vendor , kCFNumberIntType, &vid))
{
printf("\nUSB VID: %04X", vid);
}
// Release CFTypeRef
if (cf_vendor) CFRelease(cf_vendor);
// Return vendor id
return vid;
} - (int)ProductID
{
// Variable declaration
int pid;
CFTypeRef cf_product;
pid = -1;
// Search properties among parents of the current port
cf_product = IORegistryEntrySearchCFProperty(_IOKitDevice, kIOServicePlane,
CFSTR(kUSBProductID),
kCFAllocatorDefault,
kIORegistryIterateRecursively | kIORegistryIterateParents);
// Decode & print PID
if (cf_product && CFNumberGetValue(cf_product , kCFNumberIntType, &pid))
{
printf("\nUSB PID: %04X", pid);
}
// Release CFTypeRef
if (cf_product) CFRelease(cf_product);
// Return product id
return pid;
} |
Works fine for me as described by underscore forbidden but I experienced the same problem as martinjbakker: disconnecting / reconnecting the USB device gives a (null) PID/VID. So I included a workaround: restart the app when removing an USB device. I would be glad to see a solution for the cause of the problem which I couldn't find.
|
Unfortunately, I don't know why getting these fails after a disconnect/reconnect. I don't use the PID/VID for anything myself, so haven't noticed this. I'll look into it at some point, though. |
Should be fixed by #144. |
https://github.com/armadsen/ORSSerialPort/wiki/Getting-Vendor-ID-and-Product-ID
The method in this page can not get the product ID and vendor ID. IORegistryEntryCreateIterator got an error result and return nil for property.
The text was updated successfully, but these errors were encountered: