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

Commit 93e760a

Browse files
authored
add disableTestingOpen (#552)
1 parent d61fd7a commit 93e760a

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,16 @@ The following Visual Studio Code settings are available for the Arduino extensio
5858
"arduino.commandPath": "run-arduino.bat",
5959
"arduino.additionalUrls": "",
6060
"arduino.logLevel": "info",
61-
"arduino.enableUSBDetection": true
61+
"arduino.enableUSBDetection": true,
62+
"arduino.disableTestingOpen": false
6263
}
6364
```
6465
- `arduino.path` - Path to Arduino, you can use a custom version of Arduino by modifying this setting to include the full path. Example: `C:\\Program Files\\Arduino` for Windows, `/Applications` for Mac, `/home/$user/Downloads/arduino-1.8.1` for Linux. (Requires a restart after change). The default value is automatically detected from your Arduino IDE installation path.
6566
- `arduino.commandPath` - Path to an executable (or script) relative to `arduino.path`. You can use a custom launch script to run Arduino by modifying this setting. (Requires a restart after change) Example: `run-arduino.bat` for Windows, `Contents/MacOS/run-arduino.sh` for Mac, `bin/run-arduino.sh` for Linux."
6667
- `arduino.additionalUrls` - Additional URLs for 3rd party packages. You can have multiple URLs in one string with comma(,) as separator, or have a string array. The default value is empty.
6768
- `arduino.logLevel` - CLI output log level. Could be info or verbose. The default value is `"info"`.
6869
- `arduino.enableUSBDetection` - Enable/disable USB detection from the VSCode Arduino extension. The default value is `true`.
70+
- `arduino.disableTestingOpen` - Disable/enable auto sending a test message to serial port for checking open status. The default value is `false` (a test message will be sent).
6971

7072
The following settings are per sketch settings of the Arduino extension. You can find them in
7173
`.vscode/arduino.json` under the workspace.

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,10 @@
436436
"arduino.enableUSBDetection": {
437437
"type": "boolean",
438438
"default": true
439+
},
440+
"arduino.disableTestingOpen": {
441+
"type": "boolean",
442+
"default": false
439443
}
440444
}
441445
},

src/arduino/vscodeSettings.ts

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const configKeys = {
1010
LOG_LEVEL: "arduino.logLevel",
1111
AUTO_UPDATE_INDEX_FILES: "arduino.autoUpdateIndexFiles",
1212
ENABLE_USB_DETECTOIN: "arduino.enableUSBDetection",
13+
DISABLE_TESTING_OPEN: "arduino.disableTestingOpen",
1314
};
1415

1516
export interface IVscodeSettings {
@@ -18,6 +19,7 @@ export interface IVscodeSettings {
1819
additionalUrls: string | string[];
1920
logLevel: string;
2021
enableUSBDetection: boolean;
22+
disableTestingOpen: boolean;
2123
updateAdditionalUrls(urls: string | string[]): void;
2224
}
2325

@@ -53,6 +55,10 @@ export class VscodeSettings implements IVscodeSettings {
5355
return this.getConfigValue<boolean>(configKeys.ENABLE_USB_DETECTOIN);
5456
}
5557

58+
public get disableTestingOpen(): boolean {
59+
return this.getConfigValue<boolean>(configKeys.DISABLE_TESTING_OPEN);
60+
}
61+
5662
public async updateAdditionalUrls(value) {
5763
await this.setConfigValue(configKeys.ADDITIONAL_URLS, value, true);
5864
}

src/serialmonitor/serialportctrl.ts

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import * as os from "os";
55
import { OutputChannel, QuickPickItem, StatusBarAlignment, StatusBarItem, window } from "vscode";
6+
import { VscodeSettings } from "../arduino/vscodeSettings";
67

78
interface ISerialPortDetail {
89
comName: string;
@@ -78,6 +79,11 @@ export class SerialPortCtrl {
7879
this._currentSerialPort = new SerialPortCtrl.serialport(this._currentPort, { baudRate: this._currentBaudRate });
7980
this._outputChannel.show();
8081
this._currentSerialPort.on("open", () => {
82+
if (VscodeSettings.getInstance().disableTestingOpen) {
83+
this._outputChannel.appendLine("[Warning] Auto checking serial port open is disabled");
84+
return resolve();
85+
}
86+
8187
this._currentSerialPort.write("TestingOpen", "Both NL & CR", (err) => {
8288
// TODO: Fix this on the serial port lib: https://github.com/EmergingTechnologyAdvisors/node-serialport/issues/795
8389
if (err && !(err.message.indexOf("Writing to COM port (GetOverlappedResult): Unknown error code 121") >= 0)) {

0 commit comments

Comments
 (0)