device identification

Tim Roberts timr at
Thu Mar 25 04:41:25 CET 2010

Omer Ihsan <omrihsan at> wrote:
>VID and PID is fair enough. now what i want is that i have a threaded
>code that threads two functions to run at the same time. i want each
>function to run seperate devices. the problem is if it doesnt identify
>the attached devices it might run the code on a single device which
>isnt what is required.

Some of the libraries that pyusb uses are not thread-safe, like libusb 0.1.

>how will i be able to run a code on a device of my choice???
>can leave away the threading part for now.

You can return all of the devices with a particular VID and PID:

    collection = usb.core.find( find_all=True, idVendor=0x1234,
idProduct=0x5678 )

Then you can dish those out to threads using something like the queue

Or, usb.core.find accepts a predicate function that allows you to use any
criteria you wish.

What kind of device are you trying to manipulate?  I have a lot of USB
experience -- perhaps I can offer advice.
Tim Roberts, timr at
Providenza & Boekelheide, Inc.

More information about the Python-list mailing list