问题
For this part of code for my node.js server
var SerialPort = require("serialport");
var port = new SerialPort("/dev/tty-usbserial1", {});
wich use the https://github.com/EmergingTechnologyAdvisors/node-serialport library how I can know this path to my serial port?
回答1:
To find the paths of available COM ports on the system, you can use the list method.
I'd advise omitting any that have an undefined manufacturer property as these normally seem to be things like built-in bluetooth etc.
Example:
const SerialPort = require('serialport')
SerialPort.list((err, ports) => {
console.log(ports)
})
Documentation: https://node-serialport.github.io/node-serialport/SerialPort.html#.list
来源:https://stackoverflow.com/questions/38607979/node-js-path-to-serialport