Sha256: c8e4941146a7ba7152eb774020d5b2ae5f752ab62d1a0aef7da3842305cbb1cf

Contents?: true

Size: 1.49 KB

Versions: 5

Compression:

Stored size: 1.49 KB

Contents

// Arduino Node.js


var sys  = require('sys'),
fs  = require('fs'),
faye  = require('./vendor/faye');

var dpath = "/dev/ttyUSB1";

var client = new faye.Client('http://localhost:8000/faye');

var subscription = client.subscribe('/foo', function(message) {
  sys.puts("SUB!!!");  // handle message
});

var log = function(txt) {
  sys.puts(txt)
}

var find_arduino = function(err, stats) {
  if(err)
    return log("Arduino not found...");

  log("DUIN!");
  log(sys.inspect(stats));
}

fs.stat("/dev/ttyUSB1", find_arduino);


var spawn = require('child_process').spawn,
    stty  = spawn('stty -F /dev/ttyUSB1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts'); //, ['-lh', '/usr']);

stty.stdout.on('data', function (data) {
  sys.print('stdout: ' + data);
});

stty.stderr.on('data', function (data) {
  log("Could not stty " + dpath);
  log('stderr: ' + data);
});

stty.on('exit', function (code) {
  if (code == 0)
    console.log('Done modding stty ' + dpath);
});


// stty -F /dev/ttyUSB1 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
var rr = fs.createReadStream(dpath, {
  'flags': 'r',
  'encoding': 'ascii', // binary, utf8
  // 'mode': 0666,
  // 'bufferSize': 4 * 1024
});


rr.addListener('data', function (chunk) {
  log('data: ' + chunk);
  log(sys.inspect(chunk));
});

rr.on('end', function () {
  log('end, closed fs');
});



Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
subduino-0.3.1 node/arduinode.js
subduino-0.2.2 node/arduinode.js
subduino-0.2.1 node/arduinode.js
subduino-0.2.0 node/arduinode.js
subduino-0.1.0 node/arduinode.js