Skip to content

Instantly share code, notes, and snippets.

@mauricesvay
Created February 13, 2012 21:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauricesvay/1820545 to your computer and use it in GitHub Desktop.
Save mauricesvay/1820545 to your computer and use it in GitHub Desktop.
//How to read RFID tags with a mir:ror and nodejs
//Requires https://github.com/hanshuebner/node-hid
var HID = require('HID');
var devices = new HID.devices(7592, 4865);
var hid;
if (!devices.length) {
console.log("No mir:ror found");
} else {
hid = new HID.HID(devices[0].path);
console.log(hid);
hid.read(onRead);
}
function onRead(error, data) {
switch (data[0]) {
case 1:
//Orientation change
if (data[1] == 4) {
console.log("mir:ror up");
} else if (data[1] == 5) {
console.log("mir:ror down");
}
break;
case 2:
//RFID
if (data[1] == 1) {
console.log("RFID in");
} else if (data[1] == 2) {
console.log("RFID out");
}
data.splice(0,4);
console.log(data.join("|"));
break;
}
hid.read(onRead);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment