diff --git a/Gruntfile.js b/Gruntfile.js index 4daacfa..5efb2b6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,7 +9,13 @@ module.exports = function(grunt) { } }, eslint: { - src: ['*.js', 'test/**/*.js', 'test_mocks/**/*.js', 'arduinoTest/**/*.js'] + src: [ + '*.js', + 'test/**/*.js', + 'test_mocks/**/*.js', + 'arduinoTest/**/*.js', + 'bin/*.js' + ] } }); diff --git a/README.md b/README.md index 19a9b31..b9fc240 100644 --- a/README.md +++ b/README.md @@ -247,7 +247,7 @@ Port configuration options. * `xon` * `xoff` * `xany` -* `flowControl` +* `flowControl` One of the following `XON`, `XOFF`, `XANY`, `RTSCTS` * `bufferSize` Size of read buffer, defaults to 255. Must be an integer value. * `parser` The parser engine to use with read data, defaults to rawPacket strategy which just emits the raw buffer as a "data" event. Can be any function that accepts EventEmitter as first parameter and the raw buffer as the second parameter. * `encoding` diff --git a/bin/serialportList.js b/bin/serialportList.js index f374882..1fbf60e 100755 --- a/bin/serialportList.js +++ b/bin/serialportList.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + var serialport = require('../'); var sf = require('sf'); diff --git a/bin/serialportTerminal.js b/bin/serialportTerminal.js index 2154904..2fd51fb 100755 --- a/bin/serialportTerminal.js +++ b/bin/serialportTerminal.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + var SerialPort = require('../').SerialPort; var optimist = require('optimist'); @@ -38,10 +40,19 @@ if (args.help) { } if (!args.portname) { - console.error("Serial port name is required."); + console.error('Serial port name is required.'); return process.exit(-1); } +var openOptions = { + baudRate: args.baud, + dataBits: args.databits, + parity: args.parity, + stopBits: args.stopbits +}; + +var port = new SerialPort(args.portname, openOptions); + process.stdin.resume(); process.stdin.setRawMode(true); process.stdin.on('data', function (s) { @@ -63,14 +74,6 @@ process.stdin.on('data', function (s) { }); }); -var openOptions = { - baudRate: args.baud, - dataBits: args.databits, - parity: args.parity, - stopBits: args.stopbits -}; -var port = new SerialPort(args.portname, openOptions); - port.on('data', function (data) { process.stdout.write(data.toString()); }); diff --git a/serialport.js b/serialport.js index 5b9890a..a49ccea 100644 --- a/serialport.js +++ b/serialport.js @@ -162,6 +162,7 @@ function SerialPortFactory(_spfOptions) { return true; }); if (!clean) { + // TODO this is very very messy return; } } @@ -238,7 +239,7 @@ function SerialPortFactory(_spfOptions) { }; // underlying code is written to update all options, but for now - // only baud is respected as I dont want to duplicate all the option + // only baud is respected as I don't want to duplicate all the option // verification code above SerialPort.prototype.update = function (options, callback) { var self = this; @@ -248,7 +249,6 @@ function SerialPortFactory(_spfOptions) { if (callback) { callback(err); } else { - // console.log("write-fd"); self.emit('error', err); } return; diff --git a/test/serialport-basic.js b/test/serialport-basic.js index 4b0a014..12d18b1 100644 --- a/test/serialport-basic.js +++ b/test/serialport-basic.js @@ -251,7 +251,7 @@ describe('SerialPort', function () { }); }); - describe('close', function () { + describe('#close', function () { it('fires a close event when it\'s closed', function (done) { var port = new SerialPort('/dev/exists', function () { var closeSpy = sandbox.spy(); diff --git a/test/serialport-c.js b/test/serialport-c.js index 2f7e844..d80b021 100644 --- a/test/serialport-c.js +++ b/test/serialport-c.js @@ -23,7 +23,7 @@ describe('SerialPort', function () { it('Throws an error in callback when trying to open an invalid port', function (done) { var SerialPort = require('../').SerialPort; this.port = new SerialPort('/dev/nullbad', function (err) { - chai.assert.isDefined(err, 'didn\'t get an error'); + chai.assert.isDefined(err, "didn't get an error"); done(); }); });