I've have one of these RFID boards...
It returns a 30 byte message, starting with 0x02, and end with 0x03.
I've written this code to read from the board.
#include <SoftwareSerial.h>
SoftwareSerial RFID(7, 8);
char ch;
char buffer[30];
int idx;
boolean started = false;
void setup()
{
Serial.begin (9600);
RFID.begin (9600);
}
void loop()
{
while (RFID.available())
{
ch = RFID.read();
if (ch == 0x02) // Start byte
{
idx = 0;
started = true;
}
if (started) // Ignore anything received until we get a start byte.
{
buffer[idx++] = ch;
if (ch == 0x03) // End byte
{
// Display the received data.
for (int x = 0; x < idx; x++)
{
if (buffer[x] < 0x10)
{
Serial.print("0"); // Pad with leading 0
}
Serial.print (buffer[x], HEX);
Serial.print (" ");
}
started = false;
}
}
}
}
It seems to work fine... the message is as expected.. except for the 2nd to last byte (i.e. just before the last 0x03 byte).
The above code returns the following...
02 33 39 38 44 38 35 42 30 30 30 36 44 33 30 30 31 30 30 30 30 30 30 30 30 30 30 79 0FFFFFF86 03
Can anyone explain why I get this odd output?
Thanks