From c2bea78f6d1d22c3c0bbe3aa5cae63b542d5444c Mon Sep 17 00:00:00 2001 From: bkralik Date: Sat, 2 May 2020 21:18:26 +0200 Subject: [PATCH] Fix python library on Windows (#523) On Windows, setAutoDetachKernelDriver is not supported (http://libusb.sourceforge.net/api-1.0/group__libusb__dev.html#ga5e0cc1d666097e915748593effdc634a) and causes libusb to get stuck (simple try-catch is not working). This prevents any issues when running both at native windows python and cygwined python... --- python/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/__init__.py b/python/__init__.py index dc4e5b1420d6e9..e8525a1764e9a6 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -9,6 +9,7 @@ import time import traceback import subprocess +import sys from .dfu import PandaDFU from .esptool import ESPROM, CesantaFlasher # noqa: F401 from .flash_release import flash_release # noqa: F401 @@ -187,7 +188,8 @@ def connect(self, claim=True, wait=False): self.bootstub = device.getProductID() == 0xddee self.legacy = (device.getbcdDevice() != 0x2300) self._handle = device.open() - self._handle.setAutoDetachKernelDriver(True) + if not sys.platform in ["win32", "cygwin", "msys"]: + self._handle.setAutoDetachKernelDriver(True) if claim: self._handle.claimInterface(0) #self._handle.setInterfaceAltSetting(0, 0) #Issue in USB stack