Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2241 > unrolled thread

Get USB ID of a serial port through pyserial?

Started byJohn Nagle <nagle@animats.com>
First post2011-03-30 12:01 -0700
Last post2011-03-31 15:54 +0100
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Get USB ID of a serial port through pyserial? John Nagle <nagle@animats.com> - 2011-03-30 12:01 -0700
    Re: Get USB ID of a serial port through pyserial? Tim Golden <mail@timgolden.me.uk> - 2011-03-31 15:54 +0100

#2241 — Get USB ID of a serial port through pyserial?

FromJohn Nagle <nagle@animats.com>
Date2011-03-30 12:01 -0700
SubjectGet USB ID of a serial port through pyserial?
Message-ID<4d937de9$0$10597$742ec2ed@news.sonic.net>
   Is there some way to get the USB ID of a serial port through
pyserial on Linux and/or Windows?  USB serial port devices have
device names determined by when they were plugged in.  So, if
you have more than one USB serial device, you need the USB device's
built-in ID to figure out what's out there.

   Is there a way to get that info portably?

				John Nagle

[toc] | [next] | [standalone]


#2286

FromTim Golden <mail@timgolden.me.uk>
Date2011-03-31 15:54 +0100
Message-ID<mailman.34.1301583295.2990.python-list@python.org>
In reply to#2241
On 30/03/2011 20:01, John Nagle wrote:
> Is there some way to get the USB ID of a serial port through
> pyserial on Linux and/or Windows? USB serial port devices have
> device names determined by when they were plugged in. So, if
> you have more than one USB serial device, you need the USB device's
> built-in ID to figure out what's out there.
>
> Is there a way to get that info portably?

I appreciate that you're after a portable solution and are
using pyserial, but since no-one's responded (publicly), then
let me at least offer a WMI solution which should work on
Windows:

<code>
import win32com.client

wmi = win32com.client.GetObject ("winmgmts:")
for usb in wmi.InstancesOf ("Win32_USBHub"):
   print usb.DeviceID

</code>

Now, that shows that WMI can "see" USB devices, but to
get from that database record to something more physical,
such as a disk drive or a COM port usually involves a
merry dance across the WMI namespace, essentially joining
to successive entity classes until you reach the one you
want.

If you think this might be worth pursuing for your case,
feel free to get back and ask.

TJG

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web