I've an RDM880 HW to read some 13.56MHz cards.
I've read the protocol of comunication and writed a sketch following some guides i found on the net. I'm able print on serial the response from the reciver correctly, but when i try to store it to use it, i encountering some problems. Following My code:
byte MF_GET_SNR[8] = {0xAA, 0x00, 0x03, 0x25, 0x26, 0x00, 0x00, 0xBB};
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
Serial1.write(MF_GET_SNR, 8);
delay(1000);
while(Serial1.available() > 0) {
Serial.print(Serial1.read(), HEX);
Serial.print(" ");
}
Serial.println();
}
I get this on serial monitor:
AA 0 2 1 83 80 BB
AA 0 2 1 83 80 BB
AA 0 2 1 83 80 BB
AA 0 6 0 0 ED B F0 6C 7C BB
AA 0 6 0 0 ED B F0 6C 7C BB
AA 0 6 0 0 ED B F0 6C 7C BB
AA 0 6 0 0 ED B F0 6C 7C BB
AA 0 2 1 83 80 BB
AA 0 2 1 83 80 BB
AA 0 2 1 83 80 BB
AA 0 2 1 83 80 BB
AA 0 2 1 83 80 BB
AA 0 2 1 83 80 BB
Where AA 0 6 0 0 ED B F0 6C 7C BB is the answare of the reciver when i put the card, where this ED B F0 6C should be the RFID of the card and
When i alter my code to store and use the data i get from the reciver in this way my problem starts:
byte MF_GET_SNR[8] = {0xAA, 0x00, 0x03, 0x25, 0x26, 0x00, 0x00, 0xBB};
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
Serial1.write(MF_GET_SNR, 8);
delay(1000);
char rfid[1024];
for (int i=0;i<14;i++) rfid[i]='0';
int counter=0;
while (Serial1.available()){
//var=Serial1.read();
rfid[counter]=Serial1.read();
actived=true;
Serial.print("Recived Element: "); Serial.println(rfid[counter],HEX);
counter++;
//Serial.println("CHECK1");
if (counter > 14) break;
}
}
And this the data i get:
Recived Element: FFFFFFAA
Recived Element: 0
Recived Element: 2
Recived Element: 1
Recived Element: FFFFFF83
Recived Element: FFFFFF80
Recived Element: FFFFFFBB
Recived Element: FFFFFFAA
Recived Element: 0
Recived Element: 6
Recived Element: 0
Recived Element: 0
Recived Element: 2B
Recived Element: FFFFFFA8
Recived Element: FFFFFFB5
Recived Element: FFFFFF9E
Recived Element: FFFFFFAE
Recived Element: FFFFFFBB
I cant understand how fix the problem with the FFFFFF readed in front of the HEX values.
Doesent seems to be a problem of baudrate becouse if i only try to read the data i get the correct values.
What i'm tryng to achive have to get this at the end: var="AA00060000ED0BF06C7CBB"