Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit 94deda9

Browse files
baud rate for restoration
1 parent 040d227 commit 94deda9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/serialmonitor/serialMonitor.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class SerialMonitor implements vscode.Disposable {
3232
private extensionContext: vscode.ExtensionContext;
3333
private currentPort: string;
3434
private activePort: Port | undefined;
35+
private lastSelectedBaudRate: number = 9600; // arbitrary default.
3536

3637
private openPortStatusBar: vscode.StatusBarItem;
3738
private portsStatusBar: vscode.StatusBarItem;
@@ -126,10 +127,11 @@ export class SerialMonitor implements vscode.Disposable {
126127
return undefined;
127128
}
128129
const selectedRate: number = parseInt(chosen, 10);
130+
this.lastSelectedBaudRate = selectedRate;
129131
return selectedRate;
130132
}
131133

132-
public async openSerialMonitor(): Promise<void> {
134+
public async openSerialMonitor(restore: boolean = false): Promise<void> {
133135
if (!this.currentPort) {
134136
const ans = await vscode.window.showInformationMessage("No serial port was selected, please select a serial port first", "Yes", "No");
135137
if (ans === "Yes") {
@@ -142,7 +144,8 @@ export class SerialMonitor implements vscode.Disposable {
142144
}
143145
}
144146

145-
const baudRate = await this.selectBaudRate();
147+
// if we're restoring, we want to use the most recent baud rate selected, rather than popping UI.
148+
const baudRate = restore ? this.lastSelectedBaudRate : await this.selectBaudRate();
146149

147150
if (!baudRate) {
148151
return;
@@ -168,11 +171,10 @@ export class SerialMonitor implements vscode.Disposable {
168171
}
169172

170173
public async closeSerialMonitor(port?: string): Promise<boolean> {
171-
await this.serialMonitorApi.stopMonitoringPort(port ?? this.currentPort);
174+
const closed = await this.serialMonitorApi.stopMonitoringPort(port ?? this.currentPort);
172175
this.updatePortStatus(false);
173176

174-
// TODO: Update API to return a boolean acknowledging whether monitor session was closed.
175-
return true;
177+
return closed;
176178
}
177179

178180
public dispose() {

0 commit comments

Comments
 (0)