Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Just found and corrected a 'Bug' in RFID code,
Previously, the ID Number read back was treated as a decimal number, not a HEX String, My fix corrects this.
#include "ID12RFID.h" #include "mbed.h" ID12RFID::ID12RFID(PinName rx) : _rfid(NC, rx) { } int ID12RFID::readable() { return _rfid.readable(); } int ID12RFID::read() { while (_rfid.getc() != 2); int v = 0; _rfid.getc(); // drop 1st 2 bytes - we actually only read the lower 32-bits of the code _rfid.getc(); for (int i=7; i>=0; i--) { char c = _rfid.getc(); // a ascii hex char int part = c - '0'; // test if 'Alpha' if (part > 9) part -= 7; // Quick & dirty ! v |= part << (i * 4); } for (int i=0; i<5; i++) { _rfid.getc(); } return v; }Hope this is of use
Ceri