uint8_t message[] = {0xBB, 0x00, 0x22, 0x0000, 0x0000, 0x22, 0x7E}; // reading command
uint8_t q[] = {0xBB, 0x00, 0x0E, 0x0000, 0x0002, 0x10,0x38, 0x58, 0x7E}; // max quary 8
uint8_t p[] = {0xBB, 0x00, 0xB6, 0x0000, 0x0002, 0x0007,0xD0, 0x8F, 0x7E}; // max power command
uint8_t d[] = {0xBB, 0x00, 0xF5, 0x0000, 0x0001, 0x0000,0xF6,0x7E}; // max density
uint8_t id[51][25]={{}};
uint8_t id2[51][25]={{}};
int r=0; // counting row
int c=0; // counting Columns
int s; // serial read
int i=0; // column increase and decrease
unsigned long previousMillis = 0; // for timer
const long interval = 2000; // interval
void setup() {
Serial.begin(115200);
Serial1.begin(115200);
// setting up the RFID Module
delay(1000);
Serial1.write(q, sizeof(q));
delay(1000);
Serial1.write(p, sizeof(p));
delay(1000);
Serial1.write(d, sizeof(d));
delay(500);
}
void loop() {
unsigned long currentMillis = millis();
// interval for calling data
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
Serial.println("The Buffer is: ");
for ( int i = 0; i < 50; ++i ) {
for ( int j = 0; j < 24; ++j ){
Serial.print (id[ i ][ j ] ,HEX);
Serial.print (" ");
}
Serial.println () ; // start new line of output
}
delay(100);
Serial.println(r);
delay(100);
Serial1.write(message, sizeof(message)); // sending command to the module
}// end interval
if (r>=50){ // if reached to 50 reads
Serial1.flush();
Serial.println () ;
Serial.println("Buffer is: ");
for ( int i = 0; i < 50; ++i ) {
// loop through columns of current row
for ( int j = 0; j < 24; ++j ){
Serial.print (id[ i ][ j ] ,HEX);
Serial.print (" ");
}//end for j
Serial.println () ; // start new line of output
}//end for i
Serial.println("Data base is: ");
for ( int i = 0; i < 50; ++i ) {
// loop through columns of current row
for ( int j = 0; j < 24; ++j ){
// HERE I NEED TO DO THE COMPASSION AND THEN ADD IT ,IF ITS NOT IN THE DATABASE
id2[i][j]=id[i][j];
Serial.print (id2[ i ][ j ] ,HEX);
Serial.print (" ");
}//end for j
Serial.println () ; // start new line of output
}//end for i
Serial.println () ;
for ( int i = 0; i < 50; ++i ) {
for ( int j = 0; j < 24; ++j ){
id[i][j]=0;// setting buffer to 0, ready for next reading
}
}
delay(5000);
Serial.println();
delay(2000);
s=0;
r=0;
}// end if a> 50
// Reading the data
while (Serial1.available()) {
s= Serial1.read();
id[r][i]=s;
i++;
if (s==126){ // going to next row
i=0;
r++;
}
}//end while
}//end
I have thought of different ways, such as saving each is as a string and compare it with the database or using "strcmp" . However, no success.
I would really appreciate any guidance.
Thanks.