diff --git a/editor/flash.ts b/editor/flash.ts index ad93e8081..b1c37aaa6 100644 --- a/editor/flash.ts +++ b/editor/flash.ts @@ -313,13 +313,7 @@ class DAPWrapper implements pxt.packetio.PacketIOWrapper { await this.io.reconnectAsync() - // before calling into dapjs, push through a few commands to make sure the responses - // to commands from previous sessions (if any) are flushed. Count of 5 is arbitrary. - for (let i = 0; i < 5; i++) { - try { - await this.getDaplinkVersionAsync(); - } catch (e) {} - } + await this.clearCommandsAsync() // halt before reading from dap // to avoid interference from data logger @@ -356,6 +350,16 @@ class DAPWrapper implements pxt.packetio.PacketIOWrapper { this.startReadSerial(connectionId) } + private async clearCommandsAsync() { + // before calling into dapjs, push through a few commands to make sure the responses + // to commands from previous sessions (if any) are flushed. Count of 5 is arbitrary. + for (let i = 0; i < 5; i++) { + try { + await this.getDaplinkVersionAsync(); + } catch (e) {} + } + } + private async getDaplinkVersionAsync() { return await this.dapCmdNums(0x00, 0x04); } @@ -403,6 +407,7 @@ class DAPWrapper implements pxt.packetio.PacketIOWrapper { await this.io.reconnectAsync(); } + await this.clearCommandsAsync() await this.stopReadersAsync(); await this.cortexM.init(); await this.cortexM.reset(true); diff --git a/package.json b/package.json index d10a98235..554cac818 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,6 @@ }, "dependencies": { "pxt-common-packages": "12.0.3", - "pxt-core": "10.2.13" + "pxt-core": "10.2.15" } }