Skip to content

Commit 75bab41

Browse files
Make uf2conf.py flush STDOUT for real-time updates (#1194)
Without flushing STDOUT, the upload script's output aften are buffered and not displayed until it completes. Add in flush commands to allow the IDE to display status as it changes.
1 parent 36e0b4a commit 75bab41

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/uf2conv.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ def error(msg):
364364
if str(args.serial).startswith("/dev/tty") or str(args.serial).startswith("COM") or str(args.serial).startswith("/dev/cu"):
365365
try:
366366
print("Resetting " + str(args.serial))
367+
sys.stdout.flush()
367368
try:
368369
ser = serial.Serial()
369370
ser.port = args.serial
@@ -401,11 +402,14 @@ def error(msg):
401402
outbuf = convert_to_uf2(inpbuf)
402403
print("Converting to %s, output size: %d, start address: 0x%x" %
403404
(ext, len(outbuf), appstartaddr))
405+
sys.stdout.flush()
404406
if args.convert or ext != "uf2":
405407
drives = []
406408
if args.output == None:
407409
args.output = "flash." + ext
408410
else:
411+
print("Scanning for RP2040 devices")
412+
sys.stdout.flush()
409413
now = time.time()
410414
drives = []
411415
while (time.time() - now < 10.0) and (len(drives) == 0):
@@ -419,6 +423,7 @@ def error(msg):
419423
error("No drive to deploy.")
420424
for d in drives:
421425
print("Flashing %s (%s)" % (d, board_id(d)))
426+
sys.stdout.flush()
422427
write_file(d + "/NEW.UF2", outbuf)
423428

424429
# Wait until serial port (if defined) re-appears, or 2s timeout unless UF2 drive direct upload

0 commit comments

Comments
 (0)