1
0
mirror of https://github.com/antonblanchard/microwatt.git synced 2026-02-03 15:12:52 +00:00
Files
antonblanchard.microwatt/rust_lib_demo/bin2hex.py
Tom Vijlbrief ae55f5efbd Add Rust demo
Signed-off-by: Tom Vijlbrief <tvijlbrief@gmail.com>
2020-04-16 17:16:37 +10:00

18 lines
459 B
Python
Executable File

#!/usr/bin/python3
import sys
import subprocess
import struct
with open(sys.argv[1], "rb") as f:
while True:
word = f.read(8)
if len(word) == 8:
print("%016x" % struct.unpack('Q', word));
elif len(word) == 4:
print("00000000%08x" % struct.unpack('I', word));
elif len(word) == 0:
exit(0);
else:
raise Exception("Bad length")