![](/media/cache/profiles/94aef38441efa3380a3bed3faf1f9d5d.50x50_q85.jpg)
Dependencies: EthernetNetIf NTPClient_NetServices mbed
Diff: MyRFID.cpp
- Revision:
- 0:d441275f622f
diff -r 000000000000 -r d441275f622f MyRFID.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MyRFID.cpp Mon Aug 09 07:01:43 2010 +0000 @@ -0,0 +1,40 @@ +#include "MyRFID.h" +#include "mbed.h" + +using namespace mbed; + +MyRFID::MyRFID(PinName tx, PinName rx) + : _rfid(tx,rx) {} + + + +int MyRFID::readable(void) { + return (_rfid.readable()); +} + +void MyRFID::baud(int baudrate) { + return (_rfid.baud(baudrate)); +} + +unsigned int MyRFID::read(void) { + + unsigned int id=0; + int len,i; + + _rfid.getc();//header + _rfid.getc();//header + len = _rfid.getc(); + + char data[len]; + for (i=0;i<len;i++) { + data[i]=_rfid.getc(); + } + if (data[0]==0x50) {//success + for (i=0;i<4;i++) { + id |= (data[4-i] << (i * 8)); + } + } else {//failre + } + + return id; +} \ No newline at end of file