mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-26 02:47:17 +00:00
Merge pull request #709 from voodootikigod/linting
linting binaries, cleaning up tests, add a doc
This commit is contained in:
commit
2250223fc2
7 changed files with 26 additions and 15 deletions
|
|
@ -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'
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
var serialport = require('../');
|
||||
var sf = require('sf');
|
||||
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue