serialport
Advanced tools
Comparing version 1.1.1 to 1.1.3
@@ -0,4 +1,10 @@ | ||
Version 1.1.3 | ||
------------- | ||
- Remove ATL dependency on Windows (added Visual Studio Pro requirement) | ||
- Update build instructions | ||
- Four small bugfixes | ||
Version 1.0.7 | ||
------------- | ||
- Guaranteed in-order delivery of messages thanks to Jay Beaver and bnoordhuis | ||
- Guaranteed in-order delivery of messages thanks to Jay Beavers and bnoordhuis | ||
@@ -5,0 +11,0 @@ Version 1.0.6 |
{ | ||
"name": "serialport", | ||
"version": "1.1.1", | ||
"version": "1.1.3", | ||
"description": "Welcome your robotic javascript overlords. Better yet, program them!", | ||
@@ -23,2 +23,6 @@ "author": { | ||
"email": "joe.ferner@nearinfinity.com" | ||
}, | ||
{ | ||
"name": "Jay Beavers", | ||
"email": "jay@hikinghomeschoolers.org" | ||
} | ||
@@ -25,0 +29,0 @@ ], |
144
README.md
@@ -1,2 +0,2 @@ | ||
<pre> | ||
``` | ||
eeeee eeeee eeeee eeee e eeeee | ||
@@ -13,5 +13,5 @@ 8 8 8 88 8 8 8 8 8 " | ||
8ee88 88ee 88 8 88 88 8 88eee 88 8eee8 88 8 88 | ||
</pre> | ||
``` | ||
Version: 1.1.0 - Released August 24, 2012 - Now with Windows Support!!! | ||
Version: 1.1.3 - Released July 29, 2013 | ||
@@ -36,2 +36,3 @@ ***** | ||
* [devicestack](https://github.com/adrai/devicestack) - This module helps you to represent a device and its protocol. | ||
* [reflecta](https://github.com/jbeavers/reflecta) A communication protocol that combines Arduino Libraries and NodeJS into an integrated system. | ||
@@ -52,6 +53,2 @@ For getting started with node-serialport, we recommend you begin with the following articles: | ||
<pre> | ||
npm install serialport | ||
</pre> | ||
This assumes you have everything on your system necessary to compile ANY native module for Node.js. This may not be the case, though, so please ensure the following are true for your system before filing an issue about "Does not install". For all operatings systems, please ensure you have Python 2.x installed AND not 3.0, node-gyp (what we use to compile) requires Python 2.x. | ||
@@ -61,9 +58,21 @@ | ||
Ensure you have Visual Studio 2010+ (Express is fine) installed. If you are hacking on an Arduino, be sure to install [the drivers](http://arduino.cc/en/Main/Software). | ||
* Install Windows 7 or Windows 8. | ||
* Install [Visual Studio Express 2013 Preview for Windows Desktop](http://www.microsoft.com/visualstudio/eng/2013-downloads#d-2013-express) or [Visual Studio Express 2012 for Windows Desktop](http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-for-windows-desktop). | ||
* If you are hacking on an Arduino, be sure to install [the drivers](http://arduino.cc/en/Guide/windows#toc4). | ||
* Install [node.js 0.10.x](http://nodejs.org/) matching the bitness (32 or 64) of your operating system. | ||
* Install [Python 2.7.5](http://www.python.org/download/releases/2.7.5/) matching the bitness of your operating system. For any questions, please refer to their [FAQ](http://docs.python.org/2/faq/windows.html). Default settings are perfect. | ||
* Open the 'Visual Studio Command Prompt' and add Python to the path. When installing serialport, you need to tell the build system (known as node-gyp) that you are using a newer compiler by using: | ||
```Batchfile | ||
set path=%path%;C:\Python27 | ||
npm install serialport --msvs_version=2012 | ||
``` | ||
This switch works for both Visual Studio Express 2012 and 2013. | ||
### Mac OS X: | ||
Ensure that you have at a minimum the xCode Command Line Tools installed appropriate for your system configuration. If you recently upgrade OS, it probably removed your installation of Command Line Tools, please verify before submitting a ticket. | ||
Ensure that you have at a minimum the xCode Command Line Tools installed appropriate for your system configuration. If you recently upgraded the OS, it probably removed your installation of Command Line Tools, please verify before submitting a ticket. | ||
### Linux: | ||
### Desktop (Debian/Ubuntu) Linux: | ||
@@ -73,2 +82,32 @@ You know what you need for you system, basically your appropriate analog of build-essential. Keep rocking! | ||
``` | ||
sudo apt-get install build-essential | ||
npm install serialport | ||
``` | ||
### Raspberry Pi Linux: | ||
* Starting with a a vanilla New Out of the Box Software (NOOBS) Raspbian image (currently tested: 5/25/2013) | ||
* Log into your Raspberry Pi through whatever means works best and ensure you are on a terminal prompt for the remaining steps. This could be local or through an SSH (or a serial connection if you like). | ||
* Issue the following commands to ensure you are up to date: | ||
``` | ||
sudo apt-get update | ||
sudo apt-get upgrade -y | ||
``` | ||
* Download and install node.js: | ||
``` | ||
wget http://nodejs.org/dist/v0.10.12/node-v0.10.12-linux-arm-pi.tar.gz | ||
tar xvfz node-v0.10.12-linux-arm-pi.tar.gz | ||
sudo mv node-v0.10.12-linux-arm-pi /opt/node/ | ||
``` | ||
* Set up your paths correctly: | ||
``` | ||
echo 'export PATH="$PATH:/opt/node/bin"' >> ~/.bashrc | ||
source ~/.bashrc | ||
``` | ||
* Install using npm, note this will take a while as it is actually compiling code and that ARM processor is getting a workout. | ||
``` | ||
npm install serialport | ||
``` | ||
To Use | ||
@@ -79,8 +118,8 @@ ------ | ||
<pre> | ||
var SerialPort = require("serialport").SerialPort | ||
var serialPort = new SerialPort("/dev/tty-usbserial1", { | ||
baudrate: 57600 | ||
}); | ||
</pre> | ||
```js | ||
var SerialPort = require("serialport").SerialPort | ||
var serialPort = new SerialPort("/dev/tty-usbserial1", { | ||
baudrate: 57600 | ||
}); | ||
``` | ||
@@ -111,3 +150,3 @@ When opening a serial port, you can specify (in this order). | ||
<pre> | ||
```js | ||
serialPort.on("open", function () { | ||
@@ -123,7 +162,7 @@ console.log('open'); | ||
}); | ||
</pre> | ||
``` | ||
You can also call the open function, in this case instanciate the serialport with an additional flag. | ||
<pre> | ||
```js | ||
var SerialPort = require("serialport").SerialPort | ||
@@ -144,3 +183,3 @@ var serialPort = new SerialPort("/dev/tty-usbserial1", { | ||
}); | ||
</pre> | ||
``` | ||
@@ -152,11 +191,11 @@ List Ports | ||
<pre> | ||
serialport.list(function (err, ports) { | ||
ports.forEach(function(port) { | ||
console.log(port.comName); | ||
console.log(port.pnpId); | ||
console.log(port.manufacturer); | ||
}); | ||
```js | ||
serialport.list(function (err, ports) { | ||
ports.forEach(function(port) { | ||
console.log(port.comName); | ||
console.log(port.pnpId); | ||
console.log(port.manufacturer); | ||
}); | ||
</pre> | ||
}); | ||
``` | ||
@@ -168,38 +207,37 @@ Parsers | ||
<pre> | ||
var serialport = require("serialport"); | ||
var SerialPort = serialport.SerialPort; // localize object constructor | ||
var sp = new SerialPort("/dev/tty-usbserial1", { | ||
parser: serialport.parsers.readline("\n") | ||
}); | ||
</pre> | ||
```js | ||
var serialport = require("serialport"); | ||
var SerialPort = serialport.SerialPort; // localize object constructor | ||
var sp = new SerialPort("/dev/tty-usbserial1", { | ||
parser: serialport.parsers.readline("\n") | ||
}); | ||
``` | ||
To use the raw parser, you just provide the function definition (or leave undefined): | ||
<pre> | ||
var serialport = require("serialport"); | ||
var SerialPort = serialport.SerialPort; // localize object constructor | ||
var sp = new SerialPort("/dev/tty-usbserial1", { | ||
parser: serialport.parsers.raw | ||
}); | ||
</pre> | ||
```js | ||
var serialport = require("serialport"); | ||
var SerialPort = serialport.SerialPort; // localize object constructor | ||
var sp = new SerialPort("/dev/tty-usbserial1", { | ||
parser: serialport.parsers.raw | ||
}); | ||
``` | ||
You can get updates of new data from the Serial Port as follows: | ||
<pre> | ||
serialPort.on("data", function (data) { | ||
sys.puts("here: "+data); | ||
}); | ||
</pre> | ||
```js | ||
serialPort.on("data", function (data) { | ||
sys.puts("here: "+data); | ||
}); | ||
``` | ||
You can write to the serial port by sending a string or buffer to the write method as follows: | ||
<pre> | ||
```js | ||
serialPort.write("OMG IT WORKS\r"); | ||
</pre> | ||
``` | ||
Enjoy and do cool things with this code. | ||
Enjoy and do cool things with this code. |
@@ -25,4 +25,7 @@ "use strict"; | ||
}, | ||
readline: function (delimiter) { | ||
//encoding: ascii utf8 utf16le ucs2 base64 binary hex | ||
//More: http://nodejs.org/api/buffer.html#buffer_buffer | ||
readline: function (delimiter, encoding) { | ||
if (typeof delimiter === "undefined" || delimiter === null) { delimiter = "\r"; } | ||
if (typeof encoding === "undefined" || encoding === null) { encoding = "utf8"; } | ||
// Delimiter buffer saved in closure | ||
@@ -32,3 +35,3 @@ var data = ""; | ||
// Collect data | ||
data += buffer.toString(); | ||
data += buffer.toString(encoding); | ||
// Split collected data by delimiter | ||
@@ -88,5 +91,4 @@ var parts = data.split(delimiter) | ||
options.bufferSize = options.bufferSize || options.buffersize || 100; | ||
if (!('flowControl' in options)) { | ||
options.flowControl = false; | ||
} | ||
options.flowControl = options.flowControl || options.flowcontrol || false; | ||
options.dataCallback = function (data) { | ||
@@ -93,0 +95,0 @@ options.parser(self, data); |
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
618949
602
232