Get USB ID of a serial port through pyserial?

John Nagle

Usenet Archive
Joined
Dec 2, 2004
Messages
1,267
Reaction score
0
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
 

Tim Golden

Usenet Archive
Joined
Jul 18, 2003
Messages
1,060
Reaction score
0
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,245
Members
248,133
Latest member
DujonT

Latest Threads

Top