Fix infinite loop (#346)

* Fix infinite loop

Fixed the findID function getting stuck in an infinite loop when scanning certain cards.
Loop now stops at 255.
This commit is contained in:
Mads Mogensen
2017-11-06 22:30:37 +01:00
committed by Rotzbua
parent 97ac8d389d
commit ae13b02342

View File

@@ -27,8 +27,8 @@
| | | | | | | | | | | |
| +----+ +----v------+ +--v---+ | +---------------> | +----+ +----v------+ +--v---+ | +--------------->
+-------+EXIT| |DELETE FROM| |ADD TO| | | +-------+EXIT| |DELETE FROM| |ADD TO| | |
+----+ | EEPROM | |EEPROM| | | +----+ | EEPROM | |EEPROM| | |
+-----------+ +------+ +-------------------------------+ +-----------+ +------+ +-------------------------------+
Use a Master Card which is act as Programmer then you can able to choose card holders who will granted access or not Use a Master Card which is act as Programmer then you can able to choose card holders who will granted access or not
@@ -460,7 +460,7 @@ uint8_t findIDSLOT( byte find[] ) {
///////////////////////////////////////// Find ID From EEPROM /////////////////////////////////// ///////////////////////////////////////// Find ID From EEPROM ///////////////////////////////////
boolean findID( byte find[] ) { boolean findID( byte find[] ) {
uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that
for ( uint8_t i = 1; i <= count; i++ ) { // Loop once for each EEPROM entry for ( uint8_t i = 1; i < count; i++ ) { // Loop once for each EEPROM entry
readID(i); // Read an ID from EEPROM, it is stored in storedCard[4] readID(i); // Read an ID from EEPROM, it is stored in storedCard[4]
if ( checkTwo( find, storedCard ) ) { // Check to see if the storedCard read from EEPROM if ( checkTwo( find, storedCard ) ) { // Check to see if the storedCard read from EEPROM
return true; return true;