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

serialport

Package Overview
Dependencies
Maintainers
0
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 0.2.2 to 0.2.3

._serialport.js

2

._package.json

@@ -1,4 +0,4 @@

Mac OS X  2��ATTRk�V��"�"com.macromates.caret{
Mac OS X  2��ATTR� ���"�"com.macromates.caret{
column = 22;
line = 1;
}

@@ -1,4 +0,4 @@

Mac OS X  2��ATTRk�X��#�#com.macromates.caret{
column = 34;
line = 14;
Mac OS X  2��ATTR� ���$�$com.macromates.caret{
column = 114;
line = 51;
}
{ "name" : "serialport",
"version" : "0.2.2",
"version" : "0.2.3",
"description" : "Welcome your robotic javascript overlords. Better yet, program them!",

@@ -4,0 +4,0 @@ "author": "Chris Williams <voodootikigod@gmail.com>",

@@ -15,3 +15,3 @@ <pre>

Version: 0.2.2 - Released March 19, 2011
Version: 0.2.3 - Released March 19, 2011

@@ -53,3 +53,3 @@ *****

* baudrate: Baud Rate, defaults to 9600. Must be one of: 115200, 57600, 38400, 19200, 9600, 4800, 2400, 1800, 120,, 600, 300, 200, 150, 134, 110, 75, or 50.
* baudrate: Baud Rate, defaults to 9600. Must be one of: 115200, 57600, 38400, 19200, 9600, 4800, 2400, 1800, 1200, 600, 300, 200, 150, 134, 110, 75, or 50.
* databits: Data Bits, defaults to 8. Must be one of: 8, 7, 6, or 5.

@@ -56,0 +56,0 @@ * stopbits: Stop Bits, defaults to 1. Must be one of: 1 or 2.

@@ -8,9 +8,9 @@ "use strict";

var Buffer = require('buffer').Buffer;
var events = require('events');
var stream = require('stream');
var fs = require('fs');
var net = require('net');
var serialport_native = require('./serialport_native');
var IOWatcher = process.binding('io_watcher').IOWatcher; // - for the future!
var IOWatcher = process.binding('io_watcher').IOWatcher;
var BAUDRATES = [115200, 57600, 38400, 19200, 9600, 4800, 2400, 1800, 120,, 600, 300, 200, 150, 134, 110, 75, 50];
var BAUDRATES = [115200, 57600, 38400, 19200, 9600, 4800, 2400, 1800, 1200, 600, 300, 200, 150, 134, 110, 75, 50];
var DATABITS = [8, 7, 6, 5];

@@ -50,38 +50,33 @@ var STOPBITS = [1, 2];

// can accept path, baudrate, databits, stopbits, parity
// The default options, can be overwritten in the 'SerialPort' constructor
var _options = {
baudrate: 38400,
databits: 8,
stopbits: 1,
parity: 0,
buffersize: 255,
parser: parsers.raw
};
function SerialPort(path, options) {
var _options = {
baudrate: 38400,
databits: 8,
stopbits: 1,
parity: 0,
buffersize: 255,
parser: parsers.raw
};
events.EventEmitter.call(this);
options = options || {};
options.__proto__ = _options;
this.port = path;
if (options.baudrate && BAUDRATES.indexOf(options.baudrate) >= 0) {
_options.baudrate = options.baudrate;
if (BAUDRATES.indexOf(options.baudrate) == -1) {
throw new Error('Invalid "baudrate": ' + options.baudrate);
}
if (options.databits && DATABITS.indexOf(options.databits) >= 0) {
_options.databits = options.databits;
if (DATABITS.indexOf(options.databits) == -1) {
throw new Error('Invalid "databits": ' + options.databits);
}
if (options.stopbits && STOPBITS.indexOf(options.stopbits) >= 0) {
_options.stopbits = options.stopbits;
if (STOPBITS.indexOf(options.stopbits) == -1) {
throw new Error('Invalid "stopbits": ' + options.stopbits);
}
if (options.parity && PARITY.indexOf(options.parity) >= 0) {
_options.parity = options.parity;
if (PARITY.indexOf(options.parity) == -1) {
throw new Error('Invalid "parity": ' + options.parity);
}
if (options.buffersize && typeof options.buffersize == "number" || options.buffersize instanceof Number) {
_options.buffersize = options.buffersize;
}
if (options.parser && typeof options.parser == 'function') {
_options.parser = options.parser;
}
this.fd = serialport_native.open(this.port, _options.baudrate, _options.databits, _options.stopbits, _options.parity);
stream.Stream.call(this);
this.port = path;
this.fd = serialport_native.open(this.port, options.baudrate, options.databits, options.stopbits, options.parity);
this.readWatcher = new IOWatcher();

@@ -91,8 +86,7 @@ this.empty_reads = 0;

return function () {
var buffer = new Buffer(_options.buffersize);
var buffer = new Buffer(options.buffersize);
var bytes_read = 0, err = null;
try {
bytes_read = serialport_native.read(file_id, buffer);
}
catch (e) {
} catch (e) {
err = e;

@@ -104,5 +98,6 @@ }

me.close();
} else {
options.parser(me, buffer.slice(0, bytes_read));
}
_options.parser(me, buffer.slice(0, bytes_read));
};
}
})(this.fd, this);

@@ -114,3 +109,3 @@ this.readWatcher.set(this.fd, true, false);

sys.inherits(SerialPort, events.EventEmitter);
sys.inherits(SerialPort, stream.Stream);

@@ -136,3 +131,11 @@ SerialPort.prototype.close = function () {

SerialPort.prototype.end = function(buf, enc) {
if (buf) {
this.write(buf, enc);
}
this.close();
}
module.exports.SerialPort = SerialPort;
module.exports.parsers = parsers;

@@ -1,4 +0,4 @@

Mac OS X  2��ATTRk�_��#�#com.macromates.caret{
Mac OS X  2��ATTR� ���#�#com.macromates.caret{
column = 26;
line = 11;
}

@@ -1,1 +0,4 @@

Mac OS X  2��ATTRk�a�� � com.macromates.caretx���R������<[k0?'3/«��
Mac OS X  2��ATTR� ���!�!com.macromates.caret{
column = 0;
line = 8;
}

@@ -6,3 +6,3 @@ // Test with the epic VirtualSerialPortApp - http://code.google.com/p/macosxvirtualserialport/

var serial_port = new SerialPort("/dev/master", 9600);
var serial_port = new SerialPort("/dev/master", {baudrate: 9600});

@@ -9,0 +9,0 @@ serial_port.on("data", function (data) {

@@ -6,4 +6,5 @@ // Test with the epic VirtualSerialPortApp - http://code.google.com/p/macosxvirtualserialport/

var serial_port = new SerialPort("/dev/master");
var serial_port = new SerialPort("/dev/master", {baudrate: 9600});
serial_port.write("It worked!\r");
serial_port.close();

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