Finding USB Device by VID and PID

  • Share this:

Code introduction


This function is used to find and return a USB device with specific Vendor ID and Product ID.


Technology Stack : PyUSB

Code Type : Function

Code Difficulty : Intermediate


                
                    
import usb.core
import usb.util

def find_usb_device_byvidpid(vid, pid):
    # This function finds and returns a USB device with a specific Vendor ID (vid) and Product ID (pid).
    device = usb.core.find(idVendor=vid, idProduct=pid)
    return device                
              
Tags: