Skip to content

Commit d90e673

Browse files
authored
Merge pull request #59 from sparkfun/uploaderProgress
Add progress bar to uploader
2 parents aa2b614 + 5871ae3 commit d90e673

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

tools/artemis/artemis_svl.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
SVL_CMD_RETRY = 0x05 # request re-send frame
5454
SVL_CMD_DONE = 0x06 # finished - all data sent
5555

56+
# Global variables
57+
58+
barWidthInCharacters = 50 # Width of progress bar, ie [###### % complete
59+
5660

5761
# ***********************************************************************************
5862
#
@@ -205,6 +209,10 @@ def phase_bootload(ser):
205209

206210
total_frames = math.ceil(total_len/frame_size)
207211
curr_frame = 0
212+
progressChars = 0
213+
214+
if (not args.verbose):
215+
print("[", end = '')
208216

209217
verboseprint('\thave ' + str(total_len) + ' bytes to send in ' + str(total_frames) + ' frames')
210218

@@ -237,7 +245,16 @@ def phase_bootload(ser):
237245

238246
if( curr_frame <= total_frames ):
239247
frame_data = application[((curr_frame-1)*frame_size):((curr_frame-1+1)*frame_size)]
240-
verboseprint('\tsending frame #'+str(curr_frame)+', length: '+str(len(frame_data)))
248+
if(args.verbose):
249+
verboseprint('\tsending frame #'+str(curr_frame)+', length: '+str(len(frame_data)))
250+
else:
251+
percentComplete = curr_frame * 100 / total_frames
252+
percentCompleteInChars = math.ceil(percentComplete / 100 * barWidthInCharacters)
253+
while(progressChars < percentCompleteInChars):
254+
progressChars = progressChars + 1
255+
print('#', end='', flush=True)
256+
if (percentComplete == 100):
257+
print("]", end='')
241258

242259
send_packet(ser, SVL_CMD_FRAME, frame_data)
243260

@@ -246,9 +263,9 @@ def phase_bootload(ser):
246263
bl_done = True
247264

248265
if( bl_failed == False ):
249-
twopartprint('\n\t', 'Upload complete')
266+
twopartprint('\n\t', ' Upload complete')
250267
else:
251-
twopartprint('\n\t', 'Upload failed')
268+
twopartprint('\n\t', ' Upload failed')
252269

253270
return bl_failed
254271

tools/artemis/linux/artemis_svl

-440 Bytes
Binary file not shown.

tools/artemis/macosx/artemis_svl

2.08 KB
Binary file not shown.

tools/artemis/windows/artemis_svl.exe

2.13 KB
Binary file not shown.

0 commit comments

Comments
 (0)