Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit 4a638e5

Browse files
authored
Serial Monitor Fix (#282)
1 parent 3a3ae68 commit 4a638e5

File tree

73 files changed

+3205
-6381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3205
-6381
lines changed

Diff for: locales/en/out/constants.i18n.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"dialogResponses.agreeAndRun": "Agree and Run",
33
"dialogResponses.acceptPrivacy": "Got it",
44
"dialogResponses.cancel": "Cancel",
5+
"dialogResponses.select": "Select",
56
"dialogResponses.dontShowAgain": "Don't Show Again",
67
"dialogResponses.exampleCode": "Example Code on GitHub",
78
"dialogResponses.help": "I need help",

Diff for: package-lock.json

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

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"instrumentationKey": "__AIKEY__",
88
"icon": "assets/icon.png",
99
"engines": {
10-
"vscode": "^1.34.0"
10+
"vscode": "^1.43.0"
1111
},
1212
"categories": [
1313
"Other"
@@ -353,6 +353,7 @@
353353
"socket.io": "^2.2.0",
354354
"svg-inline-react": "^3.1.0",
355355
"ts-jest": "^25.0.0",
356+
"usb-native": "^5.0.1",
356357
"util": "^0.12.1",
357358
"vscode-extension-telemetry": "^0.1.1",
358359
"vscode-nls": "^4.1.0"

Diff for: src/constants.ts

+3
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,9 @@ export namespace DialogResponses {
403403
export const CANCEL: MessageItem = {
404404
title: localize("dialogResponses.cancel", "Cancel"),
405405
};
406+
export const SELECT: MessageItem = {
407+
title: localize("dialogResponses.select", "Select"),
408+
};
406409
export const HELP: MessageItem = {
407410
title: localize("dialogResponses.help", "I need help"),
408411
};

Diff for: src/serialMonitor.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { logToOutputChannel } from "./extension_utils/utils";
1111
import { SerialPortControl } from "./serialPortControl";
1212

1313
export interface ISerialPortDetail {
14-
comName: string;
14+
path: string;
1515
manufacturer: string;
1616
vendorId: string;
1717
productId: string;
@@ -127,7 +127,7 @@ export class SerialMonitor implements vscode.Disposable {
127127
foundPort &&
128128
!(this._serialPortControl && this._serialPortControl.isActive)
129129
) {
130-
this.updatePortListStatus(foundPort.comName);
130+
this.updatePortListStatus(foundPort.path);
131131
}
132132
} else {
133133
const chosen = await vscode.window.showQuickPick(
@@ -136,7 +136,7 @@ export class SerialMonitor implements vscode.Disposable {
136136
(port: ISerialPortDetail): vscode.QuickPickItem => {
137137
return {
138138
description: port.manufacturer,
139-
label: port.comName,
139+
label: port.path,
140140
};
141141
}
142142
)
@@ -160,10 +160,10 @@ export class SerialMonitor implements vscode.Disposable {
160160
if (!this._currentPort) {
161161
const ans = await vscode.window.showInformationMessage(
162162
CONSTANTS.WARNING.NO_SERIAL_PORT_SELECTED,
163-
DialogResponses.YES,
164-
DialogResponses.NO
163+
DialogResponses.SELECT,
164+
DialogResponses.CANCEL
165165
);
166-
if (ans === DialogResponses.YES) {
166+
if (ans === DialogResponses.SELECT) {
167167
await this.selectSerialPort(null, null);
168168
}
169169
if (!this._currentPort) {

Diff for: src/serialPortControl.ts

+8-14
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { CONSTANTS } from "./constants";
99
import { logToOutputChannel } from "./extension_utils/utils";
1010

1111
interface ISerialPortDetail {
12-
comName: string;
12+
path: string;
1313
manufacturer: string;
1414
vendorId: string;
1515
productId: string;
@@ -18,21 +18,16 @@ interface ISerialPortDetail {
1818
export class SerialPortControl {
1919
public static get serialport(): any {
2020
if (!SerialPortControl._serialport) {
21-
SerialPortControl._serialport = require("../vendor/node-usb-native").SerialPort;
21+
SerialPortControl._serialport = require("usb-native").SerialPort;
2222
}
2323
return SerialPortControl._serialport;
2424
}
2525

2626
public static list(): Promise<ISerialPortDetail[]> {
2727
return new Promise((resolve, reject) => {
28-
SerialPortControl.serialport.list(
29-
(error: any, ports: ISerialPortDetail[]) => {
30-
if (error) {
31-
reject(error);
32-
} else {
33-
resolve(ports);
34-
}
35-
}
28+
SerialPortControl.serialport.list().then(
29+
ports => resolve(ports),
30+
err => reject(err)
3631
);
3732
});
3833
}
@@ -53,7 +48,7 @@ export class SerialPortControl {
5348
}
5449

5550
public get isActive(): boolean {
56-
return this._currentSerialPort && this._currentSerialPort.isOpen();
51+
return this._currentSerialPort && this._currentSerialPort.isOpen;
5752
}
5853

5954
public get currentPort(): string {
@@ -66,7 +61,7 @@ export class SerialPortControl {
6661
CONSTANTS.INFO.OPENING_SERIAL_PORT(this._currentPort)
6762
);
6863
return new Promise((resolve, reject) => {
69-
if (this._currentSerialPort && this._currentSerialPort.isOpen()) {
64+
if (this._currentSerialPort && this._currentSerialPort.isOpen) {
7065
this._currentSerialPort.close((err: any) => {
7166
if (err) {
7267
return reject(err);
@@ -89,8 +84,7 @@ export class SerialPortControl {
8984
this._outputChannel.show();
9085
this._currentSerialPort.on("open", () => {
9186
this._currentSerialPort.write(
92-
CONSTANTS.MISC.SERIAL_MONITOR_TEST_IF_OPEN,
93-
"Both NL & CR",
87+
CONSTANTS.MISC.SERIAL_MONITOR_TEST_IF_OPEN + os.EOL,
9488
(err: any) => {
9589
if (
9690
err &&

Diff for: src/usbDetector.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class UsbDetector {
4242
if (os.platform() === "linux" || !enableUSBDetection) {
4343
return;
4444
}
45-
this._usbDetector = require("../vendor/node-usb-native").detector;
45+
this._usbDetector = require("usb-native").detector;
4646

4747
if (!this._usbDetector) {
4848
return;

Diff for: vendor/node-usb-native/.eslintrc

-26
This file was deleted.

Diff for: vendor/node-usb-native/.gitignore

-14
This file was deleted.

Diff for: vendor/node-usb-native/.npmignore

-2
This file was deleted.

Diff for: vendor/node-usb-native/README.md

-4
This file was deleted.

Diff for: vendor/node-usb-native/binding.gyp

-64
This file was deleted.

Diff for: vendor/node-usb-native/lib/bindings.js

-44
This file was deleted.

0 commit comments

Comments
 (0)