mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-24 16:33:52 +08:00
dragonpilot 2022-08-19T01:11:48 for EON/C2
version: dragonpilot v0.8.16 beta for EON/C2 date: 2022-08-19T01:11:48 dp-dev(priv2) master commit: 4aee191bc9d1c5099913455ff9e5fa1c3a7a7903
This commit is contained in:
committed by
Comma Device
parent
b437663252
commit
66006fe0e9
@@ -150,7 +150,7 @@ class Panda:
|
||||
SAFETY_STELLANTIS = 25
|
||||
SAFETY_FAW = 26
|
||||
SAFETY_BODY = 27
|
||||
SAFETY_HYUNDAI_HDA2 = 28
|
||||
SAFETY_HYUNDAI_CANFD = 28
|
||||
|
||||
SERIAL_DEBUG = 0
|
||||
SERIAL_ESP = 1
|
||||
@@ -200,10 +200,15 @@ class Panda:
|
||||
FLAG_TESLA_POWERTRAIN = 1
|
||||
FLAG_TESLA_LONG_CONTROL = 2
|
||||
|
||||
FLAG_VOLKSWAGEN_LONG_CONTROL = 1
|
||||
|
||||
FLAG_CHRYSLER_RAM_DT = 1
|
||||
FLAG_CHRYSLER_RAM_HD = 2
|
||||
|
||||
FLAG_SUBARU_GEN2 = 1
|
||||
|
||||
FLAG_GM_HW_CAM = 1
|
||||
|
||||
def __init__(self, serial: Optional[str] = None, claim: bool = True):
|
||||
self._serial = serial
|
||||
self._handle = None
|
||||
@@ -335,9 +340,10 @@ class Panda:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def flash(self, fn=DEFAULT_FW_FN, code=None, reconnect=True):
|
||||
if self._mcu_type == MCU_TYPE_H7 and fn == DEFAULT_FW_FN:
|
||||
fn = DEFAULT_H7_FW_FN
|
||||
def flash(self, fn=None, code=None, reconnect=True):
|
||||
if not fn:
|
||||
fn = DEFAULT_H7_FW_FN if self._mcu_type == MCU_TYPE_H7 else DEFAULT_FW_FN
|
||||
assert os.path.isfile(fn)
|
||||
print("flash: main version is " + self.get_version())
|
||||
if not self.bootstub:
|
||||
self.reset(enter_bootstub=True)
|
||||
@@ -358,18 +364,16 @@ class Panda:
|
||||
self.reconnect()
|
||||
|
||||
def recover(self, timeout: Optional[int] = None, reset: bool = True) -> bool:
|
||||
dfu_serial = PandaDFU.st_serial_to_dfu_serial(self._serial, self._mcu_type)
|
||||
|
||||
if reset:
|
||||
self.reset(enter_bootstub=True)
|
||||
self.reset(enter_bootloader=True)
|
||||
|
||||
t_start = time.time()
|
||||
while len(PandaDFU.list()) == 0:
|
||||
print("waiting for DFU...")
|
||||
time.sleep(0.1)
|
||||
if timeout is not None and (time.time() - t_start) > timeout:
|
||||
return False
|
||||
if not self.wait_for_dfu(dfu_serial, timeout=timeout):
|
||||
return False
|
||||
|
||||
dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial, self._mcu_type))
|
||||
dfu = PandaDFU(dfu_serial)
|
||||
dfu.recover()
|
||||
|
||||
# reflash after recover
|
||||
@@ -377,6 +381,16 @@ class Panda:
|
||||
self.flash()
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def wait_for_dfu(dfu_serial: str, timeout: Optional[int] = None) -> bool:
|
||||
t_start = time.monotonic()
|
||||
while dfu_serial not in PandaDFU.list():
|
||||
print("waiting for DFU...")
|
||||
time.sleep(0.1)
|
||||
if timeout is not None and (time.monotonic() - t_start) > timeout:
|
||||
return False
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def list():
|
||||
context = usb1.USBContext()
|
||||
|
||||
Reference in New Issue
Block a user