【发布时间】:2015-04-07 08:20:18
【问题描述】:
我在我的应用程序中使用串行端口包 (https://github.com/voodootikigod/node-serialport)。 这段代码在服务器上运行良好:
Meteor.startup(function () {
SerialPort = Meteor.npmRequire('serialport');
});
Meteor.methods({
serialPortsRefresh: function () {
SerialPort.list(function (err, ports) {
ports.forEach(function(port) {
console.log(port.comName);
});
// Config.insert(ports);
return ports;
});
}
});
现在我想将此列表保存在集合中以将其公开给客户端。 什么是最好的解决方案?
当我取消注释 Config.insert(ports);我有错误:
throw new Error("Meteor code must always run within a Fiber. " +
提前致谢!
【问题讨论】:
-
尝试使用 wrapasync 来避免光纤问题的运行。您可以在文档中找到它
标签: javascript meteor node-serialport