Wiegand card reader driver library
Import libraryCardReader
Wiegand card reader driver library
This is a Wiegand 2 signal (Data0, Data1) card reader interface library.
Information
Todo - parity checking.
Wiegand technology References
- How Do Wiegand Card Readers and Devices Work
- HID
- ib technology
- Pyramid
- Mercury - Missing Diagrams
- RS2 Technologies - Some documented card formats
Hobbyist project
Library use example
/* * Wiegand card reader driver library * Copyright (c) 2012 Neal Horman - http://www.wanlink.com * * License: MIT open source (http://opensource.org/licenses/MIT) * Summary; * Use / modify / distribute / publish it how you want and * if you use it, or don't, you can't hold me liable for how * it does or doesn't work. * If it doesn't work how you want, don't use it, or change * it so that it does work. */ #include "mbed.h" #include "ReaderWiegand.h" Serial gSerial(USBTX, USBRX); ReaderWiegand gReader(p10,p11); int main() { gSerial.printf("Ready\r\n"); while(1) { if(gReader.isNew()) { uint8_t bq = gReader.bitCount(); uint64_t bits = gReader.bits(); for(uint8_t i=0; i<bq; i++) gSerial.printf("%c",'0' + ( ( bits & ( (uint64_t)1 << i ) ) != 0)); gSerial.printf(" bq: %u h: 0x%llX ",bq,bits); if(gReader.isValid()) gSerial.printf("f: %lu, c: %lu\r\n",gReader.facility(),gReader.card()); else gSerial.printf("Unknown format\r\n"); gReader.old(); } } }
ReaderWiegand.h@0:b468573740b5, 2012-07-18 (annotated)
- Committer:
- nkhorman
- Date:
- Wed Jul 18 01:54:58 2012 +0000
- Revision:
- 0:b468573740b5
Add copyright and licensing.; Move to library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nkhorman | 0:b468573740b5 | 1 | /* |
nkhorman | 0:b468573740b5 | 2 | * Wiegand card reader driver library |
nkhorman | 0:b468573740b5 | 3 | * Copyright (c) 2012 Neal Horman - http://www.wanlink.com |
nkhorman | 0:b468573740b5 | 4 | * |
nkhorman | 0:b468573740b5 | 5 | * License: MIT open source (http://opensource.org/licenses/MIT) |
nkhorman | 0:b468573740b5 | 6 | * Summary; |
nkhorman | 0:b468573740b5 | 7 | * Use / modify / distribute / publish it how you want and |
nkhorman | 0:b468573740b5 | 8 | * if you use it, or don't, you can't hold me liable for how |
nkhorman | 0:b468573740b5 | 9 | * it does or doesn't work. |
nkhorman | 0:b468573740b5 | 10 | * If it doesn't work how you want, don't use it, or change |
nkhorman | 0:b468573740b5 | 11 | * it so that it does work. |
nkhorman | 0:b468573740b5 | 12 | */ |
nkhorman | 0:b468573740b5 | 13 | |
nkhorman | 0:b468573740b5 | 14 | |
nkhorman | 0:b468573740b5 | 15 | #ifndef _READERWIEGAND_H_ |
nkhorman | 0:b468573740b5 | 16 | #define _READERWIEGAND_H_ |
nkhorman | 0:b468573740b5 | 17 | |
nkhorman | 0:b468573740b5 | 18 | #include "Reader.h" |
nkhorman | 0:b468573740b5 | 19 | |
nkhorman | 0:b468573740b5 | 20 | // Use interupt driven inputs to gather the card data |
nkhorman | 0:b468573740b5 | 21 | class ReaderWiegand : public Reader |
nkhorman | 0:b468573740b5 | 22 | { |
nkhorman | 0:b468573740b5 | 23 | public: |
nkhorman | 0:b468573740b5 | 24 | ReaderWiegand(PinName data0, PinName data1) : Reader(), mData0Irq(data0), mData1Irq(data1) |
nkhorman | 0:b468573740b5 | 25 | { |
nkhorman | 0:b468573740b5 | 26 | mData0Irq.mode(PullUp); |
nkhorman | 0:b468573740b5 | 27 | mData1Irq.mode(PullUp); |
nkhorman | 0:b468573740b5 | 28 | mData0Irq.fall(this,&ReaderWiegand::data0Fall); |
nkhorman | 0:b468573740b5 | 29 | mData1Irq.fall(this,&ReaderWiegand::data1Fall); |
nkhorman | 0:b468573740b5 | 30 | mData0Irq.rise(this,&ReaderWiegand::data01Rise); |
nkhorman | 0:b468573740b5 | 31 | mData1Irq.rise(this,&ReaderWiegand::data01Rise); |
nkhorman | 0:b468573740b5 | 32 | }; |
nkhorman | 0:b468573740b5 | 33 | protected: |
nkhorman | 0:b468573740b5 | 34 | InterruptIn mData0Irq; |
nkhorman | 0:b468573740b5 | 35 | InterruptIn mData1Irq; |
nkhorman | 0:b468573740b5 | 36 | Timeout mTimer; |
nkhorman | 0:b468573740b5 | 37 | void swiped() { Reader::swiped(); }; |
nkhorman | 0:b468573740b5 | 38 | |
nkhorman | 0:b468573740b5 | 39 | void timerRestart() { mTimer.detach(); mTimer.attach_us(this,&ReaderWiegand::swiped,50*1000); }; |
nkhorman | 0:b468573740b5 | 40 | |
nkhorman | 0:b468573740b5 | 41 | void data0Fall() { shiftIn(0); timerRestart(); }; |
nkhorman | 0:b468573740b5 | 42 | void data1Fall() { shiftIn(1); timerRestart(); }; |
nkhorman | 0:b468573740b5 | 43 | void data01Rise() { timerRestart(); }; |
nkhorman | 0:b468573740b5 | 44 | }; |
nkhorman | 0:b468573740b5 | 45 | |
nkhorman | 0:b468573740b5 | 46 | #endif |