Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pyusb question
#1
Shocked 
Hi,
I am attempting to find the PID and VID from inserted USB devices.

I installed pyusb.
I also found libusb, because without it, no info.
Then you use the wizzard to identify one inserted device (eg. usb stick),
and create a new driver for it.
That works, the pyUsb software now sees it, and gives the PID and the VID.

But, it seems that you have to repeat that process for every USB device that you want info from.
Which is useless because the Win 11 device manager will give that info as well. No need for pyusb.

So nothing happens when you insert a different USB stick. This is not what I imagined for my app.

Can anybody confirm that this pyusb only works with previously identified USB sticks, USB printers, USB hubs, etc on you PC.

Thanks
Paul
Update: I am convinced it is not possible, without major inconvenience.
So pyusb seems to work in a closed (controlled) environment, using libusb
to make a kind of list of detectable devices. Not of "visitors'.
And even then the whole app is linked to one PC, where the usblib is installed.

Many years ago, we could insert a 3.5" diskette in the a: or b:, and
simple visual basic would tell you it's serial# right away.

I have a list of VID numbers for more than 3000 vendors.
Would have been nice to link that to pyusb. Angry
Paul
update2: don't give up Smile
if you want to find the serial, PID or VID of any inserted USB stick, on the fly,
forget pyusb, libusb, and the likes. Too much hassle with very little result.
After a while it dawned on me that the windows device manager
seemed to have no trouble at all to give me the right info. How come ?

For those interested, all you have to do is call that windows
module from python, and in 3 lines you get all the info you want, and more.
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply
#2
Does this provide same information? https://pyserial.readthedocs.io/en/lates...stPortInfo

I seem to recall that USB port assignments come and go as usb devices are connected or removed, so can be different at various times.
Reply
#3
Hi Larz,

Thanks for your interest in this matter.
USB port assignments may vary, ProductID, VendorID and serial# don't.
I can now -on the fly- determine if an inserted USB stick :
- is mine ?
- is who's ? (providing an authorized list of serials, that can be hard-coded or encrypted))
- is authorized to access a given PC? (between hours, certain days...)
- is made by which vendor...(inclusion , exclusion list)
(And the stick may have no data at all, freshly formatted.)
Possible applications are numerous.
You can do the same with other USB connected devices like the BBC micro:bit, all be it in a slightly different manner.
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020