pxt-microbit 5.1.3 → 5.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/built/editor.js CHANGED
@@ -3373,7 +3373,18 @@ class DAPWrapper {
3373
3373
  isConnecting() {
3374
3374
  return this.io.isConnecting() || (this.io.isConnected() && !this.initialized);
3375
3375
  }
3376
+ async getBaudRate() {
3377
+ const readSerialSettings = new Uint8Array([0x81]); // get serial settings
3378
+ const serialSettings = await this.dapCmd(readSerialSettings);
3379
+ const baud = (serialSettings[4] << 24) + (serialSettings[3] << 16) + (serialSettings[2] << 8) + serialSettings[1];
3380
+ return baud;
3381
+ }
3376
3382
  async setBaudRate() {
3383
+ const currentBaudRate = await this.getBaudRate();
3384
+ if (currentBaudRate === 115200) {
3385
+ log(`baud rate already set to 115200`);
3386
+ return;
3387
+ }
3377
3388
  log(`set baud rate to 115200`);
3378
3389
  const baud = new Uint8Array(5);
3379
3390
  baud[0] = 0x82; // set baud