53
53
SVL_CMD_RETRY = 0x05 # request re-send frame
54
54
SVL_CMD_DONE = 0x06 # finished - all data sent
55
55
56
+ # Global variables
57
+
58
+ barWidthInCharacters = 50 # Width of progress bar, ie [###### % complete
59
+
56
60
57
61
# ***********************************************************************************
58
62
#
@@ -205,6 +209,10 @@ def phase_bootload(ser):
205
209
206
210
total_frames = math .ceil (total_len / frame_size )
207
211
curr_frame = 0
212
+ progressChars = 0
213
+
214
+ if (not args .verbose ):
215
+ print ("[" , end = '' )
208
216
209
217
verboseprint ('\t have ' + str (total_len ) + ' bytes to send in ' + str (total_frames ) + ' frames' )
210
218
@@ -237,7 +245,16 @@ def phase_bootload(ser):
237
245
238
246
if ( curr_frame <= total_frames ):
239
247
frame_data = application [((curr_frame - 1 )* frame_size ):((curr_frame - 1 + 1 )* frame_size )]
240
- verboseprint ('\t sending frame #' + str (curr_frame )+ ', length: ' + str (len (frame_data )))
248
+ if (args .verbose ):
249
+ verboseprint ('\t sending 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 = '' )
241
258
242
259
send_packet (ser , SVL_CMD_FRAME , frame_data )
243
260
@@ -246,9 +263,9 @@ def phase_bootload(ser):
246
263
bl_done = True
247
264
248
265
if ( bl_failed == False ):
249
- twopartprint ('\n \t ' , 'Upload complete' )
266
+ twopartprint ('\n \t ' , ' Upload complete' )
250
267
else :
251
- twopartprint ('\n \t ' , 'Upload failed' )
268
+ twopartprint ('\n \t ' , ' Upload failed' )
252
269
253
270
return bl_failed
254
271
0 commit comments