From 0abebcdd9d730e6822ba64ed2e57d2d4ec26a8ee Mon Sep 17 00:00:00 2001 From: AJ Keller Date: Thu, 20 Jul 2017 01:09:53 -0400 Subject: [PATCH] FIX: disconnect did not close serial port if device was not streaming --- changelog.md | 3 ++- openBCICyton.js | 4 +++- package.json | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index d8aafcd..98fea1e 100644 --- a/changelog.md +++ b/changelog.md @@ -2,7 +2,8 @@ ### Enhancements -* Update openbci-utilities to v0.1.1 to patch for sendCounts. +* Update openbci-utilities to v0.1.2 to patch for sendCounts. +* Disconnect did not disconnect from serial port if the device was not streaming. # 2.1.1 diff --git a/openBCICyton.js b/openBCICyton.js index 564f5d9..9b35de2 100644 --- a/openBCICyton.js +++ b/openBCICyton.js @@ -368,13 +368,15 @@ Cyton.prototype.disconnect = function () { if (this.isStreaming()) { if (this.options.verbose) console.log('stop streaming'); return this.streamStop(); + } else { + return Promise.resolve(); } }) .then(() => { if (!this.isConnected()) { return Promise.reject(Error('no board connected')); } else { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { // serial emitting 'close' will call _disconnected this.serial.close(() => { resolve(); diff --git a/package.json b/package.json index cd95f03..0622d73 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "gaussian": "^1.0.0", "lodash": "^4.17.4", "mathjs": "^3.14.2", - "openbci-utilities": "0.1.1", + "openbci-utilities": "0.1.2", "performance-now": "^2.1.0", "safe-buffer": "^5.1.1", "serialport": "4.0.7",