We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c38fdc8 commit 751eb04Copy full SHA for 751eb04
js/main/serial.js
@@ -12,11 +12,17 @@ const serial = {
12
connect: function(path, options, window) {
13
return new Promise(resolve => {
14
try {
15
+ var openPortResolved = false;
16
this._serialport = new SerialPortStream({binding, path: path, baudRate: options.bitrate, autoOpen: true});
17
this._serialport.on('error', error => {
18
if (!window.isDestroyed()) {
19
window.webContents.send('serialError', error);
20
}
21
+
22
+ if(!openPortResolved) {
23
+ openPortResolved = true;
24
+ resolve({error: false, id: this._id++});
25
+ }
26
});
27
28
this._serialport.on('close', () => {
@@ -30,7 +36,12 @@ const serial = {
30
36
window.webContents.send('serialData', buffer);
31
37
32
38
33
- resolve({error: false, id: this._id++});
39
40
+ this._serialport.on('open', () => {
41
42
43
+ });
44
34
45
} catch (err) {
35
46
resolve ({error: true, errorMsg: err});
47
0 commit comments