Skip to content

WebUSB: On serial connection check baud rate before setting it. #1103

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

Merged
merged 1 commit into from
Feb 27, 2023
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
6 changes: 5 additions & 1 deletion src/device/dap-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ export class DAPWrapper {
}

async startSerial(listener: (data: string) => void): Promise<void> {
await this.daplink.setSerialBaudrate(115200);
const currentBaud = await this.daplink.getSerialBaudrate();
if (currentBaud !== 115200) {
// Changing the baud rate causes a micro:bit reset, so only do it if necessary
await this.daplink.setSerialBaudrate(115200);
}
this.daplink.on(DAPLink.EVENT_SERIAL_DATA, listener);
await this.daplink.startSerialRead(1);
}
Expand Down