projects
/
microwatt.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Merge pull request #183 from shawnanastasio/addpcis
[microwatt.git]
/
scripts
/
bin2hex.py
1
#!/usr/bin/python3
2
3
import
sys
4
import
subprocess
5
import
struct
6
7
with
open
(
sys
.
argv
[
1
],
"rb"
)
as
f
:
8
while True
:
9
word
=
f
.
read
(
8
)
10
if
len
(
word
) ==
8
:
11
print
(
"
%0
16x"
%
struct
.
unpack
(
'<Q'
,
word
));
12
elif
len
(
word
) ==
4
:
13
print
(
"00000000
%0
8x"
%
struct
.
unpack
(
'<I'
,
word
));
14
elif
len
(
word
) ==
0
:
15
exit
(
0
);
16
else
:
17
raise
Exception
(
"Bad length"
)