More output after checksum calc.
This commit is contained in:
parent
90957931f2
commit
6da125adbe
@ -9,16 +9,23 @@ FILE = sys.argv[1]
|
|||||||
|
|
||||||
print("Opening {}".format(FILE))
|
print("Opening {}".format(FILE))
|
||||||
|
|
||||||
|
csum_pre = 0
|
||||||
csum = 0
|
csum = 0
|
||||||
|
|
||||||
with open(FILE, "rb") as f:
|
with open(FILE, "rb") as f:
|
||||||
while True:
|
while True:
|
||||||
block = f.read(1024)
|
block = f.read(1024)
|
||||||
for c in block:
|
for c in block:
|
||||||
|
csum_pre = csum
|
||||||
csum += c
|
csum += c
|
||||||
csum &= 0xff
|
csum &= 0xff
|
||||||
if len(block) < 1024:
|
if len(block) < 1024:
|
||||||
print("End reached.")
|
print("End reached.")
|
||||||
break
|
break
|
||||||
|
|
||||||
print("Sum of all bytes: {}".format(csum))
|
print("Sum of all bytes: {:02x}".format(csum))
|
||||||
|
print("Sum without last: {:02x}".format(csum_pre))
|
||||||
|
|
||||||
|
expected_cksum = ( 0x100 - csum_pre ) & 0xff
|
||||||
|
|
||||||
|
print("Expected last byte: {:02x}".format(expected_cksum))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user