var SerialPort = require("serialport");
var port = new SerialPort("COM5");
port.on('open', function() {
port.write('main screen turn on', function(err) {
if (err) {
return console.log('Error on write: ', err.message);
}
console.log('message written');
});
});
// open errors will be emitted as an error event
port.on('error', function(err) {
console.log('Error: ', err.message);
})
install npm -g serialport
install npm serialport
错误:打开 COM5:未知错误代码 121