mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 17:23:52 +08:00
fix graceful updating of old old boards
This commit is contained in:
@@ -184,7 +184,7 @@ class Panda(object):
|
||||
break
|
||||
except Exception:
|
||||
print("reconnecting is taking %d seconds..." % (i+1))
|
||||
if i == 14:
|
||||
if i == 13:
|
||||
try:
|
||||
dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial))
|
||||
dfu.recover()
|
||||
|
||||
@@ -21,7 +21,7 @@ class PandaDFU(object):
|
||||
this_dfu_serial = device._getASCIIStringDescriptor(3)
|
||||
except Exception:
|
||||
continue
|
||||
if this_dfu_serial == dfu_serial:
|
||||
if this_dfu_serial == dfu_serial or dfu_serial is None:
|
||||
self._handle = device.open()
|
||||
self.legacy = "07*128Kg" in self._handle.getASCIIStringDescriptor(4)
|
||||
return
|
||||
@@ -44,6 +44,8 @@ class PandaDFU(object):
|
||||
|
||||
@staticmethod
|
||||
def st_serial_to_dfu_serial(st):
|
||||
if st == None or st == "none":
|
||||
return None
|
||||
uid_base = struct.unpack("H"*6, st.decode("hex"))
|
||||
return struct.pack("!HHH", uid_base[1] + uid_base[5], uid_base[0] + uid_base[4] + 0xA, uid_base[3]).encode("hex").upper()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user