Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

serialport

Package Overview
Dependencies
Maintainers
1
Versions
175
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serialport - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

.travis.yml

8

package.json
{
"name": "serialport",
"version": "1.2.2",
"version": "1.2.3",
"description": "Welcome your robotic javascript overlords. Better yet, program them!",

@@ -41,3 +41,5 @@ "author": {

"mocha": "*",
"chai": "*"
"chai": "*",
"sinon-chai": "~2.4.0",
"sinon": "~1.7.3"
},

@@ -52,4 +54,4 @@ "engines": {

"scripts": {
"test": "mocha -R spec -t 60s -s 60s"
"test": "mocha -R spec"
}
}

@@ -0,7 +1,6 @@

/*jslint node: true */
"use strict";
/*global process require exports console */
// Copyright 2011 Chris Williams <chris@iterativedesigns.com>
var Buffer = require('buffer').Buffer;
var SerialPortBinding = require("bindings")("serialport.node");

@@ -38,3 +37,2 @@ var EventEmitter = require('events').EventEmitter;

var parsers = {

@@ -55,3 +53,3 @@ raw: function (emitter, buffer) {

// Split collected data by delimiter
var parts = data.split(delimiter)
var parts = data.split(delimiter);
data = parts.pop();

@@ -78,3 +76,11 @@ parts.forEach(function (part, i, array) {

};
function SerialPort (path, options, openImmediately) {
function SerialPort (path, options, openImmediately, callback) {
var args = Array.prototype.slice.call(arguments);
callback = args.pop();
if (typeof(callback) !== 'function') {
callback = null;
}
options = options || {};

@@ -87,2 +93,4 @@ openImmediately = (openImmediately === undefined || openImmediately === null) ? true : openImmediately;

var err;
options.baudRate = options.baudRate || options.baudrate || _options.baudrate;

@@ -96,3 +104,8 @@ // Removing check for valid BaudRates due to ticket: #140

if (DATABITS.indexOf(options.dataBits) == -1) {
throw new Error('Invalid "databits": ' + options.dataBits);
err = new Error('Invalid "databits": ' + options.dataBits);
if (callback) {
callback(err);
} else {
// TODO: emit error event
}
}

@@ -102,3 +115,9 @@

if (STOPBITS.indexOf(options.stopBits) == -1) {
throw new Error('Invalid "stopbits": ' + options.stopbits);
err = new Error('Invalid "stopbits": ' + options.stopbits);
if (callback) {
callback(err);
} else {
// TODO: emit error event
}
}

@@ -108,6 +127,17 @@

if (PARITY.indexOf(options.parity) == -1) {
throw new Error('Invalid "parity": ' + options.parity);
err = new Error('Invalid "parity": ' + options.parity);
if (callback) {
callback(err);
} else {
// TODO: emit error event
}
}
if (!path) {
throw new Error('Invalid port specified: ' + path);
err = new Error('Invalid port specified: ' + path);
if (callback) {
callback(err);
} else {
// TODO: emit error event
}
}

@@ -131,3 +161,8 @@

if (idx < 0) {
throw new Error('Invalid "flowControl": ' + fcup + ". Valid options: "+FLOWCONTROLS.join(", "));
var err = new Error('Invalid "flowControl": ' + fcup + ". Valid options: "+FLOWCONTROLS.join(", "));
if (callback) {
callback(err);
} else {
// TODO: emit error event
}
} else {

@@ -143,3 +178,3 @@

}
})
});
}

@@ -160,4 +195,3 @@ }

options.errorCallback = function (err) {
// console.log("sp err:", JSON.stringify(err));
self.emit('error', {spErr: err});
self.emit('error', err);
};

@@ -168,3 +202,4 @@ options.disconnectedCallback = function () {

}
self.emit('error', new Error("Disconnected"));
var err = new Error("Disconnected");
self.options.errorCallback(err);
// self.close();

@@ -204,3 +239,3 @@ };

if (err) {
self.emit('error', {openErr: err});
self.options.errorCallback(err);
if (callback) { callback(err); }

@@ -234,7 +269,8 @@ return;

if (!this.fd) {
var err = new Error("Serialport not open.");
self.options.errorCallback(err);
if (callback) {
return callback(new Error("Serialport not open."));
} else {
return;
callback(err);
}
return;
}

@@ -247,3 +283,3 @@

if (err) {
self.emit('error', {spWriteErr: err});
self.options.errorCallback(err);
}

@@ -358,3 +394,3 @@ if (callback) {

// No longer open?
if (null == self.fd)
if (null === self.fd)
return;

@@ -376,7 +412,8 @@

if (!fd) {
var err = new Error("Serialport not open.");
self.options.errorCallback(err);
if (callback) {
return callback(new Error("Serialport not open."));
} else {
return;
callback(err);
}
return;
}

@@ -394,8 +431,11 @@

SerialPortBinding.close(fd, function (err) {
if (err) {
self.emit('error', err);
self.options.errorCallback(err);
if (callback) {
callback(err);
}
return;
}
if (callback) {
callback(err);
}
self.emit('close');

@@ -410,6 +450,13 @@ self.removeAllListeners();

}
if (callback) {
callback();
}
});
} catch (ex) {
self.closing = false;
throw ex;
self.options.errorCallback(ex);
if (callback) {
callback(ex);
}
}

@@ -425,4 +472,10 @@ };

}
return console.log(err);
// TODO: emit error event
if (callback) {
callback(err);
}
return;
}
var dirName = "/dev/serial/by-id";

@@ -433,4 +486,9 @@ async.map(files, function (file, callback) {

if (err) {
return callback(err);
// TODO: emit error event
if (callback) {
callback(err);
}
return;
}
link = path.resolve(dirName, link);

@@ -480,3 +538,3 @@ callback(null, {

if (process.platform === 'win32') {
exports.list = SerialPortBinding.list
exports.list = SerialPortBinding.list;
} else if (process.platform === 'darwin') {

@@ -493,6 +551,6 @@ exports.list = SerialPortBinding.list;

if (!fd) {
var err = new Error("Serialport not open.");
self.options.errorCallback(err);
if (callback) {
return callback(new Error("Serialport not open."));
} else {
return;
callback(err);
}

@@ -503,3 +561,3 @@ }

if (err) {
self.emit('error', err);
self.options.errorCallback(err);
}

@@ -506,0 +564,0 @@ if (callback) {

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc