Skip to content

Instantly share code, notes, and snippets.

@Zirak
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zirak/58ac340e094c08acab05 to your computer and use it in GitHub Desktop.
Save Zirak/58ac340e094c08acab05 to your computer and use it in GitHub Desktop.
var readline = require('readline'),
fs = require('fs'),
tty = require('tty');
var device = fs.openSync('/dev/ttyO4', 'r+');
var rstream = new tty.ReadStream(device),
wstream = new tty.WriteStream(device);
rstream.on('data', function (chunk) {
console.log('Data from device');
console.log('' + chunk);
});
var cli = readline.createInterface(process.stdin, process.stdout);
cli.prompt();
cli.on('line', function (line) {
wstream.write(line + '\n');
cli.prompt();
}).on('end', function () {
shell.kill();
console.log('goodbye');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment