serialport
Advanced tools
Comparing version
@@ -0,1 +1,6 @@ | ||
Version 0.6.5 | ||
------------- | ||
- Added SetBaudRate, SetDTR; Custom Baud Rates | ||
- New "close" listener when device being disconnected | ||
Version 0.2.8 | ||
@@ -2,0 +7,0 @@ ------------- |
{ "name" : "serialport", | ||
"version" : "0.6.3", | ||
"version" : "0.6.5", | ||
"description" : "Welcome your robotic javascript overlords. Better yet, program them!", | ||
@@ -4,0 +4,0 @@ "author": "Chris Williams <voodootikigod@gmail.com>", |
@@ -89,5 +89,17 @@ "use strict"; | ||
}); | ||
}); | ||
})(this); | ||
var closeCallback = (function (me) { | ||
return (function () { | ||
me.emit("close"); | ||
}); | ||
})(this); | ||
var endCallback = (function (me) { | ||
return (function () { | ||
me.emit("end"); | ||
}); | ||
})(this); | ||
this.readStream.on("data", dataCallback); | ||
this.readStream.on("error", errorCallback); | ||
this.readStream.on("close", closeCallback); | ||
this.readStream.on("end", endCallback); | ||
} | ||
@@ -122,4 +134,19 @@ } | ||
SerialPort.prototype.set_baud_rate = function(baud_rate) { | ||
if (this.fd) { | ||
serialport_native.set_baud_rate(this.fd, baud_rate); | ||
} else { | ||
throw new Error("Can't set baud rate; invalid file descriptor"); | ||
} | ||
} | ||
SerialPort.prototype.set_dtr = function(boolean_value) { | ||
if (this.fd) { | ||
serialport_native.set_dtr(this.fd, boolean_value); | ||
} else { | ||
throw new Error("Can't set or clear DTR; invalid file descriptor"); | ||
} | ||
} | ||
module.exports.SerialPort = SerialPort; | ||
module.exports.parsers = parsers; |
// Test with the epic VirtualSerialPortApp - http://code.google.com/p/macosxvirtualserialport/ | ||
var SerialPort = require("../serialport").SerialPort; | ||
var sys = require("sys"), repl = require("repl"); | ||
var util = require("util"), repl = require("repl"); | ||
@@ -9,6 +9,6 @@ var serial_port = new SerialPort("/dev/master", {baudrate: 9600}); | ||
serial_port.on("data", function (data) { | ||
sys.puts("here: "+data); | ||
util.puts("here: "+data); | ||
}) | ||
serial_port.on("error", function (msg) { | ||
sys.puts("error: "+msg); | ||
util.puts("error: "+msg); | ||
}) | ||
@@ -15,0 +15,0 @@ repl.start("=>") |
// Test with the epic VirtualSerialPortApp - http://code.google.com/p/macosxvirtualserialport/ | ||
var SerialPort = require("../serialport").SerialPort; | ||
var sys = require("sys"); | ||
@@ -9,2 +8,2 @@ var serial_port = new SerialPort("/dev/master", {baudrate: 9600}); | ||
serial_port.write("It worked!\r"); | ||
serial_port.close(); | ||
serial_port.close(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24213
11.14%191
15.76%