Node.js 串口路径

nus*_*ser 5 serial-port path node.js

对于我的 node.js 服务器的这部分代码

var SerialPort = require("serialport");
var port = new SerialPort("/dev/tty-usbserial1", {});
Run Code Online (Sandbox Code Playgroud)

它使用https://github.com/EmergingTechnologyAdvisors/node-serialport库。

我如何知道我的串行端口的路径?

tot*_*rds 3

要查找系统上可用 COM 端口的路径,可以使用列表方法。

我建议忽略任何具有未定义的制造商属性的东西,因为这些通常看起来像是内置蓝牙等。

例子:

const SerialPort = require('serialport') 
SerialPort.list((err, ports) => {
    console.log(ports)                
})
Run Code Online (Sandbox Code Playgroud)

文档: https ://node-serialport.github.io/node-serialport/SerialPort.html#.list