serialport
Advanced tools
Comparing version 1.4.6 to 1.4.8
@@ -0,1 +1,31 @@ | ||
Version 1.4.8 | ||
------------- | ||
- Simple bump for the binary. | ||
Version 1.4.7 | ||
------------- | ||
- Fix for Issue #398 - Dropped sent characters on OSX and Linux | ||
- Fix for Issue #387 - added isOpen | ||
- removed a residual comment | ||
- Added osx control signalling | ||
- Fix for Issue #401 | ||
- Fix for double write callbacks. | ||
- detect a serialport disconnect on linux. | ||
Version 1.4.6 | ||
------------- | ||
- Emit error on serialport when explicit handler present. Fixes gh-369 | ||
- Fix for windows and Node 0.11.13 (atom-shell) | ||
- Fix for broken Travis-CI build. | ||
Version 1.4.5 | ||
------------- | ||
- Identified and report issue to node.js core about recent 0.11.x system. | ||
- Removed support for 0.8.x | ||
- Updated dependencies | ||
Version 1.4.4 | ||
------------- | ||
- Fix for delete error. | ||
Version 1.3.0 | ||
@@ -2,0 +32,0 @@ ------------- |
{ | ||
"name": "serialport", | ||
"version": "1.4.6", | ||
"version": "1.4.8", | ||
"description": "Welcome your robotic javascript overlords. Better yet, program them!", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -17,7 +17,10 @@ ``` | ||
[![Gitter chat](https://badges.gitter.im/voodootikigod/node-serialport.png)](https://gitter.im/voodootikigod/node-serialport) | ||
[![Dependency Status](https://david-dm.org/voodootikigod/node-serialport.png) | ||
For all discussions, designs, and clarifications, we recommend you join our Gitter Chat room: [https://gitter.im/voodootikigod/node-serialport](https://gitter.im/voodootikigod/node-serialport) | ||
Version: 1.4.6 - Released September 3, 2014 | ||
Version: 1.4.8 - Released December 10, 2014 | ||
***** | ||
@@ -34,2 +37,4 @@ | ||
* [Johnny-Five](https://github.com/rwaldron/johnny-five) - Firmata based Arduino Framework. | ||
* [Cylon.js](http://cylonjs.com/) - JavaScript Robotics, By Your Command. | ||
* [node-l8smartlight](http://jakobwesthoff.github.io/node-l8smartlight/) ([source](https://github.com/jakobwesthoff/node-l8smartlight)) A node library to control the L8 Smartlight via Bluetooth or USB port | ||
@@ -305,3 +310,11 @@ * [firmata](https://github.com/jgautier/firmata) Talk natively to Arduino using the firmata protocol. | ||
* `disconnectedCallback` | ||
* `platformOptions` - sets platform specific options, see below. | ||
#### Unix Platform Options | ||
An object with the following properties: | ||
* `vmin` (default: 1) - see [`man termios`](http://linux.die.net/man/3/termios) | ||
* `vtime` (default: 0) - see [`man termios`](http://linux.die.net/man/3/termios) | ||
**_openImmediately (optional)_** | ||
@@ -388,1 +401,14 @@ | ||
### .on('error', callback) | ||
| ||
| ||
--- | ||
| ||
| ||
# Credit | ||
A special thanks to [The Hybrid Group](http://hybridgroup.com) for helping create and hosting the precompiled binaries for OSX, Linux, & Windows. This makes installing node-serialport much easier and much simpler for individuals using those platforms. Thank you. |
@@ -12,3 +12,3 @@ /*jslint node: true */ | ||
var path = require('path'); | ||
var PACKAGE_JSON = path.join(__dirname,'package.json'); | ||
var PACKAGE_JSON = path.join(__dirname, 'package.json'); | ||
var binding_path = binary.find(path.resolve(PACKAGE_JSON)); | ||
@@ -37,2 +37,3 @@ var SerialPortBinding = require(binding_path); | ||
var FLOWCONTROLS = ["XON", "XOFF", "XANY", "RTSCTS"]; | ||
var SETS = ["rts", "cts", "dtr", "dts"]; | ||
@@ -44,2 +45,13 @@ | ||
function makeDefaultPlatformOptions(){ | ||
var options = {}; | ||
if (process.platform !== 'win32') { | ||
options.vmin = 1; | ||
options.vtime = 0; | ||
} | ||
return options; | ||
} | ||
// The default options, can be overwritten in the 'SerialPort' constructor | ||
@@ -53,6 +65,11 @@ var _options = { | ||
xany: false, | ||
rts: false, | ||
cts: false, | ||
dtr: false, | ||
dts: false, | ||
databits: 8, | ||
stopbits: 1, | ||
buffersize: 256, | ||
parser: parsers.raw | ||
parser: parsers.raw, | ||
platformOptions: makeDefaultPlatformOptions() | ||
}; | ||
@@ -66,3 +83,3 @@ | ||
callback = args.pop(); | ||
if (typeof(callback) !== 'function') { | ||
if (typeof (callback) !== 'function') { | ||
callback = null; | ||
@@ -152,2 +169,3 @@ } | ||
options.parser = options.parser || _options.parser; | ||
options.platformOptions = options.platformOptions || _options.platformOptions; | ||
@@ -158,8 +176,10 @@ options.dataCallback = options.dataCallback || function (data) { | ||
options.disconnectedCallback = options.disconnectedCallback || function () { | ||
options.disconnectedCallback = options.disconnectedCallback || function (err) { | ||
if (self.closing) { | ||
return; | ||
} | ||
var err = new Error("Disconnected"); | ||
self.emit("disconnect",err); | ||
if (!err) { | ||
err = new Error("Disconnected"); | ||
} | ||
self.emit("disconnect", err); | ||
}; | ||
@@ -206,3 +226,9 @@ | ||
self.paused = false; | ||
self.serialPoller = new factory.SerialPortBinding.SerialportPoller(self.fd, function () { self._read(); }); | ||
self.serialPoller = new factory.SerialPortBinding.SerialportPoller(self.fd, function (err) { | ||
if (!err) { | ||
self._read(); | ||
} else { | ||
self.disconnected(err); | ||
} | ||
}); | ||
self.serialPoller.start(); | ||
@@ -216,2 +242,7 @@ } | ||
SerialPort.prototype.isOpen = function() { | ||
return (this.fd ? true : false); | ||
}; | ||
SerialPort.prototype.write = function (buffer, callback) { | ||
@@ -275,3 +306,2 @@ var self = this; | ||
if (err) { | ||
if (err.code && err.code === 'EAGAIN') { | ||
@@ -281,7 +311,6 @@ if (self.fd >= 0) { | ||
} | ||
} else if (err.code && (err.code === "EBADF" || err.code === 'ENXIO' || (err.errno===-1 || err.code === 'UNKNOWN'))) { // handle edge case were mac/unix doesn't clearly know the error. | ||
self.disconnected(); | ||
} else if (err.code && (err.code === "EBADF" || err.code === 'ENXIO' || (err.errno === -1 || err.code === 'UNKNOWN'))) { // handle edge case were mac/unix doesn't clearly know the error. | ||
self.disconnected(err); | ||
} else { | ||
self.fd = null; | ||
// console.log("afterRead"); | ||
self.emit('error', err); | ||
@@ -360,3 +389,3 @@ self.readable = false; | ||
SerialPort.prototype.disconnected = function (callback) { | ||
SerialPort.prototype.disconnected = function (err) { | ||
var self = this; | ||
@@ -367,5 +396,5 @@ var fd = self.fd; | ||
if (self.options.disconnectedCallback) { | ||
self.options.disconnectedCallback(); | ||
self.options.disconnectedCallback(err); | ||
} else { | ||
self.emit("disconnect"); | ||
self.emit("disconnect", err); | ||
} | ||
@@ -382,5 +411,10 @@ self.paused = true; | ||
factory.SerialPortBinding.close(fd, function (err) { | ||
if (err) { | ||
console.log('Disconnect completed with error:' + err); | ||
} else { | ||
console.log('Disconnect completed'); | ||
} | ||
}); | ||
} catch (e) { | ||
//handle silently as we are just cleaning up the OS. | ||
console.log('Disconnect failed with exception', e); | ||
} | ||
@@ -397,5 +431,2 @@ | ||
if (callback) { | ||
callback(); | ||
} | ||
}; | ||
@@ -424,2 +455,9 @@ | ||
self.closing = true; | ||
// Stop polling before closing the port. | ||
if (process.platform !== 'win32') { | ||
self.readable = false; | ||
self.serialPoller.close(); | ||
} | ||
try { | ||
@@ -443,7 +481,2 @@ factory.SerialPortBinding.close(fd, function (err) { | ||
if (process.platform !== 'win32') { | ||
self.readable = false; | ||
self.serialPoller.close(); | ||
} | ||
if (callback) { | ||
@@ -525,2 +558,39 @@ callback(); | ||
} else { | ||
if (callback) { | ||
callback(err, result); | ||
} | ||
} | ||
}); | ||
}; | ||
SerialPort.prototype.set = function (options, callback) { | ||
var self = this; | ||
var fd = self.fd; | ||
options = (typeof option !== 'function') && options || {}; | ||
// flush defaults, then update with provided details | ||
options.rts = options.rts || options.rts || _options.rts; | ||
options.cts = options.cts || options.cts || _options.cts; | ||
options.dtr = options.dtr || options.dtr || _options.dtr; | ||
options.dts = options.dts || options.dts || _options.dts; | ||
if (!fd) { | ||
var err = new Error("Serialport not open."); | ||
if (callback) { | ||
callback(err); | ||
} else { | ||
self.emit('error', err); | ||
} | ||
return; | ||
} | ||
factory.SerialPortBinding.set(fd, options, function (err, result) { | ||
if (err) { | ||
if (callback) { | ||
callback(err, result); | ||
} else { | ||
self.emit('error', err); | ||
} | ||
} else { | ||
callback(err, result); | ||
@@ -553,3 +623,5 @@ } | ||
} else { | ||
callback(err, result); | ||
if (callback) { | ||
callback(err, result); | ||
} | ||
} | ||
@@ -575,2 +647,2 @@ }); | ||
module.exports = new SerialPortFactory(); | ||
module.exports = new SerialPortFactory(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3646698
762
47993
411