2 """ Convert the raw data in 'd' to an hex string with a space every 4 bytes.
5 for i
,c
in enumerate(d
):
7 hex_byte
= hex(byte
)[2:]
9 hex_byte
= '0' + hex_byte
12 bytes
.append(hex_byte
)
13 return ''.join(bytes
).strip()
15 def dataToHexUnified(d
):
16 """ Convert the raw data in 'd' to an hex string with a space every 4 bytes.
17 Each 4byte number is prefixed with 0x for easy sed/rx
18 Fixme: convert all MC tests to use this routine instead of the above
21 for i
,c
in enumerate(d
):
23 hex_byte
= hex(byte
)[2:]
25 hex_byte
= '0' + hex_byte
27 hex_byte
= '0x' + hex_byte
30 bytes
.append(hex_byte
)
31 return ''.join(bytes
).strip()
34 def HexDump(val
, numBits
=32):
37 2. Handle negatives and large numbers by mod (2^numBits)
38 3. print fixed length, prepend with zeros.
39 Length is exactly 2+(numBits/4)
41 so that they can be easily distinguished using sed/rx
43 val
= val
& (( 1 << numBits
) - 1)
44 newFmt
= "0x%0" + "%d" % (numBits
/ 4) + "x"