@7aman/wiegand-rfid-reader 中文文档教程
wiegand
node-wiegand 的一个分支,仅适用于 GPIO 上的 26 位 wiegand 读卡器。
在 Raspberry Pi 3 型号 B 上使用 EM-18 阅读器模块进行测试。
installation
$ npm install --save wiegand-rfid-reader
#OR
$ npm install --save https://github.com/7aman/wiegand-rfid-reader.git
usage
const wiegand = require('wiegand-rfid-reader');
const reader = wiegand();
const Gpio = require('onoff').Gpio;
//export d0, d1 pins
const d0 = 17, d1 = 18;
const wgnd0 = new Gpio(d0, "in", "both");
const wgnd1 = new Gpio(d1, "in", "both");
reader.begin({ d0: d0, d1: d1});
reader.on('id', id => {
console.log('Got', id, 'from RFID reader');
});
reader.on('error', err => {
console.log(err);
});
process.on('SIGINT', () => {
wgnd0.unexport();
wgnd1.unexport();
});
api
class: Wiegand
继承 EventEmitter
method: begin([options], [callback])
默认选项:
{
// RaspberryPI default
d0: 17,
d1: 18,
}
callback
将在 ready
事件或在此过程中发生错误时触发。 错误将在 error
事件中发出。
method: stop([callback])
停止轮询 GPIO 的更改。 完成后将回调并发出 stop
事件。
event: 'ready'
event: 'data'
event: 'error'
event: 'id'
event: 'stop'
license
wiegand
A fork of node-wiegand for only 26bits wiegand readers on GPIO.
Tested with EM-18 Reader Module on a Raspberry Pi 3 model B.
installation
$ npm install --save wiegand-rfid-reader
#OR
$ npm install --save https://github.com/7aman/wiegand-rfid-reader.git
usage
const wiegand = require('wiegand-rfid-reader');
const reader = wiegand();
const Gpio = require('onoff').Gpio;
//export d0, d1 pins
const d0 = 17, d1 = 18;
const wgnd0 = new Gpio(d0, "in", "both");
const wgnd1 = new Gpio(d1, "in", "both");
reader.begin({ d0: d0, d1: d1});
reader.on('id', id => {
console.log('Got', id, 'from RFID reader');
});
reader.on('error', err => {
console.log(err);
});
process.on('SIGINT', () => {
wgnd0.unexport();
wgnd1.unexport();
});
api
class: Wiegand
inherits EventEmitter
method: begin([options], [callback])
default options:
{
// RaspberryPI default
d0: 17,
d1: 18,
}
callback
will fire on the ready
event or if an error happens during the process. Errors will be emited on the error
event.
method: stop([callback])
stop polling for changes to GPIO. Will callback when done and emit a stop
event.
event: 'ready'
event: 'data'
event: 'error'
event: 'id'
event: 'stop'
license
更多