Go Down

Topic: TX command code & RX respond code of module via serial com (Read 17144 times) previous topic - next topic

PaulS

Where did you get the fingerprint reader you are trying to talk to? We have to know something about it in order to help you.
The art of getting good answers lies in asking good questions.

mr_hacker90

#16
Jan 15, 2013, 03:07 pm Last Edit: Jan 15, 2013, 03:15 pm by mr_hacker90 Reason: 1
my fingerprint? this is my fingerprint that i bought. at first i juz thought simple RX & TX. i never thought that it quite difficult to a beginner like me. SN-FPR-SM630. thank you mr pauls.

http://www.cytron.com.my/viewProduct.php?pcode=SN-FPR-SM630&name=Fingerprint%20Reader%20Integrated%20SM630

mr_hacker90

i've studied a little bit. thank you to u sir.  finally understand it a little bit. but, too bad. i don't bring the reader to my house. i left it at my hostel. at least i know the basic function. but, i'm not sure either this is the correct way to compare it. but, i know the basic operation by the way. i just not sure about the
Code: [Select]

m = memcmp(operationSuccess, operation, sizeof(operationSuccess));


by the way, thank you so much sir. at least from zero. i got half of it on what you told me. i wish i could got all of it. but i know, i need to study more. thank you coz taught me.

Code: [Select]

byte operationSuccess[] = {0x4D, 0x58, 0x30, 0x02, 0x40, 0x31, 0x48};
byte operation[7],m;

void operationSuccesful() {
  // Now, reply contains all 7 bytes
  for(byte n=0; n<7; n++)
  {
    while(Serial.available() == 0) {}; // Wait for a byte
    operation[n] = Serial.read();
   
    m = memcmp(operationSuccess, operation, sizeof(operationSuccess));
   
    if (m>0) {
      // set the cursor to column 0, line 1
      lcd.setCursor(0, 0);
      // print the number of seconds since reset:
      lcd.print("Operation Failed");
      }
     
    else if (m<0) {
      // set the cursor to column 0, line 1
      lcd.setCursor(0, 0);
      // print the number of seconds since reset:
      lcd.print("Operation Failed");
      }

   
    else {
      // set the cursor to column 0, line 1
      lcd.setCursor(0, 0);
      // print the number of seconds since reset:
      lcd.print("Operation Success");
      }
  }
}

mr_hacker90

#18
Jan 16, 2013, 09:11 am Last Edit: Jan 16, 2013, 09:27 am by mr_hacker90 Reason: 1
hello everyone. i currently make try to make a simple project. uno with fingerprint reader. as startup i try to add fingerprint.

at first. i try run the fingerprint reader + uno with X-CTU only. i use the terminal of the X-CTU. i sent the command code of the reader. and the reader reply with correct respond code & success operation code.
as u can see in the picture, the first 8 bytes {0x4D, 0x58, 0x10, 0x03, 0x40, 0x00, 0x00, 0xF8} is the command code for add fingerprint. then the reader reply 6 bytes correct respond code, {0x4D, 0x58, 0x30, 0x01, 0x01, 0xD7}. later the reader reply 7 bytes success operation code, {0x4D, 0x58, 0x30, 0x02, 0x40, 0x31, 0x48}.

then, i try make the program. so that it follow exactly what the reader respond as i tested above. i manage to make the code. by using X-CTU. i key the respond code, the arduino program able to detect the 6 bytes of the correct respond code & 7 bytes of success operation.

however, when i try to combine them both, it doesn't being to be happen. the arduino uno transmit the command code. but, the reader doesn't respond to that code. i believe there is a problem with my code. but, i don't have any idea where's the problem. with all, regards.

Code: [Select]

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8,9,4,5,6,7);

byte addFingerPrint[] = {0x4D, 0x58, 0x10, 0x03, 0x40, 0x00, 0x00, 0xF8}; // 8 bytes
byte respondCorrect[] = {0x4D, 0x58, 0x30, 0x01, 0x01, 0xD7}; // 6 bytes

byte operationSuccess[] = {0x4D, 0x58, 0x30, 0x02, 0x40, 0x31, 0x48}; // 7 bytes
byte timeOut[] = {0x4D, 0x58, 0x30, 0x02, 0x40, 0x33, 0x4A}; // 7 bytes
byte processFailure[] = {0x4D, 0x58, 0x30, 0x02, 0x40, 0x34, 0x4B}; // 7 bytes
byte parameterError [] = {0x4D, 0x58, 0x30, 0x02, 0x40, 0x35, 0x4C}; // 7 bytes
byte respond[6],operation[7],a,b,c,d;

void setup() {
 // initialize serial:
 Serial.begin(57600);
 
 // set up the LCD's number of columns and rows:
 lcd.begin(8, 2);

 displayLCD();
 
 addFinger();
 
 correctRespond();
 
 operationSuccesful();
}

void displayLCD(){
 // set the cursor to column 0, line 0
 lcd.setCursor(0, 0);
 // Print a message to the LCD.
 lcd.print("Fingerprint Reader");
}

void addFinger(){
 // set the cursor to column 0, line 1
 lcd.setCursor(0, 1);
 // Print a message to the LCD.
 lcd.print("Add Fingerprint");

 // write the 8bytes array of the command code
 Serial.write(addFingerPrint, sizeof(addFingerPrint));
 //delay(2000);
}

