小编tsp*_*ree的帖子

Serialport Node.js 读取缓冲区问题

目标
我需要通过串行端口获取一批命令的数据,例如

写入串行:“命令”
来自串行接收器的预期响应:十六进制值

我使用了串口 包。


串行.js

var serialport = require('serialport');
var Readline = serialport.parsers.Readline; // make instance of Readline parser
var parser = new Readline(); // make a new parser to read ASCII lines


// list serial ports:
serialport.list(function (err, ports) {
    ports.forEach(function (port) {
        console.log("Serial Device: " + port.comName);
    });
});

// get port name from the command line:
var path = '/dev/cu.SLAB_USBtoUART' ;

var myPort = new serialport(path ,{
    baudRate: 230400,
});

// Read …
Run Code Online (Sandbox Code Playgroud)

node-serialport

1
推荐指数
1
解决办法
7503
查看次数

标签 统计

node-serialport ×1