diff --git a/.travis.yml b/.travis.yml
index 4ddf12a..f2fc408 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -71,6 +71,10 @@ before_install:
- if [[ $TRAVIS_BRANCH == `git describe --tags --always HEAD` ]]; then PUBLISH_BINARY=true; fi;
- echo "Publishing native platform Binary Package? ->" $PUBLISH_BINARY
+# Cleanup the output of npm
+- npm config set progress false
+- npm config set spin false
+
install:
# ensure source install works
- npm install --build-from-source
diff --git a/README.md b/README.md
index e875f04..ccd4e1f 100644
--- a/README.md
+++ b/README.md
@@ -294,6 +294,12 @@ Enjoy and do cool things with this code.
### SerialPort ⏏
**Kind**: Exported class
**Emits**: [open](#module_serialport--SerialPort+event_open), [data](#module_serialport--SerialPort+event_data), [close](#module_serialport--SerialPort+event_close), [error](#module_serialport--SerialPort+event_error), [disconnect](#module_serialport--SerialPort+event_disconnect)
+**Properties**
+
+| Name | Type | Description |
+| --- | --- | --- |
+| path | string | The system path or name of the serial port. Read Only. |
+
-
diff --git a/appveyor.yml b/appveyor.yml
index 353c89d..eec079a 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -62,6 +62,11 @@ install:
}
true;
+ # Cleanup the output of npm
+ - ps: >
+ npm config set progress false
+ npm config set spin false
+
# We don't currently have a port to test on windows
# - ps: $env:TEST_PORT = "COM1";
diff --git a/lib/serialport.js b/lib/serialport.js
index 83cfe15..e4a318a 100644
--- a/lib/serialport.js
+++ b/lib/serialport.js
@@ -56,27 +56,6 @@ var defaultSetFlags = {
rts: true
};
-// deprecate the lowercase version of these options next major release
-var LOWERCASE_OPTIONS = [
- 'baudRate',
- 'dataBits',
- 'stopBits',
- 'bufferSize',
- 'platformOptions'
-];
-
-function correctOptions(options) {
- LOWERCASE_OPTIONS.forEach(function(name) {
- var lowerName = name.toLowerCase();
- if (options.hasOwnProperty(lowerName)) {
- var value = options[lowerName];
- delete options[lowerName];
- options[name] = value;
- }
- });
- return options;
-}
-
/**
* A callback called with an error or null.
* @typedef {function} errorCallback
@@ -110,6 +89,7 @@ function correctOptions(options) {
* @param {module:serialport~openOptions=} options - Port configuration options
* @param {module:serialport~errorCallback=} openCallback - Called when a connection has been opened. If this is not provided and an error occurs, it will be emitted on the ports `error` event. The callback will NOT be called if autoOpen is set to false in the openOptions as the open will not be performed.
* @throws {TypeError} When given invalid arguments a TypeError will be thrown.
+ * @property {string} path The system path or name of the serial port. Read Only.
* @emits module:serialport#open
* @emits module:serialport#data
* @emits module:serialport#close
@@ -122,6 +102,8 @@ function SerialPort(path, options, callback) {
return new SerialPort(path, options, callback);
}
+ stream.Stream.call(this);
+
if (typeof callback === 'boolean') {
throw new TypeError('`openImmediately` is now called `autoOpen` and is a property of options');
}
@@ -131,19 +113,19 @@ function SerialPort(path, options, callback) {
options = {};
}
- options = options || {};
+ var settings = assign({}, defaultSettings, options);
- stream.Stream.call(this);
+ Object.defineProperty(this, 'path', {
+ enumerable: true,
+ writable: false,
+ value: path
+ });
- if (!path) {
+
+ if (!this.path) {
throw new TypeError('No path specified');
}
- this.path = path;
-
- var correctedOptions = correctOptions(options);
- var settings = assign({}, defaultSettings, correctedOptions);
-
if (typeof settings.baudRate !== 'number') {
throw new TypeError('Invalid "baudRate" must be a number got: ' + settings.baudRate);
}
@@ -269,8 +251,7 @@ SerialPort.prototype.update = function(options, callback) {
return this._error(new Error('Port is not open'), callback);
}
- var correctedOptions = correctOptions(options);
- var settings = assign({}, defaultSettings, correctedOptions);
+ var settings = assign({}, defaultSettings, options);
this.options.baudRate = settings.baudRate;
SerialPortBinding.update(this.fd, this.options, function(err) {
diff --git a/package.json b/package.json
index 7224165..8b15e7d 100644
--- a/package.json
+++ b/package.json
@@ -94,6 +94,7 @@
"stress": "mocha --no-timeouts test/arduinoTest/stress.js",
"lint": "eslint *.js lib/**/*.js test/**/*.js bin/**/*.js examples/**/*.js",
"test": "istanbul cover ./node_modules/mocha/bin/_mocha test/*.js test/arduinoTest/integration.js test/integration-lite.js",
+ "test:unit": "mocha test/*.js test/arduinoTest/integration.js test/integration-lite.js",
"report-coverage": "cat ./coverage/lcov.info | coveralls",
"valgrind": "valgrind --leak-check=full --show-possibly-lost=no node --expose-gc --trace-gc node_modules/.bin/grunt test"
},
diff --git a/test/serialport.js b/test/serialport.js
index 9311042..90c0abc 100644
--- a/test/serialport.js
+++ b/test/serialport.js
@@ -37,13 +37,6 @@ describe('SerialPort', function() {
done();
}
});
-
- it('takes lowercase options', function(done) {
- var port = new SerialPort.SerialPort('/dev/exists', { baudrate: 14400, autoOpen: false });
- assert.equal(port.options.baudRate, 14400);
- done();
- });
-
});
describe('Constructor', function() {
@@ -118,7 +111,7 @@ describe('SerialPort', function() {
it('errors with invalid databits', function(done) {
try {
- this.port = new SerialPort('/dev/exists', { databits: 19 });
+ this.port = new SerialPort('/dev/exists', { dataBits: 19 });
} catch(err){
assert.instanceOf(err, Error);
done();
@@ -127,7 +120,7 @@ describe('SerialPort', function() {
it('errors with invalid stopbits', function(done) {
try {
- this.port = new SerialPort('/dev/exists', { stopbits: 19 });
+ this.port = new SerialPort('/dev/exists', { stopBits: 19 });
} catch(err){
assert.instanceOf(err, Error);
done();
@@ -173,6 +166,21 @@ describe('SerialPort', function() {
});
});
+ describe('Properties', function() {
+ describe('.path', function(){
+ it('is a read only property set during construction', function(){
+ var port = new SerialPort('/dev/exists', {autoOpen: false});
+ assert.equal(port.path, '/dev/exists');
+ try {
+ port.path = 'foo';
+ } catch(e) {
+ assert.instanceOf(e, TypeError);
+ }
+ assert.equal(port.path, '/dev/exists');
+ });
+ });
+ });
+
describe('Methods', function() {
describe('#open', function() {
it('passes the port to the bindings', function(done) {