Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/commaai/panda into rm-esp…
Browse files Browse the repository at this point in the history
…-gps
  • Loading branch information
Bruce Wayne committed Aug 5, 2023
2 parents fbf87e0 + 130092e commit ae874b6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import hashlib
import binascii
import datetime
import warnings
import logging
from functools import wraps
from typing import Optional
Expand Down Expand Up @@ -427,7 +426,7 @@ def usb_list(cls):
if len(serial) == 24:
ret.append(serial)
else:
warnings.warn(f"found device with panda descriptors but invalid serial: {serial}", RuntimeWarning)
logging.warning(f"found device with panda descriptors but invalid serial: {serial}", RuntimeWarning)
except Exception:
continue
except Exception:
Expand Down Expand Up @@ -464,23 +463,21 @@ def connected(self) -> bool:
def reconnect(self):
if self._handle_open:
self.close()
time.sleep(1.0)

success = False
# wait up to 15 seconds
for i in range(0, 15):
for _ in range(0, 15*10):
try:
self.connect()
success = True
break
except Exception:
logging.debug("reconnecting is taking %d seconds...", i + 1)
try:
dfu = PandaDFU(self.get_dfu_serial())
dfu.recover()
except Exception:
pass
time.sleep(1.0)
time.sleep(0.1)
if not success:
raise Exception("reconnect failed")

Expand Down

0 comments on commit ae874b6

Please sign in to comment.