[Cryptech-Commits] [sw/stm32] 02/02: Flush output to serial device after writing.

git at cryptech.is git at cryptech.is
Wed Dec 21 04:28:51 UTC 2016


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch ksng
in repository sw/stm32.

commit d492caaf91d37d7623a57e2d77d3d61fd8ffbda0
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Tue Dec 20 22:30:41 2016 -0500

    Flush output to serial device after writing.
---
 projects/hsm/cryptech_upload | 3 +++
 1 file changed, 3 insertions(+)

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))



More information about the Commits mailing list