@@ -471,7 +471,7 @@ class WEBUSBDFU_protocol extends EventTarget {
471471 } ;
472472 return memory ;
473473 } ;
474- const chipInfo = descriptors . map ( parseDescriptor ) . reduce ( ( o , v , i ) => {
474+ const chipInfo = descriptors . map ( parseDescriptor ) . reduce ( ( o , v ) => {
475475 o [ v . type . toLowerCase ( ) . replace ( " " , "_" ) ] = v ;
476476 return o ;
477477 } , { } ) ;
@@ -500,7 +500,7 @@ class WEBUSBDFU_protocol extends EventTarget {
500500 }
501501 } )
502502 . catch ( ( error ) => {
503- console . log ( `${ this . logHead } USB controlTransfer IN failed for request: ${ request } ` ) ;
503+ console . log ( `${ this . logHead } USB controlTransfer IN failed for request: ${ request } ( ${ error } ) ` ) ;
504504 callback ( [ ] , 1 ) ;
505505 } ) ;
506506 } else {
@@ -525,7 +525,7 @@ class WEBUSBDFU_protocol extends EventTarget {
525525 }
526526 } )
527527 . catch ( ( error ) => {
528- console . log ( `${ this . logHead } USB controlTransfer OUT failed for request: ${ request } ` ) ;
528+ console . log ( `${ this . logHead } USB controlTransfer OUT failed for request: ${ request } ( ${ error } ) ` ) ;
529529 } ) ;
530530 }
531531 }
@@ -900,7 +900,7 @@ class WEBUSBDFU_protocol extends EventTarget {
900900 const spans_page = hexData . address < page_start && end_address > page_end ;
901901
902902 if ( starts_in_page || ends_in_page || spans_page ) {
903- const idx = erase_pages . findIndex ( ( element , index , array ) => {
903+ const idx = erase_pages . findIndex ( ( element ) => {
904904 return element . sector === i && element . page === j ;
905905 } ) ;
906906 if ( idx === - 1 ) {
@@ -1161,31 +1161,23 @@ class WEBUSBDFU_protocol extends EventTarget {
11611161 ? this . transferSize
11621162 : this . hex . data [ reading_block ] . bytes - bytes_verified ;
11631163
1164- this . controlTransfer (
1165- "in" ,
1166- this . request . UPLOAD ,
1167- wBlockNum ++ ,
1168- 0 ,
1169- bytes_to_read ,
1170- 0 ,
1171- ( data , code ) => {
1172- for ( const piece of data ) {
1173- this . verify_hex [ reading_block ] . push ( piece ) ;
1174- }
1164+ this . controlTransfer ( "in" , this . request . UPLOAD , wBlockNum ++ , 0 , bytes_to_read , 0 , ( data ) => {
1165+ for ( const piece of data ) {
1166+ this . verify_hex [ reading_block ] . push ( piece ) ;
1167+ }
11751168
1176- address += bytes_to_read ;
1177- bytes_verified += bytes_to_read ;
1178- bytes_verified_total += bytes_to_read ;
1169+ address += bytes_to_read ;
1170+ bytes_verified += bytes_to_read ;
1171+ bytes_verified_total += bytes_to_read ;
11791172
1180- // update progress bar
1181- TABS . firmware_flasher . flashProgress (
1182- ( ( this . hex . bytes_total + bytes_verified_total ) / ( this . hex . bytes_total * 2 ) ) * 100 ,
1183- ) ;
1173+ // update progress bar
1174+ TABS . firmware_flasher . flashProgress (
1175+ ( ( this . hex . bytes_total + bytes_verified_total ) / ( this . hex . bytes_total * 2 ) ) * 100 ,
1176+ ) ;
11841177
1185- // verify another page
1186- read ( ) ;
1187- } ,
1188- ) ;
1178+ // verify another page
1179+ read ( ) ;
1180+ } ) ;
11891181 } else {
11901182 if ( reading_block < blocks ) {
11911183 // move to another block
@@ -1261,7 +1253,7 @@ class WEBUSBDFU_protocol extends EventTarget {
12611253 this . loadAddress ( address , ( ) => {
12621254 // 'downloading' 0 bytes to the program start address followed by a GETSTATUS is used to trigger DFU exit on STM32
12631255 this . controlTransfer ( "out" , this . request . DNLOAD , 0 , 0 , 0 , 0 , ( ) => {
1264- this . controlTransfer ( "in" , this . request . GETSTATUS , 0 , 0 , 6 , 0 , ( data ) => {
1256+ this . controlTransfer ( "in" , this . request . GETSTATUS , 0 , 0 , 6 , 0 , ( ) => {
12651257 this . cleanup ( ) ;
12661258 } ) ;
12671259 } ) ;
0 commit comments