diff --git a/python/samples/flash.py b/python/samples/flash.py index 6134cfe..5248c79 100644 --- a/python/samples/flash.py +++ b/python/samples/flash.py @@ -8,14 +8,15 @@ def hexdump(s): def toprint(c): - if 32 <= ord(c) < 127: - return c + if 32 <= c < 127: + return chr(c) else: return "." def hexline(s): - return (" ".join(["%02x" % ord(c) for c in s]).ljust(49) + + bb = struct.unpack("16B", s) + return (" ".join(["%02x" % c for c in bb]).ljust(49) + "|" + - "".join([toprint(c) for c in s]).ljust(16) + + "".join([toprint(c) for c in bb]).ljust(16) + "|") return "\n".join([hexline(s[i:i+16]) for i in range(0, len(s), 16)]) @@ -38,6 +39,7 @@ def pattern(n): optdict = dict(optlist) s = SPIDriver(optdict.get('-h', "/dev/ttyUSB0")) + s.unsel() while True: s.sel() # start command