You can download this code by clicking the button below.
This code is now available for download.
This function discovers and returns information about all USB devices connected to the computer.
Technology Stack : PyUSB
Code Type : Function
Code Difficulty : Intermediate
import usb.core
import usb.util
def discover_usb_devices():
# Discover all USB devices connected to the computer
devices = usb.core.find(find_all=True)
# List devices and their details
device_list = []
for device in devices:
device_info = {
'vendor_id': device.idVendor,
'product_id': device.idProduct,
'device': device
}
device_list.append(device_info)
return device_list