Created
February 13, 2012 21:13
-
-
Save mauricesvay/1820545 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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