mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-20 00:03:56 +08:00
openpilot v0.8.8 release
This commit is contained in:
@@ -8,17 +8,16 @@ import os
|
||||
import time
|
||||
import traceback
|
||||
import sys
|
||||
from .dfu import PandaDFU # pylint: disable=import-error
|
||||
from .dfu import PandaDFU, MCU_TYPE_F2, MCU_TYPE_F4, MCU_TYPE_H7 # pylint: disable=import-error
|
||||
from .flash_release import flash_release # noqa pylint: disable=import-error
|
||||
from .update import ensure_st_up_to_date # noqa pylint: disable=import-error
|
||||
from .serial import PandaSerial # noqa pylint: disable=import-error
|
||||
from .isotp import isotp_send, isotp_recv # pylint: disable=import-error
|
||||
|
||||
from .config import DEFAULT_FW_FN, DEFAULT_H7_FW_FN # noqa pylint: disable=import-error
|
||||
|
||||
__version__ = '0.0.9'
|
||||
|
||||
BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../")
|
||||
DEFAULT_FW_FN = os.path.join(BASEDIR, "board", "obj", "panda.bin.signed")
|
||||
|
||||
DEBUG = os.getenv("PANDADEBUG") is not None
|
||||
|
||||
@@ -139,6 +138,11 @@ class Panda(object):
|
||||
HW_TYPE_PEDAL = b'\x04'
|
||||
HW_TYPE_UNO = b'\x05'
|
||||
HW_TYPE_DOS = b'\x06'
|
||||
HW_TYPE_RED_PANDA = b'\x07'
|
||||
|
||||
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]
|
||||
|
||||
CLOCK_SOURCE_MODE_DISABLED = 0
|
||||
CLOCK_SOURCE_MODE_FREE_RUNNING = 1
|
||||
@@ -151,6 +155,7 @@ class Panda(object):
|
||||
self._serial = serial
|
||||
self._handle = None
|
||||
self.connect(claim)
|
||||
self._mcu_type = self.get_mcu_type()
|
||||
|
||||
def close(self):
|
||||
self._handle.close()
|
||||
@@ -225,7 +230,7 @@ class Panda(object):
|
||||
except Exception:
|
||||
print("reconnecting is taking %d seconds..." % (i + 1))
|
||||
try:
|
||||
dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial))
|
||||
dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial, self._mcu_type))
|
||||
dfu.recover()
|
||||
except Exception:
|
||||
pass
|
||||
@@ -262,6 +267,8 @@ class Panda(object):
|
||||
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
|
||||
print("flash: main version is " + self.get_version())
|
||||
if not self.bootstub:
|
||||
self.reset(enter_bootstub=True)
|
||||
@@ -291,7 +298,7 @@ class Panda(object):
|
||||
if timeout is not None and (time.time() - t_start) > timeout:
|
||||
return False
|
||||
|
||||
dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial))
|
||||
dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial, self._mcu_type))
|
||||
dfu.recover()
|
||||
|
||||
# reflash after recover
|
||||
@@ -401,9 +408,25 @@ class Panda(object):
|
||||
|
||||
def is_dos(self):
|
||||
return self.get_type() == Panda.HW_TYPE_DOS
|
||||
|
||||
def is_red(self):
|
||||
return self.get_type() == Panda.HW_TYPE_RED_PANDA
|
||||
|
||||
def get_mcu_type(self):
|
||||
hw_type = self.get_type()
|
||||
if hw_type in Panda.F2_DEVICES:
|
||||
return MCU_TYPE_F2
|
||||
elif hw_type in Panda.F4_DEVICES:
|
||||
return MCU_TYPE_F4
|
||||
elif hw_type in Panda.H7_DEVICES:
|
||||
return MCU_TYPE_H7
|
||||
return None
|
||||
|
||||
def has_obd(self):
|
||||
return (self.is_uno() or self.is_dos() or self.is_black())
|
||||
return (self.is_uno() or self.is_dos() or self.is_black() or self.is_red())
|
||||
|
||||
def has_canfd(self):
|
||||
return self._mcu_type in Panda.H7_DEVICES
|
||||
|
||||
def get_serial(self):
|
||||
dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd0, 0, 0, 0x20)
|
||||
@@ -460,6 +483,9 @@ class Panda(object):
|
||||
def set_can_speed_kbps(self, bus, speed):
|
||||
self._handle.controlWrite(Panda.REQUEST_OUT, 0xde, bus, int(speed * 10), b'')
|
||||
|
||||
def set_can_data_speed_kbps(self, bus, speed):
|
||||
self._handle.controlWrite(Panda.REQUEST_OUT, 0xf9, bus, int(speed * 10), b'')
|
||||
|
||||
def set_uart_baud(self, uart, rate):
|
||||
self._handle.controlWrite(Panda.REQUEST_OUT, 0xe4, uart, int(rate / 300), b'')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user