summaryrefslogtreecommitdiff
path: root/test/Scripts/common_dump.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/Scripts/common_dump.py')
-rw-r--r--test/Scripts/common_dump.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/Scripts/common_dump.py b/test/Scripts/common_dump.py
new file mode 100644
index 0000000000..444b389dd0
--- /dev/null
+++ b/test/Scripts/common_dump.py
@@ -0,0 +1,13 @@
+def dataToHex(d):
+ """ Convert the raw data in 'd' to an hex string with a space every 4 bytes.
+ """
+ bytes = []
+ for i,c in enumerate(d):
+ byte = ord(c)
+ hex_byte = hex(byte)[2:]
+ if byte <= 0xf:
+ hex_byte = '0' + hex_byte
+ if i % 4 == 3:
+ hex_byte += ' '
+ bytes.append(hex_byte)
+ return ''.join(bytes).strip()