5353SVL_CMD_RETRY = 0x05 # request re-send frame
5454SVL_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 ('\t have ' + 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 ('\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 = '' )
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
0 commit comments