netease-youdao / hex

heX
Other
1.52k stars 301 forks source link

引用nodejs的串口模块出现问题,请问怎么解决? #44

Open BluePlan-xiaoke opened 10 years ago

BluePlan-xiaoke commented 10 years ago

try{ var SerialPort = require("serialport").SerialPort alert(SerialPort); var serialPort = new SerialPort("COM4", { baudrate: 9600, databits:8, stopbits:1, parity:'none', flowcontral:false, bufferSize:2000 }, false); // this is the openImmediately flag [default is true]

serialPort.open(function () { console.log('open'); serialPort.on('data', function(data) { console.log('data received: ' + data); }); serialPort.write("ls\n", function(err, results) { console.log('err ' + err); console.log('results ' + results); }); }); } catch(e){ alert(e.message); } 提示错误为: a valid Stream instance must be passed in

BluePlan-xiaoke commented 10 years ago

求大神帮我解决这个问题!!!!

xiongxin commented 10 years ago

serialport你这个模块是node自带的吗