forked from serialport/node-serialport
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopening.js
43 lines (33 loc) · 1.2 KB
/
opening.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
// Open event example
// var SerialPort = require('serialport').SerialPort;
// var port = new SerialPort('/dev/tty-usbserial1');
// port.on('open', function () {
// port.write('main screen turn on', function(err, bytesWritten) {
// if (err) {
// return console.log('Error: ', err.message);
// }
// console.log(bytesWritten, 'bytes written');
// });
// });
// port.on('data', function(data) { /* do anything */ });
// Constructor callback example
// var SerialPort = require('serialport').SerialPort;
// var port = new SerialPort('/dev/tty-usbserial1', function () {
// port.write('main screen turn on', function(err, bytesWritten) {
// if (err) {
// return console.log('Error: ', err.message);
// }
// console.log(bytesWritten, 'bytes written');
// });
// });
// When disabling open immediately.
// var SerialPort = require('serialport').SerialPort;
// var port = new SerialPort('/dev/tty-usbserial1', {}, false);
// port.open(function (err) {
// if (err) {
// return console.log('Error opening port: ', err.message);
// }
// // errors will be emitted on the port since there is no callback to write
// port.write('main screen turn on');
// });