mirror of https://github.com/commaai/panda.git
parent
422e3e0c0f
commit
998a639360
|
@ -100,11 +100,14 @@ class PandaDFU:
|
||||||
def st_serial_to_dfu_serial(st: str, mcu_type: McuType = McuType.F4):
|
def st_serial_to_dfu_serial(st: str, mcu_type: McuType = McuType.F4):
|
||||||
if st is None or st == "none":
|
if st is None or st == "none":
|
||||||
return None
|
return None
|
||||||
uid_base = struct.unpack("H" * 6, bytes.fromhex(st))
|
try:
|
||||||
if mcu_type == McuType.H7:
|
uid_base = struct.unpack("H" * 6, bytes.fromhex(st))
|
||||||
return binascii.hexlify(struct.pack("!HHH", uid_base[1] + uid_base[5], uid_base[0] + uid_base[4], uid_base[3])).upper().decode("utf-8")
|
if mcu_type == McuType.H7:
|
||||||
else:
|
return binascii.hexlify(struct.pack("!HHH", uid_base[1] + uid_base[5], uid_base[0] + uid_base[4], uid_base[3])).upper().decode("utf-8")
|
||||||
return binascii.hexlify(struct.pack("!HHH", uid_base[1] + uid_base[5], uid_base[0] + uid_base[4] + 0xA, uid_base[3])).upper().decode("utf-8")
|
else:
|
||||||
|
return binascii.hexlify(struct.pack("!HHH", uid_base[1] + uid_base[5], uid_base[0] + uid_base[4] + 0xA, uid_base[3])).upper().decode("utf-8")
|
||||||
|
except struct.error:
|
||||||
|
return None
|
||||||
|
|
||||||
def get_mcu_type(self) -> McuType:
|
def get_mcu_type(self) -> McuType:
|
||||||
return self._mcu_type
|
return self._mcu_type
|
||||||
|
|
|
@ -402,7 +402,8 @@ class STBootloaderSPIHandle(BaseSTBootloaderHandle):
|
||||||
|
|
||||||
def get_chip_id(self) -> int:
|
def get_chip_id(self) -> int:
|
||||||
r = self._cmd(0x02, read_bytes=3)
|
r = self._cmd(0x02, read_bytes=3)
|
||||||
assert r[0] == 1 # response length - 1
|
if r[0] != 1: # response length - 1
|
||||||
|
raise PandaSpiException("incorrect response length")
|
||||||
return ((r[1] << 8) + r[2])
|
return ((r[1] << 8) + r[2])
|
||||||
|
|
||||||
def go_cmd(self, address: int) -> None:
|
def go_cmd(self, address: int) -> None:
|
||||||
|
|
Loading…
Reference in New Issue