incyclist-devices 2.0.9 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -176,23 +176,25 @@ class SerialInterface extends events_1.default {
|
|
|
176
176
|
openPort(path) {
|
|
177
177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
178
178
|
this.logEvent({ message: 'opening port', path });
|
|
179
|
-
const port = serialport_1.default.getInstance().getSerialPort(this.ifaceName, { path });
|
|
180
|
-
if (!port) {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
179
|
const existing = this.ports.findIndex(p => p.path === path);
|
|
184
180
|
if (existing !== -1) {
|
|
185
181
|
const port = this.ports[existing].port;
|
|
186
182
|
if (port.isOpen) {
|
|
183
|
+
this.logEvent({ message: 'opening port - port already exists', path });
|
|
187
184
|
return port;
|
|
188
185
|
}
|
|
189
186
|
else {
|
|
190
187
|
this.ports.splice(existing, 1);
|
|
191
188
|
}
|
|
192
189
|
}
|
|
190
|
+
this.logEvent({ message: 'opening port - getSerialPort()', path });
|
|
191
|
+
const port = serialport_1.default.getInstance().getSerialPort(this.ifaceName, { path });
|
|
192
|
+
if (!port) {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
193
195
|
return new Promise((resolve) => {
|
|
194
196
|
port.once('error', (err) => {
|
|
195
|
-
this.logEvent({ message: 'error', path, error: err || err
|
|
197
|
+
this.logEvent({ message: 'error', path, error: err.message || err });
|
|
196
198
|
port.removeAllListeners();
|
|
197
199
|
resolve(null);
|
|
198
200
|
});
|