我尝试使用这两个库来检测 NFC 标签 ( https://github.com/mitchellparsons/rc522-rfid-promise ) 并控制 Raspberry Pi 上的 MPD 服务器 ( https://github.com/andrewrk/mpd.js )。我在 Raspbian Jessie 上使用 Node v6.9.5 (2017-01-11)。
执行以下代码时,仅执行 MPD 监听器。我是否做错了什么或误解了 Nodejs 的概念?
var mpd = require('mpd')
var rc522 = require("rc522-rfid-promise")
var client = mpd.connect({
port: 6600,
host: 'localhost',
})
rc522.startListening()
.then(function(rfidTag){
console.log('Got RFID tag')
})
client.on('ready', function() {
console.log("MPD ready")
})
谢谢!
最佳答案
尝试监听错误事件:
client.on('error', function (err) {
console.log('Error:', err)
});
关于javascript - Node 中库的回调被阻塞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42273869/