@@ -3,11 +3,13 @@ import { window } from "vscode";
3
3
import * as path from "path" ;
4
4
5
5
export function uploadFile ( device : string , filename : string ) {
6
- let connector = new nodemcu . Connector ( device , 9600 ) ;
6
+ // TODO: NodeMcu's default uart settings is 115200. Need to implement baudrate change function
7
+ let connector = new nodemcu . Connector ( device , 115200 ) ;
7
8
8
9
connector . connect ( ( err , deviceInfo ) => {
9
10
if ( err ) {
10
11
window . showErrorMessage ( "NodeMCU connection error: " + err ) ;
12
+ connector . disconnect ( ) ;
11
13
}
12
14
else {
13
15
window . showInformationMessage ( "NodeMCU device connected: " + deviceInfo ) ;
@@ -31,13 +33,24 @@ export function uploadFile(device: string, filename: string) {
31
33
export function findDevice ( cb : any ) : void {
32
34
let connector = new nodemcu . Connector ( "" , 9600 ) ;
33
35
34
- connector . deviceInfo ( false , ( err , devices ) => {
36
+ // serialport module cannot detect vendor id on windows so we should get all com devices and filtered by pnpid
37
+ let osIsWindows = process . platform == "win32" ;
38
+
39
+ connector . deviceInfo ( osIsWindows , ( err , devices ) => {
35
40
if ( err ) {
36
41
window . showErrorMessage ( 'Serial device connection error: ' + err ) ;
37
42
} else {
43
+ if ( osIsWindows )
44
+ {
45
+ devices = devices . filter ( function ( device ) {
46
+ return device . pnpId . toString ( ) . includes ( "VID_1A86" ) || device . pnpId . toString ( ) . includes ( "VID_10C4" ) ;
47
+ } ) ;
48
+ }
49
+
38
50
if ( devices . length == 0 ) {
39
51
window . showErrorMessage ( 'No Connected Devices found' ) ;
40
52
} else if ( devices . length > 1 ) {
53
+ // TODO: Display selection popup
41
54
window . showErrorMessage ( "Many devices found. Connect only once" ) ;
42
55
}
43
56
else {
0 commit comments