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

Commit 8ea053e

Browse files
authored
Merge branch 'main' into patch-1
2 parents ec7eaef + 970615a commit 8ea053e

10 files changed

+101
-35
lines changed

.github/workflows/build.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ name: CI
66
on:
77
push:
88
branches:
9-
- master
10-
- dev
9+
- main
10+
- release
1111
tags:
1212
- v*
1313
pull_request:
1414
branches:
15-
- master
16-
- dev
15+
- main
16+
- release
1717

1818
jobs:
1919
build:

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## Version 0.4.9
5+
6+
- Release date: January 12, 2022
7+
8+
### Changed
9+
10+
- vid and pid for Adafruit Grand Central M4 (SAMD51) [#1218](https://github.com/microsoft/vscode-arduino/pull/1218)
11+
- Add clear output on build option [#1057](https://github.com/microsoft/vscode-arduino/pull/1057)
12+
- Added buffering to prevent heavy logging issues [#1412](https://github.com/microsoft/vscode-arduino/pull/1412)
13+
414
## Version 0.4.8
515

616
- Release date: November 9, 2021

CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ There are many ways that you can contribute, beyond writing code. The goal of th
88

99
If you are interested in writing code to fix issues, first look at the issues with the [help-wanted](https://github.com/Microsoft/vscode-arduino/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) label. They should have the context and code pointers needed to get started. If not, then feel free to ask for some, and we will be happy to provide any guidance you need.
1010

11-
When you are doing code fix, please work against [dev](https://github.com/microsoft/vscode-arduino/tree/dev)
12-
branch and also submit pull request to `dev` branch.
13-
Changes will be merged into `master` branch after production release.
11+
When you are doing code fix, please work against [main](https://github.com/microsoft/vscode-arduino/tree/main)
12+
branch and also submit pull request to `main` branch.
13+
Changes will be merged into `release` branch after production release.
1414

1515

1616

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Visual Studio Code extension for Arduino
22

33
[![Gitter](https://img.shields.io/badge/chat-on%20gitter-blue.svg)](https://gitter.im/Microsoft/vscode-arduino)
4-
[![Travis CI](https://travis-ci.org/Microsoft/vscode-arduino.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-arduino)
54

65
Welcome to the Visual Studio Code extension for **Arduino** <sup>preview</sup> ! The Arduino extension makes it easy to develop, build, deploy and debug your Arduino sketches in Visual Studio Code, with a rich set of functionalities. These include:
76

@@ -121,7 +120,7 @@ The following settings are as per sketch settings of the Arduino extension. You
121120
- `port` - Name of the serial port connected to the device. Can be set by the `Arduino: Select Serial Port` command. For Mac users could be "/dev/cu.wchusbserial1420".
122121
- `board` - Currently selected Arduino board alias. Can be set by the `Arduino: Change Board Type` command. Also, you can find the board list there.
123122
- `output` - Arduino build output path. If not set, Arduino will create a new temporary output folder each time, which means it cannot reuse the intermediate result of the previous build leading to long verify/upload time, so it is recommended to set the field. Arduino requires that the output path should not be the workspace itself or in a subfolder of the workspace, otherwise, it may not work correctly. By default, this option is not set. It's worth noting that the contents of this file could be deleted during the build process, so pick (or create) a directory that will not store files you want to keep.
124-
- `debugger` - The short name of the debugger that will be used when the board itself does not have a debugger and there is more than one debugger available. You can find the list of debuggers [here](https://github.com/Microsoft/vscode-arduino/blob/master/misc/debuggerUsbMapping.json). By default, this option is not set.
123+
- `debugger` - The short name of the debugger that will be used when the board itself does not have a debugger and there is more than one debugger available. You can find the list of debuggers [here](https://github.com/Microsoft/vscode-arduino/blob/release/misc/debuggerUsbMapping.json). By default, this option is not set.
125124
- `prebuild` - External command which will be invoked before any sketch build (verify, upload, ...). For details see the [Pre- and Post-Build Commands](#Pre--and-Post-Build-Commands) section.
126125
- `postbuild` - External command to be run after the sketch has been built successfully. See the afore mentioned section for more details.
127126
- `intelliSenseGen` - Override the global setting for auto-generation of the IntelliSense configuration (i.e. `.vscode/c_cpp_properties.json`). Three options are available:
@@ -204,7 +203,7 @@ Steps to start debugging:
204203
> To learn more about how to debug Arduino code, visit our [team blog](https://blogs.msdn.microsoft.com/iotdev/2017/05/27/debug-your-arduino-code-with-visual-studio-code/).
205204
206205
## Change Log
207-
See the [Change log](https://github.com/Microsoft/vscode-arduino/blob/master/CHANGELOG.md) for details about the changes in each version.
206+
See the [Change log](https://github.com/Microsoft/vscode-arduino/blob/release/CHANGELOG.md) for details about the changes in each version.
208207

209208
## Supported Operating Systems
210209
Currently this extension supports the following operating systems:
@@ -242,7 +241,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
242241
The [Microsoft Enterprise and Developer Privacy Statement](https://www.microsoft.com/en-us/privacystatement/EnterpriseDev/default.aspx) describes the privacy statement of this software.
243242

244243
## License
245-
This extension is licensed under the [MIT License](https://github.com/Microsoft/vscode-arduino/blob/master/LICENSE.txt). Please see the [Third Party Notice](https://github.com/Microsoft/vscode-arduino/blob/master/ThirdPartyNotices.txt) file for additional copyright notices and terms.
244+
This extension is licensed under the [MIT License](https://github.com/Microsoft/vscode-arduino/blob/release/LICENSE.txt). Please see the [Third Party Notice](https://github.com/Microsoft/vscode-arduino/blob/release/ThirdPartyNotices.txt) file for additional copyright notices and terms.
246245

247246
## Contact Us
248247
If you would like to help build the best Arduino experience with VS Code, you can reach us directly at [gitter chat room](https://gitter.im/Microsoft/vscode-arduino).

azure-pipelines.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ parameters:
1414
- real
1515

1616
pr:
17-
- master
18-
- dev
17+
- main
18+
- release
1919

2020
trigger:
2121
branches:
2222
include:
23-
- master
24-
- dev
23+
- main
24+
- release
2525
tags:
2626
include:
2727
- v*
@@ -33,12 +33,12 @@ variables:
3333
# MicroBuild requires TeamName to be set.
3434
TeamName: C++ Cross Platform and Cloud
3535
# If the user didn't override the signing type, then only real-sign on tags,
36-
# master, or dev.
36+
# main, or release.
3737
${{ if ne(parameters.SignTypeOverride, 'default') }}:
3838
SignType: ${{ parameters.SignTypeOverride }}
39-
${{ if and(eq(parameters.SignTypeOverride, 'default'), or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), eq(variables['Build.SourceBranchName'], 'master'), eq(variables['Build.SourceBranchName'], 'dev'))) }}:
39+
${{ if and(eq(parameters.SignTypeOverride, 'default'), or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), eq(variables['Build.SourceBranchName'], 'main'), eq(variables['Build.SourceBranchName'], 'release'))) }}:
4040
SignType: real
41-
${{ if and(eq(parameters.SignTypeOverride, 'default'), not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), eq(variables['Build.SourceBranchName'], 'master'), eq(variables['Build.SourceBranchName'], 'dev')))) }}:
41+
${{ if and(eq(parameters.SignTypeOverride, 'default'), not(or(startsWith(variables['Build.SourceBranch'], 'refs/tags'), eq(variables['Build.SourceBranchName'], 'main'), eq(variables['Build.SourceBranchName'], 'release')))) }}:
4242
SignType: test
4343

4444
steps:

package-lock.json

+3-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-arduino",
33
"displayName": "Arduino",
44
"description": "Arduino for Visual Studio Code",
5-
"version": "0.4.8",
5+
"version": "0.4.9",
66
"publisher": "vsciot-vscode",
77
"aiKey": "83dd2c27-6594-41d3-85a9-bdb22070eb42",
88
"preview": true,
@@ -18,7 +18,7 @@
1818
"bugs": {
1919
"url": "https://github.com/Microsoft/vscode-arduino/issues"
2020
},
21-
"homepage": "https://github.com/Microsoft/vscode-arduino/blob/master/README.md",
21+
"homepage": "https://github.com/Microsoft/vscode-arduino/blob/release/README.md",
2222
"categories": [
2323
"Programming Languages",
2424
"Debuggers",

src/serialmonitor/outputBuffer.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
import { performance } from "perf_hooks";
5+
import * as vscode from "vscode";
6+
7+
export class BufferedOutputChannel implements vscode.Disposable {
8+
private _buffer: string[];
9+
private _timer: NodeJS.Timer;
10+
private _lastFlushTime: number;
11+
12+
public constructor(private readonly outputCallback: (value: string) => void, private readonly flushIntervalMs: number) {
13+
this._buffer = [];
14+
this._timer = setInterval(() => this.tryFlush(), this.flushIntervalMs);
15+
this._lastFlushTime = Number.NEGATIVE_INFINITY;
16+
}
17+
18+
public append(value: string) {
19+
this.add(value);
20+
}
21+
22+
public appendLine(value: string) {
23+
this.add(value + "\n");
24+
}
25+
26+
public dispose() {
27+
this.tryFlush();
28+
clearInterval(this._timer);
29+
}
30+
31+
private add(value: string) {
32+
this._buffer.push(value);
33+
this.tryFlush();
34+
}
35+
36+
private tryFlush() {
37+
const currentTime = performance.now();
38+
if (this._buffer.length > 0 && currentTime - this._lastFlushTime > this.flushIntervalMs) {
39+
this.outputCallback(this._buffer.join(""));
40+
this._lastFlushTime = currentTime;
41+
this._buffer = [];
42+
}
43+
}
44+
}

src/serialmonitor/serialMonitor.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import ArduinoContext from "../arduinoContext";
66
import * as constants from "../common/constants";
77
import { DeviceContext } from "../deviceContext";
88
import * as Logger from "../logger/logger";
9+
import { BufferedOutputChannel } from "./outputBuffer";
910
import { SerialPortCtrl } from "./serialportctrl";
1011

1112
export interface ISerialPortDetail {
@@ -49,6 +50,8 @@ export class SerialMonitor implements vscode.Disposable {
4950

5051
private _outputChannel: vscode.OutputChannel;
5152

53+
private _bufferedOutputChannel: BufferedOutputChannel;
54+
5255
public initialize() {
5356
let defaultBaudRate;
5457
if (ArduinoContext.arduinoApp && ArduinoContext.arduinoApp.settings && ArduinoContext.arduinoApp.settings.defaultBaudRate) {
@@ -57,6 +60,7 @@ export class SerialMonitor implements vscode.Disposable {
5760
defaultBaudRate = SerialMonitor.DEFAULT_BAUD_RATE;
5861
}
5962
this._outputChannel = vscode.window.createOutputChannel(SerialMonitor.SERIAL_MONITOR);
63+
this._bufferedOutputChannel = new BufferedOutputChannel(this._outputChannel.append, 300);
6064
this._currentBaudRate = defaultBaudRate;
6165
this._portsStatusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, constants.statusBarPriority.PORT);
6266
this._portsStatusBar.command = "arduino.selectSerialPort";
@@ -88,6 +92,8 @@ export class SerialMonitor implements vscode.Disposable {
8892
if (this._serialPortCtrl && this._serialPortCtrl.isActive) {
8993
return this._serialPortCtrl.stop();
9094
}
95+
this._outputChannel.dispose();
96+
this._bufferedOutputChannel.dispose();
9197
}
9298

9399
public async selectSerialPort(vid: string, pid: string) {
@@ -145,7 +151,11 @@ export class SerialMonitor implements vscode.Disposable {
145151
return;
146152
}
147153
} else {
148-
this._serialPortCtrl = new SerialPortCtrl(this._currentPort, this._currentBaudRate, this._outputChannel);
154+
this._serialPortCtrl = new SerialPortCtrl(
155+
this._currentPort,
156+
this._currentBaudRate,
157+
this._bufferedOutputChannel,
158+
this._outputChannel.show);
149159
}
150160

151161
if (!this._serialPortCtrl.currentPort) {

src/serialmonitor/serialportctrl.ts

+14-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import { ChildProcess, execFileSync, spawn } from "child_process";
55
import * as os from "os";
66
import * as path from "path";
7-
import { OutputChannel } from "vscode";
87
import { DeviceContext } from "../deviceContext";
8+
import { BufferedOutputChannel } from "./outputBuffer";
99

1010
interface ISerialPortDetail {
1111
port: string;
@@ -63,7 +63,11 @@ export class SerialPortCtrl {
6363
private _currentBaudRate: number;
6464
private _currentSerialPort = null;
6565

66-
public constructor(port: string, baudRate: number, private _outputChannel: OutputChannel) {
66+
public constructor(
67+
port: string,
68+
baudRate: number,
69+
private _bufferedOutputChannel: BufferedOutputChannel,
70+
private showOutputChannel: (preserveFocus?: boolean) => void) {
6771
this._currentBaudRate = baudRate;
6872
this._currentPort = port;
6973
}
@@ -80,8 +84,8 @@ export class SerialPortCtrl {
8084
}
8185

8286
public open(): Promise<void> {
83-
this._outputChannel.appendLine(`[Starting] Opening the serial port - ${this._currentPort}`);
84-
this._outputChannel.show();
87+
this._bufferedOutputChannel.appendLine(`[Starting] Opening the serial port - ${this._currentPort}`);
88+
this.showOutputChannel();
8589

8690
if (this._child) {
8791
this.stop();
@@ -96,8 +100,10 @@ export class SerialPortCtrl {
96100
});
97101

98102
this._child.stdout.on("data", (data) => {
99-
const jsonObj = JSON.parse(data.toString())
100-
this._outputChannel.append(jsonObj["payload"] + "\n");
103+
if (this.isActive) {
104+
const jsonObj = JSON.parse(data.toString())
105+
this._bufferedOutputChannel.append(jsonObj["payload"] + "\n");
106+
}
101107
});
102108
// TODO: add message check to ensure _child spawned without errors
103109
resolve();
@@ -155,8 +161,8 @@ export class SerialPortCtrl {
155161
}
156162
try {
157163
this._child.stdin.write('{"cmd": "close"}\n');
158-
if (this._outputChannel) {
159-
this._outputChannel.appendLine(`[Done] Closed the serial port ${os.EOL}`);
164+
if (this._bufferedOutputChannel) {
165+
this._bufferedOutputChannel.appendLine(`[Done] Closed the serial port ${os.EOL}`);
160166
}
161167
this._child = null;
162168
resolve(true);

0 commit comments

Comments
 (0)