aboutsummaryrefslogtreecommitdiff
path: root/projects/hsm
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-12-20 22:30:41 -0500
committerRob Austein <sra@hactrn.net>2016-12-20 22:30:41 -0500
commitd492caaf91d37d7623a57e2d77d3d61fd8ffbda0 (patch)
tree5ebbdcf9b5d8540a894b58f0947c406af2a4ccbf /projects/hsm
parentde945510ca6304f3a2cf447567981784e6244dab (diff)
Flush output to serial device after writing.
Diffstat (limited to 'projects/hsm')
-rwxr-xr-xprojects/hsm/cryptech_upload3
1 files changed, 3 insertions, 0 deletions
diff --git a/projects/hsm/cryptech_upload b/projects/hsm/cryptech_upload
index d8d1186..17395ce 100755
--- a/projects/hsm/cryptech_upload
+++ b/projects/hsm/cryptech_upload
@@ -122,6 +122,7 @@ def _write(dst, data):
if numeric:
data = struct.pack("<I", data)
dst.write(data)
+ dst.flush()
if args.debug:
if numeric:
print("Wrote 0x{!s}".format(data.encode("hex")))
@@ -195,6 +196,7 @@ def send_file(src, size, args, dst):
if not data:
break
dst.write(data)
+ dst.flush()
print("Wrote {!s} bytes (chunk {!s}/{!s})".format(len(data), counter, int(size / chunk_size)))
# read ACK (a counter of number of 4k chunks received)
while True:
@@ -203,6 +205,7 @@ def send_file(src, size, args, dst):
break
print("ERROR: Did not receive an ACK, got {!r}".format(ack_bytes))
dst.write("\r") # eventually get back to the CLI prompt
+ dst.flush()
ack = struct.unpack("<I", ack_bytes)[0]
if ack != counter + 1:
print("ERROR: Did not receive the expected counter as ACK (got {!r}/{!r}, not {!r})".format(ack, ack_bytes, counter))