I can’t get USB bsdname from macOS Monterey 12 Bate4 of Intel processor: I have use the "IORegistryEntrySearchCFProperty" function to get the bsdName of the io_service_t, It worked fine on macOS Big Sur's M1 and Intel MBP. Also it worked fine on macOS Monterey App M1. But it always returned nil on macOS Monterey Intel MBP. It involves the following code:
void getBsdName(io_service_t usbDevice)
{
CFStringRef bsdName = NULL;
for(int i = 0; i < 500; i++)
{
bsdName = (CFStringRef)IORegistryEntrySearchCFProperty(usbDevice,
kIOServicePlane,
CFSTR( kIOBSDNameKey ),
kCFAllocatorDefault,
kIORegistryIterateRecursively );
if(!bsdName) {
// If don't get a bsd name, keep waiting in 5s.
usleep(10000);
continue;
}
printf("[%s]: Found bsd name for device %d.\n”, __func__, usbDevice);
break;
}
}
Why it happened? Or is there another way to get it?