mirror of https://github.com/commaai/panda.git
Fix USB errors (#2011)
Fix LIBUSB_ERROR_PIPE [-9] when resetting over USB hubs or jungle V2
This commit is contained in:
parent
b8a2a8678f
commit
8545c68e4d
|
@ -255,7 +255,7 @@ class Panda:
|
|||
self._handle = None
|
||||
while self._handle is None:
|
||||
# try USB first, then SPI
|
||||
self._context, self._handle, serial, self.bootstub, bcd = self.usb_connect(self._connect_serial, claim=claim)
|
||||
self._context, self._handle, serial, self.bootstub, bcd = self.usb_connect(self._connect_serial, claim=claim, no_error=wait)
|
||||
if self._handle is None:
|
||||
self._context, self._handle, serial, self.bootstub, bcd = self.spi_connect(self._connect_serial)
|
||||
if not wait:
|
||||
|
@ -347,7 +347,7 @@ class Panda:
|
|||
return None, handle, spi_serial, bootstub, None
|
||||
|
||||
@classmethod
|
||||
def usb_connect(cls, serial, claim=True):
|
||||
def usb_connect(cls, serial, claim=True, no_error=False):
|
||||
handle, usb_serial, bootstub, bcd = None, None, None, None
|
||||
context = usb1.USBContext()
|
||||
context.open()
|
||||
|
@ -357,7 +357,9 @@ class Panda:
|
|||
try:
|
||||
this_serial = device.getSerialNumber()
|
||||
except Exception:
|
||||
logger.exception("failed to get serial number of panda")
|
||||
# Allow to ignore errors on reconnect. USB hubs need some time to initialize after panda reset
|
||||
if not no_error:
|
||||
logger.exception("failed to get serial number of panda")
|
||||
continue
|
||||
|
||||
if serial is None or this_serial == serial:
|
||||
|
@ -451,7 +453,7 @@ class Panda:
|
|||
# wait up to 15 seconds
|
||||
for _ in range(15*10):
|
||||
try:
|
||||
self.connect()
|
||||
self.connect(claim=False, wait=True)
|
||||
success = True
|
||||
break
|
||||
except Exception:
|
||||
|
|
Loading…
Reference in New Issue