nusb
nusb copied to clipboard
Add friendly_name field for usb device on windows
Sometimes it is useful to have this kind of information. For example using it I will have the ability to detect whether a device is a flight controller (friendly_name contains some substring like Betaflight, INav etc).
On the devices I'm looking at, the friendly name is either the same as the already exposed product string descriptor, or not present. Do you know where this value is coming from on your devices if it differs from the product string?
Here is an example of device I work with:
0483:5740 - "Betaflight STM32F405 (COM3)", "Betaflight STM32F405"
But some people notified me that they have following output:
0483:5740 - "Betaflight STM32F405 (COM3)", "STM32F405"
So sometimes friendly name is the only way on Windows to get a point that a device is flashed with Betaflight.
My question is where Windows is getting that string from -- ideally you'd have a cross-platform way to do this with knowledge of where it comes from instead of an under-documented Windows-only property that happens to include what you want.
Is it coming from the manufacturer string descriptor? Windows doesn't normally cache that when a device is plugged in, so it's not in DeviceInfo , but you can try the string_descriptors example which requests the manufacturer, product, and serial strings from the device.
Otherwise, if it's not coming from the device, it might depend on how the driver was installed on that particular computer.
Friendly name in Windows (the DEVPKEY_Device_FriendlyName property) is coming from the registry.
For winusb driver it can be set with the resgistry descriptor in the MSOS descriptor. (of that I'm 95% sure - never tried it).
You can change it after the device is first inserted and it will be persisted (i.e. Windows will not change it back automatically). It's useful for when you have ex. 2 identical webcams plugged in - it's the only easy way of differentiating between the devices for the user.
I don't know how this is handled in other OSes.