-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserial.js
More file actions
36 lines (33 loc) · 1.05 KB
/
Copy pathserial.js
File metadata and controls
36 lines (33 loc) · 1.05 KB
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
const SerialPort = require("serialport");
const Readline = require("@serialport/parser-readline");
const serialport = new SerialPort("/dev/cu.usbmodem141101", {
baudRate: 9600
});
const readParser = serialport.pipe(new Readline({ delimiter: "\r\n" }));
readParser.on("data", console.log);
const Ready = require("@serialport/parser-ready");
const readyParser = serialport.pipe(new Ready({ delimiter: "\r\n" }));
readyParser.on("ready", message => {
console.log("ready", message);
});
// setTimeout(() => {
// console.log("****** SEND *********");
// port.write("a");
// }, 8000);
// setTimeout(() => {
// console.log("****** SEND *********");
// port.write("a");
// }, 16000);
// var SerialPort = serialport.SerialPort;
// // Open the port
// var port = new SerialPort("/dev/cu.usbmodem144101", {
// baudrate: 115200,
// parser: serialport.parsers.readline("\n")
// });
// // Read the port data
// port.on("open", function() {
// console.log("open");
// port.on("data", function(data) {
// console.log(data);
// });
// });