incyclist-devices 2.0.11 → 2.0.12

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.
@@ -15,8 +15,6 @@ const utils_2 = require("../../../utils/utils");
15
15
  const __1 = require("../..");
16
16
  const ByteLength = require('@serialport/parser-byte-length');
17
17
  const nop = () => { };
18
- const TIMEOUT_START = 15000;
19
- const TIMEOUT_CLOSE = 5000;
20
18
  const TIMEOUT_SEND = 2000;
21
19
  class Daum8008 {
22
20
  constructor(props) {
@@ -78,7 +76,7 @@ class Daum8008 {
78
76
  this.connected = true;
79
77
  this.sp = port;
80
78
  this.sp.on('close', this.onPortClose.bind(this));
81
- this.sp.on('error', (error) => { this.onPortError(error); });
79
+ this.sp.on('error', this.onPortError.bind(this));
82
80
  return true;
83
81
  }
84
82
  else {
@@ -98,7 +96,10 @@ class Daum8008 {
98
96
  return;
99
97
  this.stopWorker();
100
98
  yield this.flush();
101
- yield this.serial.closePort(this.portName);
99
+ try {
100
+ yield this.serial.closePort(this.portName);
101
+ }
102
+ catch (_a) { }
102
103
  this.connected = false;
103
104
  if (this.sp)
104
105
  this.sp.removeAllListeners();
@@ -136,7 +137,7 @@ class Daum8008 {
136
137
  if ((this.closing || this.closed) && (err.message === 'Port is not open' || err.message === 'Writing to COM port (GetOverlappedResult): Operation aborted'))
137
138
  return;
138
139
  const state = { opening: this.opening, connected: this.connected, closing: this.closing, closed: this.closed, busy: this.cmdBusy };
139
- this.logEvent({ message: "port error:", port: this.getPort(), error: err.message, stack: err.stack, state });
140
+ this.logEvent({ message: "port error:", port: this.getPort(), error: err.message, state });
140
141
  this.error = err;
141
142
  this.cmdBusy = false;
142
143
  }
@@ -190,6 +190,7 @@ class SerialInterface extends events_1.default {
190
190
  this.logEvent({ message: 'opening port - getSerialPort()', path });
191
191
  const port = serialport_1.default.getInstance().getSerialPort(this.ifaceName, { path });
192
192
  if (!port) {
193
+ this.logEvent({ message: 'opening port - port does not exist', path });
193
194
  return null;
194
195
  }
195
196
  return new Promise((resolve) => {
@@ -218,8 +219,11 @@ class SerialInterface extends events_1.default {
218
219
  if (!port.isOpen)
219
220
  return true;
220
221
  port.on('error', () => { });
221
- port.flush();
222
- yield port.drain();
222
+ try {
223
+ port.flush();
224
+ yield port.drain();
225
+ }
226
+ catch (_a) { }
223
227
  return new Promise(resolve => {
224
228
  port.close(err => {
225
229
  if (!err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "2.0.11",
3
+ "version": "2.0.12",
4
4
  "dependencies": {
5
5
  "@serialport/bindings-interface": "^1.2.2",
6
6
  "@serialport/parser-byte-length": "^9.0.1",