Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear previous commands before starting flash as well #5856

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions editor/flash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,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
Expand Down Expand Up @@ -355,6 +349,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);
}
Expand Down Expand Up @@ -402,6 +406,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);
Expand Down
Loading