Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
3  bin/pinoccio.js
@@ -10,7 +10,8 @@ var commands = {
"who":require('../lib/commands/who'),
"register":require('../lib/commands/register'),
"rest":require('../lib/commands/rest'),
- "config":require('../lib/commands/config')
+ "config":require('../lib/commands/config'),
+ "serial":require('../lib/commands/serial'),
//"provision":<-- add any serial connected scouts to troops
// are you a lead scout?
// do you have a token?
View
3  lib/bitlash-rpc.js
@@ -1,7 +1,6 @@
module.exports = function(bitlashStream){
- var id = 0;
bitlashStream.on('data',function(o){
if(!o.cb) return;
o.cb(false,o.result);
@@ -9,7 +8,7 @@ module.exports = function(bitlashStream){
});
return function(command,cb){
- var o = {command:command,cb:cb};
+ var o = {type:'command',command:command,cb:cb};
bitlashStream.write(o);
setTimeout(function(){
if(o.cb) o.cb(new Error('bitlash: command '+o.command+' did not respond in 10 seconds'));
View
54 lib/commands/serial.js
@@ -1,23 +1,63 @@
+var serial = require('../serial');
+var rl = require('../rl');
+module.exports = function(args,api,config,cb){
+ var o = serial();
+ o.list(function(err,data){
-module.exports = function(args,api,config,cb){
+ if(args._[1] && data.indexOf(args._[1]) > -1) args.d = args._[1]
+ if(args.device) args.d = args.device;
+ if(args.d){
+ if(data.indexOf(args.d) > -1) {
+ o.connect(args.d,function(err,bl){
+ if(err) throw err;
+ console.log('starting bitlash repl for ',args.d)
+ var repl = rl();
+
+ repl.setPrompt('> ');
+ repl.prompt();
+ repl.on('line',function(line){
+ bl.command(line+'',function(err,data){
+ if(err) process.stderr.write('<err>'+err+"\n");
+ else {
+ console.log(data.substr(line.length+2));
+ repl.prompt();
+ }
+ });
+ }).on('SIGINT',function(){
+ console.log('close')
+ process.exit()
+ cb();
+ })
+
+ });
+ } else {
+ console.log('device ',args,d,'is not connected');
+ cb();
+ }
+ } else {
+ process.stdout.write('"'+data.join('" "')+'"\n');
+ cb();
+ }
+ })
}
module.exports.public = true;
module.exports.usage = "serial\n"
-"\n"
-+" lists scouts and \n
-+" opens a repl/command line to a scout\n"
-"\n "
++"\n"
++" lists scouts and may\n"
++" open a repl/command line to a scout\n"
++"\n "
+"Usage:\n"
+" pinoccio serial\n"
+" prints ther serial device of all of the connected pinoccios\n"
++" pinoccio serial device\n"
+" pinoccio serial -d device\n"
-+" -d --device <the serial device identifier>"
-+" --\n"
++" pinoccio serial --device device\n"
++" -d --device or the [second argument] <the serial device identifier>\n"
+" instead of a repl expect commands from stdin and print to stdout\n"
+"\n"
+"\n"
View
36 lib/interactive.js
@@ -1,24 +1,24 @@
var rl = require('./rl.js');
// ask questions from users get data back.
module.exports = function(ask,cb){
- var r = rl();
- var stateData = {};
+ var r = rl();
+ var stateData = {};
- var formatted = [];
- for(var i=0;i<ask.length;++i){
- (function(){
- var toAsk = ask[i];
- formatted.push([toAsk.question,function(input,next){
- toAsk.cb(input,function(value){
- stateData[toAsk.key] = value;
- next();
- })
- }])
- }());
- }
+ var formatted = [];
+ for(var i=0;i<ask.length;++i){
+ (function(){
+ var toAsk = ask[i];
+ formatted.push([toAsk.question,function(input,next){
+ toAsk.cb(input,function(value){
+ stateData[toAsk.key] = value;
+ next();
+ })
+ }])
+ }());
+ }
- rl.questions(r,formatted,function(){
- r.close();
- cb(false,stateData);
- });
+ rl.questions(r,formatted,function(){
+ r.close();
+ cb(false,stateData);
+ });
}

No commit comments for this range

Something went wrong with that request. Please try again.