Matrix Comparison 50x24 - RFID

Hello guys,

I am using a serial RFID module to read data of 50 RFID tags with Arduino Mega.

In my code I have two Matrix, size of 50x24. one is used as a buffer and the other to store proper readings.

After reaching to 50 count and proper reading, i will transfer readings to the other matrix which is the real database.

i am facing issue with comparison. for the fist sets of reading i can save all the data directly as it is initialisation. However, for next readings i have to compare each stored id in the buffer with all 50 ids in the database and if it is not there, save it. otherwise ignore it.

here is my code. to make it easier i removed the part of cheeking for correct reading. So it will only read data and put it in the database without cheeking and comparison:

here is the code (following post as i reached the count limit!):

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.

i am facing issue with comparison

If you want help, you'll tell us what that issue is.

What are you sending the binary data to, with the Serial1.write() calls?

Why isn't the code to dump the existing data in a function that you call from loop()?

                      Serial1.write(message, sizeof(message));  // sending command to the module

What module?

Why do you need to dump the existing array TWICE?

 // HERE I NEED TO DO THE COMPASSION AND THEN ADD IT ,IF ITS NOT IN THE DATABASE

SO, WHY DON'T YOU?

Why are you screaming? We DO have closed captioning, even if we can't hear.