Created
April 4, 2018 11:47
-
-
Save phillipsnick/a91f1ff421875703fd4144e608e05a65 to your computer and use it in GitHub Desktop.
Pure Theatre RS232
This file contains 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
var SerialPort = require('serialport'); | |
var port = new SerialPort('/dev/tty.usbserial', { | |
baudRate: 9600 | |
}); | |
port.on('open', function() { | |
console.log('open') | |
port.write(new Buffer('#DDN\r'), (err, res) => { | |
if (err) { | |
return console.log('err', err) | |
} | |
console.log('sent!', res) | |
}) | |
}); | |
// open errors will be emitted as an error event | |
port.on('error', function(err) { | |
console.log('Error: ', err.message); | |
}) | |
This file contains 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
{ | |
"name": "pure-theatre", | |
"version": "1.0.0", | |
"description": "", | |
"main": "app.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"serialport": "^6.0.5" | |
} | |
} |
This file contains 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
var SerialPort = require('serialport'); | |
var port = new SerialPort('/dev/tty.usbserial', { | |
baudRate: 9600 | |
}); | |
port.on('open', function() { | |
console.log('open') | |
port.write(new Buffer('#DUP\r'), (err, res) => { | |
if (err) { | |
return console.log('err', err) | |
} | |
console.log('sent!', res) | |
}) | |
}); | |
// open errors will be emitted as an error event | |
port.on('error', function(err) { | |
console.log('Error: ', err.message); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment