Is it possible to get USB device by USB port using PyUSB
02:02 08 Jun 2015

I have a lot identical devices with STM32 VCP. Windows 8.1 creates serial COM port for device. If I connect ONE device to any PC USB port, windows will bind to it the same COM port. After the connection of the second device to other USB port, it will create the next COM port with different serial COM number. If I unplug these devices and connect in different order, COM ports will be switched between devices. It's a problem, because I need the same order COM ports order (physically) each time. Using USBlyzer software I can see what some kind of USB port number is different for each physical USB port:

enter image description here

So I would like to access (get the current device) by these devices by port number. Or list all devices and get this port number from device object?

In libusb documentation found it has such a method:

uint8_t libusb_get_port_number (libusb_device *dev)
Get the number of the port that a device is connected to.

link: http://libusb.sourceforge.net/api-1.0/group__dev.html

Maybe PyUSB has it too...

python usb pyusb