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

add disableTestingOpen #552

Merged
merged 2 commits into from
May 8, 2018
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ The following Visual Studio Code settings are available for the Arduino extensio
"arduino.commandPath": "run-arduino.bat",
"arduino.additionalUrls": "",
"arduino.logLevel": "info",
"arduino.enableUSBDetection": true
"arduino.enableUSBDetection": true,
"arduino.disableTestingOpen": false
}
```
- `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.
- `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."
- `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.
- `arduino.logLevel` - CLI output log level. Could be info or verbose. The default value is `"info"`.
- `arduino.enableUSBDetection` - Enable/disable USB detection from the VSCode Arduino extension. The default value is `true`.
- `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).

The following settings are per sketch settings of the Arduino extension. You can find them in
`.vscode/arduino.json` under the workspace.
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@
"arduino.enableUSBDetection": {
"type": "boolean",
"default": true
},
"arduino.disableTestingOpen": {
"type": "boolean",
"default": false
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions src/arduino/vscodeSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const configKeys = {
LOG_LEVEL: "arduino.logLevel",
AUTO_UPDATE_INDEX_FILES: "arduino.autoUpdateIndexFiles",
ENABLE_USB_DETECTOIN: "arduino.enableUSBDetection",
DISABLE_TESTING_OPEN: "arduino.disableTestingOpen",
};

export interface IVscodeSettings {
Expand All @@ -18,6 +19,7 @@ export interface IVscodeSettings {
additionalUrls: string | string[];
logLevel: string;
enableUSBDetection: boolean;
disableTestingOpen: boolean;
updateAdditionalUrls(urls: string | string[]): void;
}

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

public get disableTestingOpen(): boolean {
return this.getConfigValue<boolean>(configKeys.DISABLE_TESTING_OPEN);
}

public async updateAdditionalUrls(value) {
await this.setConfigValue(configKeys.ADDITIONAL_URLS, value, true);
}
Expand Down
6 changes: 6 additions & 0 deletions src/serialmonitor/serialportctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

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

interface ISerialPortDetail {
comName: string;
Expand Down Expand Up @@ -78,6 +79,11 @@ export class SerialPortCtrl {
this._currentSerialPort = new SerialPortCtrl.serialport(this._currentPort, { baudRate: this._currentBaudRate });
this._outputChannel.show();
this._currentSerialPort.on("open", () => {
if (VscodeSettings.getInstance().disableTestingOpen) {
this._outputChannel.appendLine("[Warning] Auto checking serial port open is disabled");
return resolve();
}

this._currentSerialPort.write("TestingOpen", "Both NL & CR", (err) => {
// TODO: Fix this on the serial port lib: https://github.com/EmergingTechnologyAdvisors/node-serialport/issues/795
if (err && !(err.message.indexOf("Writing to COM port (GetOverlappedResult): Unknown error code 121") >= 0)) {
Expand Down