File tree 1 file changed +12
-0
lines changed
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -264,7 +264,19 @@ class DAPWrapper implements pxt.packetio.PacketIOWrapper {
264
264
return this . io . isConnecting ( ) || ( this . io . isConnected ( ) && ! this . initialized )
265
265
}
266
266
267
+ private async getBaudRate ( ) {
268
+ const readSerialSettings = new Uint8Array ( [ 0x81 ] ) // get serial settings
269
+ const serialSettings = await this . dapCmd ( readSerialSettings )
270
+ const baud = ( serialSettings [ 4 ] << 24 ) + ( serialSettings [ 3 ] << 16 ) + ( serialSettings [ 2 ] << 8 ) + serialSettings [ 1 ]
271
+ return baud
272
+ }
273
+
267
274
private async setBaudRate ( ) {
275
+ const currentBaudRate = await this . getBaudRate ( )
276
+ if ( currentBaudRate === 115200 ) {
277
+ log ( `baud rate already set to 115200` )
278
+ return
279
+ }
268
280
log ( `set baud rate to 115200` )
269
281
const baud = new Uint8Array ( 5 )
270
282
baud [ 0 ] = 0x82 // set baud
You can’t perform that action at this time.
0 commit comments