0

I try to use these two libraries to detect a NFC tag (https://github.com/mitchellparsons/rc522-rfid-promise) and to control a MPD server (https://github.com/andrewrk/mpd.js) on a Raspberry Pi. I use Node v6.9.5 on Raspbian Jessie (2017-01-11).

When executing the following code only the MPD listener is executed. Is there something I did wrong or misunderstood the concept of 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")
})

Thank you!

Philluxx
  • 81
  • 2

1 Answers1

1

Try listening on the error event:

client.on('error', function (err) {
  console.log('Error:', err)
});
rsp
  • 107,747
  • 29
  • 201
  • 177
  • The error event is not fired, too. I now use another library (https://github.com/ocsacesar/rc522) and decoupled NFC reader and the main logic via https://github.com/weixiyen/messenger.js – Philluxx Feb 16 '17 at 17:01