0

On a windows OS, how can I get python to detect if anything is plugged in to a specific USB location on the computer. For example "Port_#0002.Hub_#0003"

I've tried pyUSB which worked fine for detecting a specific device, but I couldn't seem to figure out how to just check a specific port/hub location for any kind of device.

tshepang
  • 12,111
  • 21
  • 91
  • 136
smkraft
  • 123
  • 2
  • 5
  • http://bitpim.svn.sourceforge.net/viewvc/bitpim/trunk/bitpim/src/native/usb/usb.py?revision=4835&view=markup see the `alldevices` method maybe – Joran Beasley Jul 01 '13 at 22:52

1 Answers1

0

What about polling? Create a Python app that enumerates a list of attached USB devices every couple of seconds or so.

Keep a list/dictionary of your initially detected devices, and compare to that to determine what was attached/detached since your last polling iteration.

This isn't the best approach, and enumerating all the devices takes a short while, so not too sure this would be the most CPU efficient method.

josef.van.niekerk
  • 11,941
  • 20
  • 97
  • 157