incyclist-devices 1.4.18 → 1.4.19

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.
@@ -16,7 +16,7 @@ const gd_eventlog_1 = require("gd-eventlog");
16
16
  const utils_1 = require("../utils");
17
17
  const events_1 = __importDefault(require("events"));
18
18
  const DEFAULT_RCV_TIMEOUT = 1500;
19
- const DEFAULT_OPEN_TIMEOUT = 1500;
19
+ const DEFAULT_OPEN_TIMEOUT = 3000;
20
20
  const DEBUG_LOGGER = {
21
21
  log: (e, ...args) => console.log(e, ...args),
22
22
  logEvent: (event) => console.log(JSON.stringify(event))
@@ -200,6 +200,7 @@ class KettlerSerialComms extends events_1.default {
200
200
  cmd.onError(err);
201
201
  this.sendState = SendState.Idle;
202
202
  this.currentCmd = undefined;
203
+ this.stopCurrentTimeoutCheck();
203
204
  };
204
205
  try {
205
206
  this.logger.logEvent({ message: "sendCommand:sending:", cmd: logStr, msg, port: this.getPort() });
@@ -208,16 +209,17 @@ class KettlerSerialComms extends events_1.default {
208
209
  this.sp.write(msg + CRLF, (err) => {
209
210
  this.sendState = SendState.Receiving;
210
211
  this.currentCmd = cmd;
211
- if (timeout) {
212
- this.currentTimeout = setTimeout(() => {
213
- if (this.sendState === SendState.Receiving) {
214
- onError(new Error("response timeout"));
215
- }
216
- }, timeout);
217
- }
218
212
  if (err)
219
213
  onError(err);
220
214
  });
215
+ this.currentTimeout = setTimeout(() => {
216
+ if (this.sendState === SendState.Sending) {
217
+ onError(new Error("send timeout"));
218
+ }
219
+ if (this.sendState === SendState.Receiving) {
220
+ onError(new Error("response timeout"));
221
+ }
222
+ }, timeout);
221
223
  }
222
224
  catch (err) {
223
225
  onError(err);
@@ -232,7 +234,7 @@ class KettlerSerialComms extends events_1.default {
232
234
  this.write(cmd);
233
235
  }
234
236
  send(cmd) {
235
- this.logger.logEvent({ message: 'send()', cmd: cmd.logStr, port: this.getPort(), queueSize: this.queue.size() });
237
+ this.logger.logEvent({ message: 'add command to queue', cmd: cmd.logStr, msg: cmd.message, port: this.getPort(), queueSize: this.queue.size() });
236
238
  this.queue.enqueue(cmd);
237
239
  }
238
240
  }
@@ -312,7 +312,6 @@ class KettlerRacerAdapter extends Device_1.default {
312
312
  return info.data;
313
313
  }
314
314
  catch (err) {
315
- console.log('~~~ Error', err);
316
315
  try {
317
316
  yield this.reset();
318
317
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "1.4.18",
3
+ "version": "1.4.19",
4
4
  "dependencies": {
5
5
  "@serialport/parser-byte-length": "^9.0.1",
6
6
  "@serialport/parser-delimiter": "^9.0.1",