From 9c7f006d478d1e906919d84bdbc76057a8ef0897 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 7 May 2019 14:49:34 -0400 Subject: [PATCH] tools/upload: make I/O a bit slower Without delays between read/writes, I often add lockups. --- tools/upload.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/upload.py b/tools/upload.py index 5d7c205..0f8a27c 100755 --- a/tools/upload.py +++ b/tools/upload.py @@ -8,6 +8,7 @@ import argparse import os import sys +import time def sendcmd(fd, cmd): # The serial link echoes back all typed characters and expects us to read @@ -35,7 +36,11 @@ def main(): print("Loading...") with open(args.filename, 'rb') as fp: fcontents = fp.read() - os.write(fd, fcontents) + for c in fcontents: + os.write(fd, bytes([c])) + # Let's give the machine a bit of time to breathe. We ain't in a + # hurry now, are we? + time.sleep(0.0001) print("Loaded") os.read(fd, 5) print("Peeking back...") @@ -43,6 +48,7 @@ def main(): peek = b'' while len(peek) < st.st_size * 2: peek += os.read(fd, 1) + time.sleep(0.0001) os.close(fd) print("Got {}".format(peek.decode())) print("Comparing...")