incyclist-devices 2.0.34 → 2.0.35

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.
@@ -58,7 +58,7 @@ class SinglePathScanner {
58
58
  return;
59
59
  this.isScanning = true;
60
60
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
61
- this.logEvent({ message: 'starting scan', path: this.path });
61
+ this.logEvent({ message: 'starting scan', path: this.path, interface: this.serial.getName() });
62
62
  this.serial.scanEvents.on('timeout', () => this.onStopRequest(resolve));
63
63
  this.serial.scanEvents.on('stop', () => this.onStopRequest(resolve));
64
64
  let found = false;
@@ -78,6 +78,7 @@ class SinglePathScanner {
78
78
  if (found) {
79
79
  this.isFound = true;
80
80
  const name = adapter.getName();
81
+ yield adapter.close();
81
82
  resolve(Object.assign(Object.assign({}, adapterSettings), { name }));
82
83
  }
83
84
  yield (0, utils_1.sleep)(100);
@@ -166,9 +167,11 @@ class SerialInterface extends events_1.default {
166
167
  }
167
168
  connect() {
168
169
  return __awaiter(this, void 0, void 0, function* () {
170
+ this.logEvent({ message: 'connecting', interface: this.ifaceName });
169
171
  const binding = serialport_1.default.getInstance().getBinding(this.ifaceName);
170
172
  if (!binding || !this.binding) {
171
173
  this.connected = false;
174
+ this.logEvent({ message: 'connecting error', interface: this.ifaceName, reason: 'no binfing found' });
172
175
  return false;
173
176
  }
174
177
  try {
@@ -178,6 +181,7 @@ class SerialInterface extends events_1.default {
178
181
  return true;
179
182
  }
180
183
  catch (err) {
184
+ this.logEvent({ message: 'connecting error', interface: this.ifaceName, reason: err.message });
181
185
  this.connected = false;
182
186
  return false;
183
187
  }
@@ -210,7 +214,7 @@ class SerialInterface extends events_1.default {
210
214
  }
211
215
  return new Promise((resolve) => {
212
216
  port.once('error', (err) => {
213
- this.logEvent({ message: 'error', path, error: err.message || err });
217
+ this.logEvent({ message: 'error', path, error: err.message || err, stack: err.stack });
214
218
  port.removeAllListeners();
215
219
  resolve(null);
216
220
  });
@@ -273,14 +277,15 @@ class SerialInterface extends events_1.default {
273
277
  }
274
278
  this.isScanning = true;
275
279
  let attemptNo = 0;
280
+ const isTcpip = this.getName() === 'tcpip';
276
281
  do {
277
282
  if (attemptNo === 0)
278
- this.logEvent({ message: 'checking for ports', port, excludes: this.inUse });
283
+ this.logEvent({ message: 'checking for ports', interface: this.ifaceName, port, excludes: this.inUse });
279
284
  else
280
- this.logEvent({ message: 'checking for ports retry', retry: attemptNo });
285
+ this.logEvent({ message: 'checking for ports retry', interface: this.ifaceName, retry: attemptNo });
281
286
  attemptNo++;
282
287
  try {
283
- if (this.getName() === 'tcpip') {
288
+ if (isTcpip) {
284
289
  const _binding = binding;
285
290
  paths = (yield _binding.list(port, this.inUse)) || [];
286
291
  }
@@ -307,19 +312,20 @@ class SerialInterface extends events_1.default {
307
312
  }
308
313
  return [];
309
314
  }
310
- this.logEvent({ message: 'scanning on ', paths: paths.map(p => p.path), timeout });
315
+ this.logEvent({ message: 'scanning on ', interface: this.ifaceName, paths: paths.map(p => p.path).join(','), timeout });
311
316
  const scanners = paths.map(p => new SinglePathScanner(p.path, this, Object.assign(Object.assign({}, props), { logger: this.logger })));
312
317
  try {
313
318
  yield Promise.all(scanners.map(s => s.scan()
314
- .then(device => {
319
+ .then((device) => __awaiter(this, void 0, void 0, function* () {
315
320
  if (device) {
316
321
  const adapter = adapter_factory_1.default.getInstance().createInstance(device);
317
322
  const path = adapter.getPort();
318
323
  this.inUse.push(path);
324
+ yield adapter.stop();
319
325
  detected.push(device);
320
326
  this.emit('device', device);
321
327
  }
322
- })
328
+ }))
323
329
  .catch()));
324
330
  }
325
331
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.0.34",
3
+ "version": "2.0.35",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",