pyftdi
pyftdi copied to clipboard
Permission issue ignore
I'm using this library in docker. Docker add usb device permissions in container, but library in container see all ftdi devices, so return an error when it finds unauthorized device. Problem was solved when I added try to 'find_all' function in 'usbtools.py'. After this operation everything works fine.
'ftconf.py' return this error:
Error: The device has no langid (permission issue, no string descriptors supported or device error)
my hotfix:
def find_all(cls, vps: Sequence[Tuple[int, int]],
nocache: bool = False) -> \
List[Tuple[UsbDeviceDescriptor, int]]:
"""Find all devices that match the specified vendor/product pairs.
:param vps: a sequence of 2-tuple (vid, pid) pairs
:param bool nocache: bypass cache to re-enumerate USB devices on
the host
:return: a list of 2-tuple (UsbDeviceDescriptor, interface count)
"""
cls.Lock.acquire()
try:
devs = set()
for vid, pid in vps:
# TODO optimize useless loops
devs.update(UsbTools._find_devices(vid, pid, nocache))
devices = set()
for dev in devs:
ifcount = max([cfg.bNumInterfaces for cfg in dev])
# TODO: handle / is serial number strings
try:
sernum = UsbTools.get_string(dev, dev.iSerialNumber)
description = UsbTools.get_string(dev, dev.iProduct)
descriptor = UsbDeviceDescriptor(dev.idVendor, dev.idProduct,
dev.bus, dev.address,
sernum, None, description)
devices.add((descriptor, ifcount))
except ValueError as E:
if not 'permission issue' in E.__str__():
raise type(E)(E)
return list(devices)
finally:
cls.Lock.release()
I just came across this same issue as I just set up a new computer. You need to add the udev rules as decribed here: https://eblot.github.io/pyftdi/installation.html