From fe55344d32e41ba2428b9b4f1198d018d8873132 Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Tue, 14 Aug 2018 23:05:23 +0200 Subject: [PATCH] pyusb backend: select the iface with the right bInterfaceClass right away --- brother_ql/backends/pyusb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brother_ql/backends/pyusb.py b/brother_ql/backends/pyusb.py index 1a843a8..2faf845 100755 --- a/brother_ql/backends/pyusb.py +++ b/brother_ql/backends/pyusb.py @@ -98,8 +98,8 @@ class BrotherQLBackendPyUSB(BrotherQLBackendGeneric): self.dev.set_configuration() cfg = self.dev.get_active_configuration() - intf = cfg[(0,0)] # (bInterfaceNumber, bAlternateSetting) - assert intf.bInterfaceClass == 7 # 'Printer' not 'Vendor Specific' or the likes... + intf = usb.util.find_descriptor(cfg, bInterfaceClass=7) + assert intf is not None ep_match_in = lambda e: usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_IN ep_match_out = lambda e: usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_OUT