Get USB ID of a serial port through pyserial?

Discussion in 'Python' started by John Nagle, Mar 30, 2011.

  1. John Nagle

    John Nagle Guest

    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
     
    John Nagle, Mar 30, 2011
    #1
    1. Advertisements

  2. John Nagle

    Tim Golden Guest

    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
     
    Tim Golden, Mar 31, 2011
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-1?Q?St=E9phane?= Nufer

    serial, parallel and USB port

    =?ISO-8859-1?Q?St=E9phane?= Nufer, Jul 30, 2003, in forum: Python
    Replies:
    6
    Views:
    1,105
    Lonnie Princehouse
    Jul 16, 2004
  2. yakka
    Replies:
    3
    Views:
    8,986
    jc9121
    Aug 17, 2006
  3. Pom
    Replies:
    3
    Views:
    2,281
    AlexxGreen
    Jul 15, 2016
  4. Replies:
    2
    Views:
    829
    Hendrik van Rooyen
    Jun 7, 2007
  5. Replies:
    0
    Views:
    1,192
  6. Replies:
    4
    Views:
    2,396
    marina_dan
    Oct 31, 2011
  7. terry
    Replies:
    5
    Views:
    1,184
    Gabriel Genellina
    May 3, 2008
  8. msalerno
    Replies:
    3
    Views:
    669
    Ilmari Karonen
    Jul 14, 2005
Loading...