Skip to content

Commit

Permalink
tools/flasher.py runs on Python 2 and 3 now
Browse files Browse the repository at this point in the history
  • Loading branch information
rsta2 committed Jun 12, 2018
1 parent ef075fc commit e3ce066
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/flasher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import serial
import sys
import time
import math

try:
fileaddress = ' '.join(sys.argv[1:2])
Expand All @@ -23,7 +24,7 @@
exit()

try:
F = open(fileaddress,"r")
F = open(fileaddress,"rb")
F.seek(0, 2)
size = F.tell()
F.seek(0, 0)
Expand All @@ -36,11 +37,11 @@
sys.stdout.flush()

try:
blocksize = flashbaud / 5
blocksize = math.trunc(flashbaud / 5)
offset = 0
while offset < size:
if sys.stdout.isatty():
percent = offset * 100 / size
percent = math.trunc(offset * 100 / size)
print("\r" + str(percent) + "%"),
sys.stdout.flush()
readlen = blocksize
Expand All @@ -54,7 +55,7 @@
print("Completed!\nRunning app...")
sys.stdout.flush()
time.sleep(1)
ser.write("g")
ser.write(b"g")
except Exception:
print("ERROR: Serial port disconnected. Check connections!")
F.close()
Expand Down

0 comments on commit e3ce066

Please sign in to comment.