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


Groups > comp.lang.python > #2286

Re: Get USB ID of a serial port through pyserial?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <mail@timgolden.me.uk>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'pursuing': 0.05; 'involves': 0.07; 'from:addr:timgolden.me.uk': 0.09; 'from:name:tim golden': 0.09; 'message-id:@timgolden.me.uk': 0.09; 'successive': 0.09; 'linux': 0.11; 'essentially': 0.12; 'wrote:': 0.14; 'namespace,': 0.16; 'pyserial': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'windows:': 0.16; 'windows?': 0.16; 'wmi': 0.16; 'dance': 0.16; 'figure': 0.18; 'device': 0.20; 'header:In-Reply-To:1': 0.22; 'joining': 0.23; "what's": 0.24; 'determined': 0.25; 'there.': 0.26; 'classes': 0.26; 'subject:?': 0.29; 'least': 0.30; 'responded': 0.31; 'subject:through': 0.31; 'tjg': 0.31; 'import': 0.32; 'to:addr:python-list': 0.32; 'record': 0.34; 'using': 0.34; 'received:192': 0.34; 'there': 0.35; 'print': 0.35; 'header:User- Agent:1': 0.35; 'disk': 0.35; 'usually': 0.36; 'think': 0.36; 'case,': 0.36; 'shows': 0.36; 'received:192.168': 0.37; 'some': 0.37; 'should': 0.37; 'but': 0.38; 'port': 0.38; 'so,': 0.38; 'database': 0.38; 'to:addr:python.org': 0.39; 'solution': 0.40; 'might': 0.40; 'from:addr:mail': 0.60; 'com': 0.60; 'back': 0.61; 'free': 0.62; 'worth': 0.64; 'devices': 0.64; 'offer': 0.72; 'subject:Get': 0.74; 'serial': 0.77; 'ask.': 0.91; 'usb': 0.95
Date Thu, 31 Mar 2011 15:54:49 +0100
From Tim Golden <mail@timgolden.me.uk>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9
MIME-Version 1.0
To python-list@python.org
Subject Re: Get USB ID of a serial port through pyserial?
References <4d937de9$0$10597$742ec2ed@news.sonic.net>
In-Reply-To <4d937de9$0$10597$742ec2ed@news.sonic.net>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.34.1301583295.2990.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 82.94.164.166
X-Trace 1301583296 news.xs4all.nl 81483 [::ffff:82.94.164.166]:60199
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:2286

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

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

csiph-web