mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-24 10:43:52 +08:00
dragonpilot beta3
date: 2023-08-14T18:35:32 commit: 90b4f6596bf852f4add5a8faa7581aabb57e4ba4
This commit is contained in:
@@ -7,7 +7,6 @@ import struct
|
||||
import hashlib
|
||||
import binascii
|
||||
import datetime
|
||||
import warnings
|
||||
import logging
|
||||
from functools import wraps
|
||||
from typing import Optional
|
||||
@@ -425,10 +424,10 @@ class Panda:
|
||||
if device.getVendorID() == 0xbbaa and device.getProductID() in cls.USB_PIDS:
|
||||
try:
|
||||
serial = device.getSerialNumber()
|
||||
if len(serial) == 24:
|
||||
if len(serial) == 24 or serial == "pedal":
|
||||
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:
|
||||
@@ -474,11 +473,7 @@ class Panda:
|
||||
success = True
|
||||
break
|
||||
except Exception:
|
||||
try:
|
||||
dfu = PandaDFU(self.get_dfu_serial())
|
||||
dfu.recover()
|
||||
except Exception:
|
||||
pass
|
||||
pass
|
||||
time.sleep(0.1)
|
||||
if not success:
|
||||
raise Exception("reconnect failed")
|
||||
@@ -772,13 +767,6 @@ class Panda:
|
||||
def enable_deepsleep(self):
|
||||
self._handle.controlWrite(Panda.REQUEST_OUT, 0xfb, 0, 0, b'')
|
||||
|
||||
def set_esp_power(self, on):
|
||||
self._handle.controlWrite(Panda.REQUEST_OUT, 0xd9, int(on), 0, b'')
|
||||
|
||||
def esp_reset(self, bootmode=0):
|
||||
self._handle.controlWrite(Panda.REQUEST_OUT, 0xda, int(bootmode), 0, b'')
|
||||
time.sleep(0.2)
|
||||
|
||||
def set_safety_mode(self, mode=SAFETY_SILENT, param=0):
|
||||
self._handle.controlWrite(Panda.REQUEST_OUT, 0xdc, mode, param, b'')
|
||||
|
||||
|
||||
@@ -6,10 +6,8 @@ DEBUG = False
|
||||
def msg(x):
|
||||
if DEBUG:
|
||||
print("S:", binascii.hexlify(x))
|
||||
if len(x) <= 7:
|
||||
ret = bytes([len(x)]) + x
|
||||
else:
|
||||
assert False
|
||||
assert len(x) <= 7
|
||||
ret = bytes([len(x)]) + x
|
||||
return ret.ljust(8, b"\x00")
|
||||
|
||||
kmsgs = []
|
||||
@@ -56,7 +54,7 @@ def isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr):
|
||||
dat = msg[2:]
|
||||
else:
|
||||
print(binascii.hexlify(msg))
|
||||
assert False
|
||||
raise AssertionError
|
||||
|
||||
return dat[0:tlen]
|
||||
|
||||
@@ -133,7 +131,7 @@ def isotp_recv(panda, addr, bus=0, sendaddr=None, subaddr=None):
|
||||
tlen = msg[0] & 0xf
|
||||
dat = msg[1:]
|
||||
else:
|
||||
assert False
|
||||
raise AssertionError
|
||||
dat = dat[0:tlen]
|
||||
|
||||
if DEBUG:
|
||||
|
||||
@@ -314,7 +314,7 @@ class STBootloaderSPIHandle(BaseSTBootloaderHandle):
|
||||
|
||||
self._mcu_type = MCU_TYPE_BY_IDCODE[self.get_chip_id()]
|
||||
except PandaSpiException:
|
||||
raise PandaSpiException("failed to connect to panda") # pylint: disable=W0707
|
||||
raise PandaSpiException("failed to connect to panda") from None
|
||||
|
||||
def _get_ack(self, spi, timeout=1.0):
|
||||
data = 0x00
|
||||
|
||||
Reference in New Issue
Block a user