more reliability for flashing, print bootstub version
@@ -155,9 +155,17 @@ class Panda(object):
except Exception:
pass
if not enter_bootloader:
+ self.close()
time.sleep(1.0)
+ try:
+ self.connect()
+ except Exception:
+ # retry after 5 seconds
+ print("connecting to bootstub is taking a while...")
+ time.sleep(5.0)
self.connect()
+
def flash(self, fn=None):
if not self.bootstub:
self.reset(enter_bootstub=True)
@@ -172,6 +180,9 @@ class Panda(object):
with open(fn) as f:
dat = f.read()
+ # get version
+ print("flash: version is "+self.get_version())
+
# confirm flasher is present
fr = self._handle.controlRead(Panda.REQUEST_IN, 0xb0, 0, 0, 0xc)
assert fr[4:8] == "\xde\xad\xd0\x0d"
@@ -247,6 +258,9 @@ class Panda(object):
print(e)
pass
+ def get_version(self):
+ return self._handle.controlRead(Panda.REQUEST_IN, 0xd6, 0, 0, 0x40)
+
def get_serial(self):
dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd0, 0, 0, 0x20)
hashsig, calc_hash = dat[0x1c:], hashlib.sha1(dat[0:0x1c]).digest()[0:4]
