Permalink
Browse files

working list and terminal on ubuntu

  • Loading branch information...
1 parent f762902 commit f44e7e66f0661f4482955c08e24f35c253bc1ddc @joeferner joeferner committed Jun 27, 2012
View
@@ -9,3 +9,4 @@ Makefile.gyp
*.target.gyp.mk
out
gyp-mac-tool
+/.idea
View
@@ -6,4 +6,5 @@ Nathan Rajlich <nathan@tootallnate.net>
Rick Waldron <waldron.rick@gmail.com>
<w1nk>
Georges-Etienne Legendre <legege>
-Duane Johnson <duane.johnson@gmail.com>
+Duane Johnson <duane.johnson@gmail.com>
+Joe Ferner <joe@fernsroth.com>
View
@@ -1,2 +0,0 @@
-setup:
- node-waf configure build
View
@@ -0,0 +1,15 @@
+#!/usr/bin/env node
+
+var serialport = require('../');
+var sf = require('sf');
+
+serialport.list(function (err, results) {
+ if (err) {
+ throw err;
+ }
+
+ for (var i = 0; i < results.length; i++) {
+ var item = results[i];
+ console.log(sf('{comName,-15} {pnpId,-20} {manufacturer}', item));
+ }
+});
@@ -0,0 +1,80 @@
+#!/usr/bin/env node
+
+var SerialPort = require('../').SerialPort;
+var optimist = require('optimist');
+
+var args = optimist
+ .alias('h', 'help')
+ .alias('h', '?')
+ .options('portname', {
+ alias: 'p',
+ describe: 'Name of serial port. See serialPortList.js for open serial ports.'
+ })
+ .options('baud', {
+ describe: 'Baud rate.',
+ default: 9600
+ })
+ .options('databits', {
+ describe: 'Data bits.',
+ default: 8
+ })
+ .options('parity', {
+ describe: 'Parity.',
+ default: 'none'
+ })
+ .options('stopbits', {
+ describe: 'Stop bits.',
+ default: 1
+ })
+ .options('localecho', {
+ describe: 'Enable local echo.',
+ boolean: true
+ })
+ .argv;
+
+if (args.help) {
+ optimist.showHelp();
+ return process.exit(-1);
+}
+
+if (!args.portname) {
+ console.error("Serial port name is required.");
+ return process.exit(-1);
+}
+
+process.stdin.resume();
+process.stdin.setRawMode(true);
+process.stdin.on('data', function (s) {
+ if (s[0] === 0x03) {
+ port.close();
+ process.exit(0);
+ }
+ if (args.localecho) {
+ if (s[0] === 0x0d) {
+ process.stdout.write('\n');
+ } else {
+ process.stdout.write(s);
+ }
+ }
+ port.write(s, function (err) {
+ if (err) {
+ console.log(err);
+ }
+ });
+});
+
+var openOptions = {
+ baudRate: args.baud,
+ dataBits: args.databits,
+ parity: args.parity,
+ stopBits: args.stopbits
+};
+var port = new SerialPort(args.portname, openOptions);
+
+port.on('data', function (data) {
+ process.stdout.write(data.toString());
+});
+
+port.on('error', function (err) {
+ console.log(err);
+});
View
@@ -1,8 +1,30 @@
{
- 'targets': [
+ "targets": [
{
- 'target_name': 'serialport_native',
- 'sources': [ 'serialport_native/serialport_native.cc' ]
+ "target_name": "serialport",
+ "sources": [
+ "src/serialport.cpp",
+ "src/serialport_unix.cpp",
+ "src/serialport.h"
+ ],
+ 'conditions': [
+ ['OS=="win"',
+ {
+ 'sources': [
+ "src/serialport_win.cpp",
+ 'src/win/disphelper.c',
+ 'src/win/disphelper.h'
+ ]
+ }
+ ],
+ ['OS!="win"',
+ {
+ 'sources': [
+ "src/serialport_unix.cpp"
+ ]
+ }
+ ]
+ ]
}
]
}
View
@@ -1,17 +1,34 @@
-{ "name" : "serialport",
- "version" : "0.7.4",
- "description" : "Welcome your robotic javascript overlords. Better yet, program them!",
- "author": "Chris Williams <voodootikigod@gmail.com>",
- "main": "./serialport",
- "repository": {
- "type": "git",
- "url": "git://github.com/voodootikigod/node-serialport.git"
+{
+ "name": "serialport",
+ "version": "0.7.4",
+ "description": "Welcome your robotic javascript overlords. Better yet, program them!",
+ "author": "Chris Williams <voodootikigod@gmail.com>",
+ "main": "./serialport",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/voodootikigod/node-serialport.git"
+ },
+ "maintainers": [
+ {
+ "name": "Chris Williams",
+ "email": "voodootikigod@gmail.com"
},
- "scripts": {
- "install": "node-waf configure build"
- },
- "dependencies": {
- "bindings": "*"
- },
- "engines": { "node": ">= 0.6.0" }
+ {
+ "name": "Joe Ferner",
+ "email": "joe.ferner@nearinfinity.com"
+ }
+ ],
+ "dependencies": {
+ "bindings": "0.3.0",
+ "async": "0.1.18",
+ "sf": "0.1.3",
+ "optimist": "~0.3.4"
+ },
+ "engines": {
+ "node": ">= 0.6.0"
+ },
+ "bin": {
+ "serialportlist": "./bin/serialportList.js",
+ "serialportterm": "./bin/serialportTerminal.js"
+ }
}
View
@@ -1 +0,0 @@
-test
Oops, something went wrong.

0 comments on commit f44e7e6

Please sign in to comment.