Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dbuentello
Created September 1, 2016 13:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbuentello/e19ec1baa7c30b5a70311de19ffbb11b to your computer and use it in GitHub Desktop.
Save dbuentello/e19ec1baa7c30b5a70311de19ffbb11b to your computer and use it in GitHub Desktop.
Log tessel2 boot in a sane way.
// Because "hit enter as fast as you can"
/*
1. Requires serialport module (npm install serialport)
2. Run with node (node t2_log_boot.js)
3. Plug in tessel2.
*/
/* Figure out what port your tessel2 is plugged into and update the SERIAL_PORT variable. */
const SERIAL_PORT = '/dev/cu.usbmodem1412';
const SerialPort = require("serialport");
const port = new SerialPort(SERIAL_PORT, { autoOpen: false, parser: SerialPort.parsers.readline('\n') });
port.on('open', function() {
console.log(`Connected to ${SERIAL_PORT}`);
});
port.on('error', function(err) {
console.log('ERROR: ' + err.message);
});
port.on('disconnect', function(err) {
console.log('DISCONNECT: ' + err.message);
});
port.on('close', function() {
console.log('CONNECTION CLOSED');
retry();
});
port.on('data', function(data) {
console.log(data)
});
function retry(){
setTimeout(start, 250);
}
function start() {
port.open(function (err) {
if (err) {
console.log('OPEN ERROR: ' + err.message);
return retry();
}
});
}
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment