Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > PyUSB available for current versions of Windows?

Reply
Thread Tools

PyUSB available for current versions of Windows?

 
 
John Nagle
Guest
Posts: n/a
 
      03-09-2012
I want to enumerate the available USB devices. All I really
need is the serial number of the USB devices available to PySerial.
(When you plug in a USB device on Windows, it's assigned the next
available COM port number. On a reboot, the numbers are reassigned.
So if you have multiple USB serial ports, there's a problem.)

PyUSB can supposedly do this, but the documentation is misleading.
It makes a big point of being "100% Python", but that's because it's
just glue code to a platform-specific "back end" provided by someone
else.

There's an old Windows back-end at
"http://www.craftedge.com/products/libusb.html", but it was written for
Windows XP, and can supposedly be run in "compatibility mode" on Windows
Vista. Current versions of Windows, who knows? It's not open source, and
it comes from someone who sells paper-cutting machines for crafters.

There's another Windows back end at

https://sourceforge.net/apps/trac/libusb-win32/wiki

but it involves installing a low-level driver in Windows.
I especially like the instruction "Close all applications which use USB
devices before installing." Does this include the keyboard and mouse?
They also warn "The device driver can not be easily removed from the
system."

John Nagle
 
Reply With Quote
 
 
 
 
Dietmar Schwertberger
Guest
Posts: n/a
 
      03-10-2012
Am 09.03.2012 18:18, schrieb John Nagle:
> I want to enumerate the available USB devices. All I really
> need is the serial number of the USB devices available to PySerial.
> (When you plug in a USB device on Windows, it's assigned the next
> available COM port number. On a reboot, the numbers are reassigned.
> So if you have multiple USB serial ports, there's a problem.)


You can get the required information using Windows Management
Instrumentation (WMI).

See e.g. here for serial port information:
http://www.activexperts.com/admin/sc...i/python/0358/


I'm using code like this to find my USB CDC devices from the device
description:

import win32com.client
strComputer = "."
objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocat or")
objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv 2")
colItems = objSWbemServices.ExecQuery("SELECT Description,DeviceID FROM
Win32_SerialPort")

COM_ports = []
for objItem in colItems:
print objItem.Description,objItem.DeviceID
if objItem.Description == "USB CDC Simple IO HC9S08JSxx":
COM_ports.append( objItem.DeviceID )


On some PCs the query took some seconds.


Regards,

Dietmar
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Examples of Programming with PyUSB 1.0? Aldo Ceccarelli Python 1 03-04-2011 02:08 PM
PyUSB 1.0.0 alpha 1 release wander.lairson Python 0 12-29-2010 06:18 PM
Re: Pyusb Chris Withers Python 0 10-14-2009 05:17 PM
Compiling modules in OSX, eg PyUSB? Dr Mephesto Python 7 03-21-2009 01:34 PM
[ANN] PyUSB Pablo Bleyer Kocik Python 0 05-22-2004 07:33 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57