Created
September 1, 2016 13:09
-
-
Save dbuentello/e19ec1baa7c30b5a70311de19ffbb11b to your computer and use it in GitHub Desktop.
Log tessel2 boot in a sane way.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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