【发布时间】:2021-05-04 01:33:14
【问题描述】:
我正在使用节点 js 串口包 (https://serialport.io/docs/)。
我创建了以下串口对象:
var port = new SerialPort(data.device.hostPort, {
baudRate: 115200,
autoOpen: false,
}
);
我将此对象保存在 json 文件中,以便以后可以重用它。 但是,在检索到 json 文件中的数据并对其进行解析后,我无法使用串行端口对象方法,我尝试使用:
port.open(function(err){
if(err){
return console.log('Error opening port: ', err.message);
}
});
但我收到一条错误消息,提示无法识别 open 方法。 有人可以帮我解决这个问题吗? 提前致谢!
【问题讨论】: