mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-25 23:23:52 +08:00
dragonpilot beta3
date: 2024-02-12T12:52:55 commit: 0f5fdc8c6be06fb8901e8be8f3fa7d00596eb1f4
This commit is contained in:
@@ -28,6 +28,7 @@ logging.basicConfig(level=LOGLEVEL, format='%(message)s')
|
||||
CANPACKET_HEAD_SIZE = 0x6
|
||||
DLC_TO_LEN = [0, 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20, 24, 32, 48, 64]
|
||||
LEN_TO_DLC = {length: dlc for (dlc, length) in enumerate(DLC_TO_LEN)}
|
||||
PANDA_BUS_CNT = 4
|
||||
|
||||
|
||||
def calculate_checksum(data):
|
||||
@@ -111,7 +112,8 @@ class ALTERNATIVE_EXPERIENCE:
|
||||
DISABLE_DISENGAGE_ON_GAS = 1
|
||||
DISABLE_STOCK_AEB = 2
|
||||
RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX = 8
|
||||
ALKA = 16
|
||||
ALLOW_AEB = 16
|
||||
ALKA = 32
|
||||
|
||||
class Panda:
|
||||
|
||||
@@ -166,6 +168,7 @@ class Panda:
|
||||
HW_TYPE_RED_PANDA = b'\x07'
|
||||
HW_TYPE_RED_PANDA_V2 = b'\x08'
|
||||
HW_TYPE_TRES = b'\x09'
|
||||
HW_TYPE_CUATRO = b'\x0a'
|
||||
|
||||
CAN_PACKET_VERSION = 4
|
||||
HEALTH_PACKET_VERSION = 15
|
||||
@@ -175,15 +178,16 @@ class Panda:
|
||||
|
||||
F2_DEVICES = [HW_TYPE_PEDAL, ]
|
||||
F4_DEVICES = [HW_TYPE_WHITE_PANDA, HW_TYPE_GREY_PANDA, HW_TYPE_BLACK_PANDA, HW_TYPE_UNO, HW_TYPE_DOS]
|
||||
H7_DEVICES = [HW_TYPE_RED_PANDA, HW_TYPE_RED_PANDA_V2, HW_TYPE_TRES]
|
||||
H7_DEVICES = [HW_TYPE_RED_PANDA, HW_TYPE_RED_PANDA_V2, HW_TYPE_TRES, HW_TYPE_CUATRO]
|
||||
|
||||
INTERNAL_DEVICES = (HW_TYPE_UNO, HW_TYPE_DOS, HW_TYPE_TRES)
|
||||
HAS_OBD = (HW_TYPE_BLACK_PANDA, HW_TYPE_UNO, HW_TYPE_DOS, HW_TYPE_RED_PANDA, HW_TYPE_RED_PANDA_V2, HW_TYPE_TRES)
|
||||
INTERNAL_DEVICES = (HW_TYPE_UNO, HW_TYPE_DOS, HW_TYPE_TRES, HW_TYPE_CUATRO)
|
||||
HAS_OBD = (HW_TYPE_BLACK_PANDA, HW_TYPE_UNO, HW_TYPE_DOS, HW_TYPE_RED_PANDA, HW_TYPE_RED_PANDA_V2, HW_TYPE_TRES, HW_TYPE_CUATRO)
|
||||
|
||||
MAX_FAN_RPMs = {
|
||||
HW_TYPE_UNO: 5100,
|
||||
HW_TYPE_DOS: 6500,
|
||||
HW_TYPE_TRES: 6600,
|
||||
HW_TYPE_CUATRO: 6600,
|
||||
}
|
||||
|
||||
HARNESS_STATUS_NC = 0
|
||||
@@ -232,20 +236,18 @@ class Panda:
|
||||
FLAG_FORD_LONG_CONTROL = 1
|
||||
FLAG_FORD_CANFD = 2
|
||||
|
||||
def __init__(self, serial: Optional[str] = None, claim: bool = True, disable_checks: bool = True):
|
||||
def __init__(self, serial: Optional[str] = None, claim: bool = True, disable_checks: bool = True, can_speed_kbps: int = 500):
|
||||
self._connect_serial = serial
|
||||
self._disable_checks = disable_checks
|
||||
|
||||
self._handle: BaseHandle
|
||||
self._handle_open = False
|
||||
self.can_rx_overflow_buffer = b''
|
||||
self._can_speed_kbps = can_speed_kbps
|
||||
|
||||
# connect and set mcu type
|
||||
self.connect(claim)
|
||||
|
||||
# reset comms
|
||||
self.can_reset_communications()
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
@@ -303,6 +305,13 @@ class Panda:
|
||||
self.set_heartbeat_disabled()
|
||||
self.set_power_save(0)
|
||||
|
||||
# reset comms
|
||||
self.can_reset_communications()
|
||||
|
||||
# set CAN speed
|
||||
for bus in range(PANDA_BUS_CNT):
|
||||
self.set_can_speed_kbps(bus, self._can_speed_kbps)
|
||||
|
||||
@classmethod
|
||||
def spi_connect(cls, serial, ignore_version=False):
|
||||
# get UID to confirm slave is present and up
|
||||
@@ -388,7 +397,7 @@ class Panda:
|
||||
return context, usb_handle, usb_serial, bootstub, bcd
|
||||
|
||||
@classmethod
|
||||
def list(cls): # noqa: A003
|
||||
def list(cls):
|
||||
ret = cls.usb_list()
|
||||
ret += cls.spi_list()
|
||||
return list(set(ret))
|
||||
|
||||
@@ -72,7 +72,7 @@ class PandaDFU:
|
||||
return None, handle
|
||||
|
||||
@staticmethod
|
||||
def list() -> List[str]: # noqa: A003
|
||||
def list() -> List[str]:
|
||||
ret = PandaDFU.usb_list()
|
||||
ret += PandaDFU.spi_list()
|
||||
return list(set(ret))
|
||||
|
||||
Reference in New Issue
Block a user