diff --git a/README.md b/README.md index 1239b42..319549b 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![Join the chat at https://gitter.im/OpenBCI/OpenBCI_NodeJS](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/OpenBCI/OpenBCI_NodeJS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/OpenBCI/OpenBCI_NodeJS.svg?branch=master)](https://travis-ci.org/OpenBCI/OpenBCI_NodeJS) [![codecov](https://codecov.io/gh/OpenBCI/OpenBCI_NodeJS/branch/master/graph/badge.svg)](https://codecov.io/gh/OpenBCI/OpenBCI_NodeJS) +[![Dependency Status](https://david-dm.org/OpenBCI/OpenBCI_NodeJS.svg)](https://david-dm.org/OpenBCI/OpenBCI_NodeJS) +[![npm](https://img.shields.io/npm/dm/openbci.svg?maxAge=2592000)](http://npmjs.com/package/openbci) # OpenBCI Node.js SDK diff --git a/changelog.md b/changelog.md index 2e6ccaa..14b2784 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +# 1.2.2 + +### Enhancements + +* Upgrade serialport to 4.x + # 1.2.1 ### Bug Fixes diff --git a/openBCIBoard.js b/openBCIBoard.js index 13ced00..84a8f38 100644 --- a/openBCIBoard.js +++ b/openBCIBoard.js @@ -3,7 +3,7 @@ var EventEmitter = require('events').EventEmitter, util = require('util'), stream = require('stream'), - serialPort = require('serialport'), + SerialPort = require('serialport'), openBCISample = require('./openBCISample'), k = openBCISample.k, openBCISimulator = require('./openBCISimulator'), @@ -240,7 +240,7 @@ function OpenBCIFactory() { } else { /* istanbul ignore if */ if (this.options.verbose) console.log('using real board ' + portName); - boardSerial = new serialPort.SerialPort(portName, { + boardSerial = new SerialPort(portName, { baudRate: this.options.baudRate },(err) => { if (err) reject(err); @@ -473,14 +473,14 @@ function OpenBCIFactory() { OpenBCIBoard.prototype._writeAndDrain = function(data) { return new Promise((resolve,reject) => { if(!this.serial) reject('Serial port not open'); - this.serial.write(data,(error,results) => { - if(results) { + this.serial.write(data,(error) => { + if(error) { + console.log('Error [writeAndDrain]: ' + error); + reject(error); + } else { this.serial.drain(function() { resolve(); }); - } else { - console.log('Error [writeAndDrain]: ' + error); - reject(error); } }) }); @@ -504,7 +504,7 @@ function OpenBCIFactory() { if (this.options.verbose) console.log('auto found sim board'); resolve(k.OBCISimulatorPortName); } else { - serialPort.list((err, ports) => { + SerialPort.list((err, ports) => { if(err) { if (this.options.verbose) console.log('serial port err'); reject(err); @@ -921,7 +921,7 @@ function OpenBCIFactory() { */ OpenBCIBoard.prototype.listPorts = function() { return new Promise((resolve, reject) => { - serialPort.list((err, ports) => { + SerialPort.list((err, ports) => { if(err) reject(err); else { ports.push( { diff --git a/package.json b/package.json index 38acd8d..ba36d1e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openbci", - "version": "1.2.1", + "version": "1.2.2", "description": "The official Node.js SDK for the OpenBCI Biosensor Board.", "main": "openBCIBoard", "scripts": { @@ -19,7 +19,7 @@ "gaussian": "^1.0.0", "mathjs": "^3.3.0", "performance-now": "^0.2.0", - "serialport": "3.1.2", + "serialport": "4.0.1", "sntp": "^2.0.0", "streamsearch": "^0.1.2" }, @@ -31,7 +31,7 @@ "chai-as-promised": "^5.2.0", "codecov": "^1.0.1", "istanbul": "^0.4.4", - "mocha": "^2.3.4", + "mocha": "^3.0.2", "sandboxed-module": "^2.0.3", "sinon": "^1.17.2", "sinon-chai": "^2.8.0"