1.1 --- a/upload.py Sun Aug 23 20:02:09 2015 +0200
1.2 +++ b/upload.py Mon Aug 24 13:00:39 2015 +0200
1.3 @@ -86,15 +86,23 @@
1.4 if not verify_only:
1.5 writeToPort("P%05x%02x\n" % (addr, value))
1.6 resp = readFromPort()
1.7 - if resp != "P":
1.8 - print >>sys.stderr, "Program of location %04x failed: %s" % (addr, resp)
1.9 - return False
1.10 - else:
1.11 + if resp == "P":
1.12 + i += 1
1.13 + continue
1.14 + else:
1.15 + closePort()
1.16 + openPort()
1.17 +
1.18 + for attempt in "first", "second":
1.19 writeToPort("R%05x\n" % addr)
1.20 resp = readFromPort()
1.21 - if resp != "%02X" % value and resp != "%X" % value:
1.22 - print >>sys.stderr, "Verify of location %04x failed: %s" % (addr, resp)
1.23 - return False
1.24 + if resp == "%02X" % value or resp == "%X" % value:
1.25 + break
1.26 + closePort()
1.27 + openPort()
1.28 + else:
1.29 + print >>sys.stderr, "%s of location %05x failed: %s" % (verify_only and "Verify" or "Program", addr, resp)
1.30 + return False
1.31
1.32 i += 1
1.33