Closed Neradoc closed 3 years ago
A possible solution (but it will need a fair amount of parsing code):
PnPUtil - https://docs.microsoft.com/en-gb/windows-hardware/drivers/devtest/pnputil
https://docs.microsoft.com/en-gb/windows-hardware/drivers/devtest/pnputil-command-syntax
I think it's similar to lshw
Running
pnputil /enum-devices /relations
gets every device EVER connected.
pnputil /enum-devices /relations /connected
gets every device currently connected.
Some example output related to my PyPortal - I've expunged the rest:
Instance ID: HID\VID_239A&PID_8036&MI_03&Col03\8&368a5fc6&0&0002
Device Description: HID-compliant consumer control device
Class Name: HIDClass
Class GUID: {745a17a0-74d3-11d0-b6fe-00a0c90f57da}
Manufacturer Name: Microsoft
Status: Started
Driver Name: hidserv.inf
Parent: USB\VID_239A&PID_8036&MI_03\7&1ec6fc0a&0&0003
Instance ID: USB\VID_239A&PID_8036&MI_03\7&1ec6fc0a&0&0003
Device Description: USB Input Device
Class Name: HIDClass
Class GUID: {745a17a0-74d3-11d0-b6fe-00a0c90f57da}
Manufacturer Name: (Standard system devices)
Status: Started
Driver Name: input.inf
Parent: USB\VID_239A&PID_8036\8351BF333339395320202038471207FF
Children: HID\VID_239A&PID_8036&MI_03&Col01\8&368a5fc6&0&0000
HID\VID_239A&PID_8036&MI_03&Col02\8&368a5fc6&0&0001
HID\VID_239A&PID_8036&MI_03&Col03\8&368a5fc6&0&0002
Instance ID: USBSTOR\Disk&Ven_Adafruit&Prod_PyPortal&Rev_1.0\8&12b32204&0&8351BF333339395320202038471207FF&0
Device Description: Adafruit PyPortal USB Device
Class Name: DiskDrive
Class GUID: {4d36e967-e325-11ce-bfc1-08002be10318}
Manufacturer Name: (Standard disk drives)
Status: Started
Driver Name: disk.inf
Parent: USB\VID_239A&PID_8036&MI_02\7&1ec6fc0a&0&0002
Instance ID: USB\VID_239A&PID_8036&MI_04\7&1ec6fc0a&0&0004
Device Description: CircuitPython Audio
Class Name: MEDIA
Class GUID: {4d36e96c-e325-11ce-bfc1-08002be10318}
Manufacturer Name: (Generic USB Audio)
Status: Started
Driver Name: wdma_usb.inf
Parent: USB\VID_239A&PID_8036\8351BF333339395320202038471207FF
Children: SWD\MMDEVAPI\MIDII_CDCA883A.P_0000
SWD\MMDEVAPI\MIDII_CDCA883A.P_0001
Instance ID: SWD\MMDEVAPI\MIDII_CDCA883A.P_0000
Device Description: 2 - CircuitPython usb_midi.ports[0]
Class Name: SoftwareDevice
Class GUID: {62f9c741-b25a-46ce-b54c-9bccce08b6f2}
Manufacturer Name: Microsoft
Status: Started
Driver Name: c_swdevice.inf
Parent: USB\VID_239A&PID_8036&MI_04\7&1ec6fc0a&0&0004
Instance ID: SWD\MMDEVAPI\MIDII_CDCA883A.P_0001
Device Description: 2 - CircuitPython usb_midi.ports[0]
Class Name: SoftwareDevice
Class GUID: {62f9c741-b25a-46ce-b54c-9bccce08b6f2}
Manufacturer Name: Microsoft
Status: Started
Driver Name: c_swdevice.inf
Parent: USB\VID_239A&PID_8036&MI_04\7&1ec6fc0a&0&0004
Instance ID: STORAGE\Volume\_??_USBSTOR#Disk&Ven_Adafruit&Prod_PyPortal&Rev_1.0#8&12b32204&0&8351BF333339395320202038471207FF&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
Device Description: Volume
Class Name: Volume
Class GUID: {71a27cdd-812a-11d0-bec7-08002be2092f}
Manufacturer Name: Microsoft
Status: Started
Driver Name: volume.inf
Parent: ROOT\volmgr\0000
Children: SWD\WPDBUSENUM\_??_USBSTOR#Disk&Ven_Adafruit&Prod_PyPortal&Rev_1.0#8&12b32204&0&8351BF333339395320202038471207FF&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
Instance ID: USB\VID_239A&PID_8036&MI_00\7&1ec6fc0a&0&0000
Device Description: USB Serial Device (COM7)
Class Name: Ports
Class GUID: {4d36e978-e325-11ce-bfc1-08002be10318}
Manufacturer Name: Microsoft
Status: Started
Driver Name: usbser.inf
Parent: USB\VID_239A&PID_8036\8351BF333339395320202038471207FF
Instance ID: USB\VID_8087&PID_0024\5&7b6a73c&0&1
Device Description: Generic USB Hub
Class Name: USB
Class GUID: {36fc9e60-c465-11cf-8056-444553540000}
Manufacturer Name: (Generic USB Hub)
Status: Started
Driver Name: usb.inf
Parent: USB\ROOT_HUB20\4&6dc585&0
Children: USB\VID_0BDA&PID_8771\00E04C239987
USB\VID_046D&PID_C534\6&ddc87e9&0&3
USB\VID_0E8D&PID_1887\KV9Z73D3736_________
USB\VID_239A&PID_8036\8351BF333339395320202038471207FF
Instance ID: USB\VID_239A&PID_8036\8351BF333339395320202038471207FF
Device Description: USB Composite Device
Class Name: USB
Class GUID: {36fc9e60-c465-11cf-8056-444553540000}
Manufacturer Name: (Standard USB Host Controller)
Status: Started
Driver Name: usb.inf
Parent: USB\VID_8087&PID_0024\5&7b6a73c&0&1
Children: USB\VID_239A&PID_8036&MI_00\7&1ec6fc0a&0&0000
USB\VID_239A&PID_8036&MI_02\7&1ec6fc0a&0&0002
USB\VID_239A&PID_8036&MI_03\7&1ec6fc0a&0&0003
USB\VID_239A&PID_8036&MI_04\7&1ec6fc0a&0&0004
Instance ID: HID\VID_239A&PID_8036&MI_03&Col01\8&368a5fc6&0&0000
Device Description: HID Keyboard Device
Class Name: Keyboard
Class GUID: {4d36e96b-e325-11ce-bfc1-08002be10318}
Manufacturer Name: (Standard keyboards)
Status: Started
Driver Name: keyboard.inf
Parent: USB\VID_239A&PID_8036&MI_03\7&1ec6fc0a&0&0003
Instance ID: SWD\WPDBUSENUM\_??_USBSTOR#Disk&Ven_Adafruit&Prod_PyPortal&Rev_1.0#8&12b32204&0&8351BF333339395320202038471207FF&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
Device Description: CIRCUITPY
Class Name: WPD
Class GUID: {eec5ad98-8080-425f-922a-dabf3de3f69a}
Manufacturer Name: Adafruit
Status: Started
Driver Name: wpdfs.inf
Parent: STORAGE\Volume\_??_USBSTOR#Disk&Ven_Adafruit&Prod_PyPortal&Rev_1.0#8&12b32204&0&8351BF333339395320202038471207FF&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
Instance ID: HID\VID_239A&PID_8036&MI_03&Col02\8&368a5fc6&0&0001
Device Description: HID-compliant mouse
Class Name: Mouse
Class GUID: {4d36e96f-e325-11ce-bfc1-08002be10318}
Manufacturer Name: Microsoft
Status: Started
Driver Name: msmouse.inf
Parent: USB\VID_239A&PID_8036&MI_03\7&1ec6fc0a&0&0003
Instance ID: USB\VID_239A&PID_8036&MI_02\7&1ec6fc0a&0&0002
Device Description: USB Mass Storage Device
Class Name: USB
Class GUID: {36fc9e60-c465-11cf-8056-444553540000}
Manufacturer Name: Compatible USB storage device
Status: Started
Driver Name: usbstor.inf
Parent: USB\VID_239A&PID_8036\8351BF333339395320202038471207FF
Children: USBSTOR\Disk&Ven_Adafruit&Prod_PyPortal&Rev_1.0\8&12b32204&0&8351BF333339395320202038471207FF&0
Matching parent to children it should be possible to extract the info you're looking for.
PRs #4 and #5 use the available PNP information to the best of my understanding.
However note that it seems that both Manufacturer and Product (name) fields are restricted to 16 characters in PNP, so I don't consider that issue to be closed, but I have not been able to get the complete strings from WMI/PNP so far. It doesn't show with pyportal, but CircuitPlaynground Express becomes "CircuitPlaygroun"
and the Arduino Nano RP2040 Connect becomes "Arduino Nano RP2"
, which is a fortuitous place to cut off, but still bad.
Also, this only works if the board has a drive currently known to the operating system, so if the drive is disabled or for boards without a drive like Arduino or Micropython, it will not retrieve a name.
I wonder if we would have to interrogate some windows USB library/driver or other through ctypes. Whatever the "Devices and Printers" control panel does.
Closed by #6
Example: the Clue is listed as "CLUE nrf52840 Express" in the windows device manager, how to get that information from it ? Right now we are parsing the port.description from the serial port, but that doesn't have what we need.