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...
master
bkralik 2020-05-02 21:18:26 +02:00 committed by GitHub
parent 0a123b1815
commit c2bea78f6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import os
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 @@ class Panda(object):
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