void correctRespond() {
 // Now, reply contains all 6 bytes
 for(byte n=0; n<6; n++)
 {
   while(Serial.available() == 0) {}; // Wait for a byte
   respond[n] = Serial.read();
   
   a = memcmp(respondCorrect, respond, sizeof(respondCorrect));

   if (a>0) {
     // set the cursor to column 0, line 0
     lcd.setCursor(0, 0);
     // Print a message to the LCD.
     lcd.print("Wrong   ");
     // set the cursor to column 0, line 1
     lcd.setCursor(0, 1);
     // Print a message to the LCD.
     lcd.print("Respond ");
     }
     
   else if (a<0) {
     // set the cursor to column 0, line 0
     lcd.setCursor(0, 0);
     // Print a message to the LCD.
     lcd.print("Wrong   ");
     // set the cursor to column 0, line 1
     lcd.setCursor(0, 1);
     // Print a message to the LCD.
     lcd.print("Respond ");
     }
   
   else {
     // set the cursor to column 0, line 0
     lcd.setCursor(0, 0);
     // Print a message to the LCD.
     lcd.print("Correct ");
     // set the cursor to column 0, line 1
     lcd.setCursor(0, 1);
     // Print a message to the LCD.
     lcd.print("Respond ");
     }
 }
 delay(2000);
}

void operationSuccesful() {
 // Now, reply contains all 7 bytes
 for(byte n=0; n<7; n++)
 {
   while(Serial.available() == 0) {}; // Wait for a byte
   operation[n] = Serial.read();
   
   b = memcmp(operationSuccess, operation, sizeof(operationSuccess));
   
   if (b==0) {
     // set the cursor to column 0, line 0
     lcd.setCursor(0, 0);
     // Print a message to the LCD.
     lcd.print("Operation");
     // set the cursor to column 0, line 1
     lcd.setCursor(0, 1);
     // Print a message to the LCD.
     lcd.print("Success ");
     }

   else {
     c = memcmp(processFailure, operation, sizeof(processFailure));
     
     if (c==0) {
       // set the cursor to column 0, line 0
       lcd.setCursor(0, 0);
       // Print a message to the LCD.
       lcd.print("Process ");
       // set the cursor to column 0, line 1
       lcd.setCursor(0, 1);
       // Print a message to the LCD.
       lcd.print("Failure ");
       }
     
     else  {
       d = memcmp(parameterError, operation, sizeof(parameterError));
       
       if (d==0) {
         // set the cursor to column 0, line 0
         lcd.setCursor(0, 0);
         // Print a message to the LCD.
         lcd.print("Parameter");
         // set the cursor to column 0, line 1
         lcd.setCursor(0, 1);
         // Print a message to the LCD.
         lcd.print("Error   ");
         }
       
       else {
         // set the cursor to column 0, line 0
         lcd.setCursor(0, 0);
         // Print a message to the LCD.
         lcd.print("Time    ");
         // set the cursor to column 0, line 1
         lcd.setCursor(0, 1);
         // Print a message to the LCD.
         lcd.print("Out     ");
       }
     }
   }
 }
 delay(2000);
}

void loop() {
}

PaulS

The art of getting good answers lies in asking good questions.

AWOL

And, by the magic of Moderation, back to a single topic.

mr_hacker90

i have a question here. is it possible for me to make a counter for the command code. for the add fingerprint add. by the way, it works. just the matter wrong connection for the RX & TX. not the programming.

AWOL

Quote
is it possible for me to make a counter for the command code. for the add fingerprint add.

If you explain what you mean by that, probably, yes.

mr_hacker90

what i mean is this byte.

Code: [Select]

byte deleteFingerPrint[] = {0x4D, 0x58, 0x10, 0x03, 0x42, 0x00, 0x00, 0xF8}; // 8 bytes


above is for fingerprint address 0. for finger print address 1, the only bytes those are changing are last 3 bytes. 00 01 F9. and for address 2, 00 02 FA. 3rd last bytes is for high byte 2nd last byte is for low byte & last byte is for check some. is the any mathematical expression that i can use in order it can change automatically according to the address?

AWOL

Quote
what i mean is this byte.

Which one?
There are eight.

If you're saying "Can I save the fixed first five bytes in one array, and have another 2D array holding the variable final three bytes, indexed by a counter?" then the answer is yes.
Code: [Select]
const byte fixedPart [5] = {0x4D, 0x58, 0x10, 0x03, 0x42};
byte variableParts [SOME_NUMBER][3];

mr_hacker90

#25
Jan 16, 2013, 01:06 pm Last Edit: Jan 16, 2013, 01:08 pm by mr_hacker90 Reason: 1
yup. like that. but how i want to integrate it with a counter? address 0, 0x00 0x00 0xF8. address 1, 0x00 0x01 0xF9. address 2, 0x00 0x02 FA. and so on.

AWOL

You just use the first subscript of "variableParts".
Or maybe I don't understand what you mean by "counter".

mr_hacker90

lets say later i want to key in the fingerprint address that i wanted to add / delete. i will key in it in the serial monitor. so, how i'm gonna link it with the variable byte? if i want to add address 0, i key in 0 in the serial monitor. then, it will look for byte address 0. and so on. on the linking part between the key in of the address in the serial monitor & variable byte. for the structure to accept input from serial monitor, that one i know how to do it.

AWOL

Quote
so, how i'm gonna link it with the variable byte?

Say you key in '1'.
So, '1' - '0' = 1. (or use "atoi" or whatever if you've captured a string)
Use that 1 as a subscript for the "variablePart" array.

mr_hacker90


Say you key in '1'.
So, '1' - '0' = 1. (or use "atoi" or whatever if you've captured a string)
Use that 1 as a subscript for the "variablePart" array.


i'm sorry sir. i don't get that.

Go Up