node-serialport-bindings-cpp/examples/open-event.js
Francis Gulotta 414057c4dc Promised based bindings.
- Base bindings class to extend
- Move docs to base binding
- Make all bindings classes
- Ditch push bindings because it doesn't make anything cleaner
2017-01-10 23:02:51 -05:00

20 lines
495 B
JavaScript

/* eslint-disable require-path-exists/exists */
'use strict';
// Open event example
const SerialPort = require('serialport');
const port = new SerialPort('/dev/tty-usbserial1');
port.on('open', () => {
console.log('Port Opened');
});
port.write('main screen turn on', (err) => {
if (err) { return console.log('Error: ', err.message) }
console.log('message written');
});
port.on('data', (data) => {
/* get a buffer of data from the serial port */
console.log(data.toString());
});