I have two USB to Serial-Converters plugged into my PC. Both of them use FTDI chips so their VendorID
and ProductID
is the same. I need to read and write to only one of them but when I use usb.core.find(VendorID, ProductID)
it always finds the wrong USB device. So I'm trying to figure out how to use the bus and the address to find the right one.
The code I'm currently using to figure out which one I connected to is:
import usb.core
dev = usb.core.find(idVendor=0x0403, idProduct=0x6001)
if dev is None:
raise ValueError('Gerät nicht angeschlossen!')
if dev.address == 2 and dev.bus == 2: # usb->serial converter motor
print("Motor")
elif dev.address == 1 and dev.bus == 2: # usb->serial converter laser
print("Laser")
else:
print("Weder Laser noch Motor")
print(dev)
I need it to find the usb
to serial converter of the motor but it always finds the laser.
Is there a way to use dev.bus
and dev.address
in the usb.core.find()
function?
I'm new to python & pyusb so I need to print everything for my own understanding.
In PyUSB's tutorial it says it's possible using the bus and the address but I still couldn't figure it out after reading it.