aboutsummaryrefslogtreecommitdiff
path: root/projects/hsm/cryptech_probe
diff options
context:
space:
mode:
Diffstat (limited to 'projects/hsm/cryptech_probe')
-rwxr-xr-xprojects/hsm/cryptech_probe10
1 files changed, 8 insertions, 2 deletions
diff --git a/projects/hsm/cryptech_probe b/projects/hsm/cryptech_probe
index 3d14484..68bcfd1 100755
--- a/projects/hsm/cryptech_probe
+++ b/projects/hsm/cryptech_probe
@@ -38,9 +38,15 @@ goes to stderr.
import sys
import time
import argparse
-import binascii
import serial.tools.list_ports_posix
+if sys.version_info.major == 2:
+ def colon_hex(raw):
+ return ":".join("{:02x}".format(ord(b)) for b in raw)
+else:
+ def colon_hex(raw):
+ return ":".join("{:02x}".format(b) for b in raw)
+
class positive_integer(int):
def __init__(self, value):
if self <= 0:
@@ -102,7 +108,7 @@ for port in ports:
response = tty.read(args.read_buffer_size)
if args.debug:
- sys.stderr.write("Received from {}: {!r} ({})\n".format(port, response, ":".join(binascii.hexlify(c) for c in response)))
+ sys.stderr.write("Received from {}: {!r} ({})\n".format(port, response, colon_hex(response)))
# Check whether we got a known console prompt.