Skip to content

Instantly share code, notes, and snippets.

@phillipsnick
Created April 4, 2018 11:47
Show Gist options
  • Save phillipsnick/a91f1ff421875703fd4144e608e05a65 to your computer and use it in GitHub Desktop.
Save phillipsnick/a91f1ff421875703fd4144e608e05a65 to your computer and use it in GitHub Desktop.
Pure Theatre RS232
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);
})
{
"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"
}
}
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