Skip to content

Commit

Permalink
Merge pull request #74 from pushtheworldllc/serialport-upgrade
Browse files Browse the repository at this point in the history
Enh upgrade serial port to 4.x
  • Loading branch information
AJ Keller authored Aug 10, 2016
2 parents c33d08b + 19f05e3 commit b51cb54
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.2.2

### Enhancements

* Upgrade serialport to 4.x

# 1.2.1

### Bug Fixes
Expand Down
18 changes: 9 additions & 9 deletions openBCIBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
})
});
Expand All @@ -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);
Expand Down Expand Up @@ -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( {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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"
},
Expand All @@ -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"
Expand Down

0 comments on commit b51cb54

Please sign in to comment.