I noticed a function in an Arduino example that goes like this:
uint8_t getPrint(int id){
......
p = finger.storeModel(id);
Serial.println();
if (p == FINGERPRINT_OK) {
Serial.println("Stored!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_BADLOCATION) {
Serial.println("Could not store in that location");
return p;
} else if (p == FINGERPRINT_FLASHERR) {
Serial.println("Error writing to flash");
return p;
} else {
Serial.println("Unknown error");
return p;
}
}
I didn't include the rest of the function because the argument was used only once as above. Whenever i pass a value greater that 255 to the function, the serial monitor prints id % 256 e.g. 300 changes to 44. As soon as i changed the return type to int, it began to behave normally. Is this possible? What can make a return type affect the arguments? I also noticed that the function does not return a value when it completes successfully (the if statement). Can this be the cause? The return value of the getPrint() function is used in this way by the loop() function:
void loop(){
//code that obtains an id (declared int) from the user
.......
while (! getPrint(id) );
}
I also need to ask: what value is returned to the while statement? When i run the code, the loop() function seems to restart each time the getPrint() function either returns or reaches the end, regardless of the success or failure of the function; i cant see the effect of the while statement. Thoughts? **All the constants are non-zero 8-bit values except FINGERPRINT_OK
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire