@@ -471,7 +471,7 @@ class WEBUSBDFU_protocol extends EventTarget {
471
471
} ;
472
472
return memory ;
473
473
} ;
474
- const chipInfo = descriptors . map ( parseDescriptor ) . reduce ( ( o , v , i ) => {
474
+ const chipInfo = descriptors . map ( parseDescriptor ) . reduce ( ( o , v ) => {
475
475
o [ v . type . toLowerCase ( ) . replace ( " " , "_" ) ] = v ;
476
476
return o ;
477
477
} , { } ) ;
@@ -500,7 +500,7 @@ class WEBUSBDFU_protocol extends EventTarget {
500
500
}
501
501
} )
502
502
. 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 } ) ` ) ;
504
504
callback ( [ ] , 1 ) ;
505
505
} ) ;
506
506
} else {
@@ -525,7 +525,7 @@ class WEBUSBDFU_protocol extends EventTarget {
525
525
}
526
526
} )
527
527
. 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 } ) ` ) ;
529
529
} ) ;
530
530
}
531
531
}
@@ -900,7 +900,7 @@ class WEBUSBDFU_protocol extends EventTarget {
900
900
const spans_page = hexData . address < page_start && end_address > page_end ;
901
901
902
902
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 ) => {
904
904
return element . sector === i && element . page === j ;
905
905
} ) ;
906
906
if ( idx === - 1 ) {
@@ -1161,31 +1161,23 @@ class WEBUSBDFU_protocol extends EventTarget {
1161
1161
? this . transferSize
1162
1162
: this . hex . data [ reading_block ] . bytes - bytes_verified ;
1163
1163
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
+ }
1175
1168
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 ;
1179
1172
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
+ ) ;
1184
1177
1185
- // verify another page
1186
- read ( ) ;
1187
- } ,
1188
- ) ;
1178
+ // verify another page
1179
+ read ( ) ;
1180
+ } ) ;
1189
1181
} else {
1190
1182
if ( reading_block < blocks ) {
1191
1183
// move to another block
@@ -1261,7 +1253,7 @@ class WEBUSBDFU_protocol extends EventTarget {
1261
1253
this . loadAddress ( address , ( ) => {
1262
1254
// 'downloading' 0 bytes to the program start address followed by a GETSTATUS is used to trigger DFU exit on STM32
1263
1255
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 , ( ) => {
1265
1257
this . cleanup ( ) ;
1266
1258
} ) ;
1267
1259
} ) ;
0 commit comments