I'm interested in connecting RFID readers and Ethernet to an mbed to form the basis for remote sensing. In theory the main interest is for tracking population movements in my college but as a reasonably keen garden railway enthusiast I'm also thinking about it for train tracking.
Anyway, the simple RFID program from the cookbook refuses to compile, I think, because of the change to using pin names (or rather PinNames) instead of ints to describe the names of the pins used for transmit and receive.
I've rewritten the sample code as follows, including the RFID.h and RFID.cpp files inline, and commented the lines that need changing with // CHANGE FROM:
#include "mbed.h"
namespace mbed {
class RFID {
public:
RFID(PinName tx, PinName rx); // CHANGE FROM RFID(int tx, int rx);
int readable(void);
int read (void);
private:
Serial _rfid;
};
}
using namespace mbed;
RFID::RFID(PinName tx, PinName rx) // CHANGE FROM RFID::RFID(int tx, int rx)
: _rfid(tx,rx) {}
int RFID::readable(void) {
return (_rfid.readable());
}
int RFID::read(void) {
while(_rfid.getc() != 2);
int v = 0;
_rfid.getc(); // drop 1st 2
_rfid.getc();
for(int i=7; i>=0; i--) {
char c = _rfid.getc(); // a ascii hex char
int part = c - '0';
v |= part << (i * 4);
}
for(int i=0; i<5; i++) {
_rfid.getc();
}
return v;
}
RFID rfid (p13,p14); // CHANGE FROM RFID rfid(13, 14);
Serial pc (USBTX,USBRX);
int main() {
while (1){
int id = rfid.read();
pc.printf("Tag ID = %d\n\r",id);
}
}
Not knowing a great deal about SVN and submitting changes I wonder if someone could make these changes into the RFID code at http://mbed.org/projects/cookbook/svn/RFID/trunk.
Now to get it talking over Ethernet!
John Stout
I'm interested in connecting RFID readers and Ethernet to an mbed to form the basis for remote sensing. In theory the main interest is for tracking population movements in my college but as a reasonably keen garden railway enthusiast I'm also thinking about it for train tracking.
Anyway, the simple RFID program from the cookbook refuses to compile, I think, because of the change to using pin names (or rather PinNames) instead of ints to describe the names of the pins used for transmit and receive.
I've rewritten the sample code as follows, including the RFID.h and RFID.cpp files inline, and commented the lines that need changing with // CHANGE FROM:
Now to get it talking over Ethernet!
John Stout