mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-22 06:13:27 -07:00
mfu read block: retry block with bad CRC
This commit is contained in:
parent
51d51c6782
commit
4601d0e77a
1 changed files with 15 additions and 6 deletions
|
@ -310,6 +310,8 @@ void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
}
|
||||
}
|
||||
|
||||
#define MFU_MAX_CRC_RETRIES 5
|
||||
unsigned int retries = 0;
|
||||
for (int i = 0; i < blocks; i++){
|
||||
if ((i*4) + 4 >= CARD_MEMORY_SIZE) {
|
||||
Dbprintf("Data exceeds buffer!!");
|
||||
|
@ -320,15 +322,22 @@ void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
|
||||
if (len) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Read block %d error",i);
|
||||
// if no blocks read - error out
|
||||
if (i==0){
|
||||
OnError(2);
|
||||
return;
|
||||
|
||||
if (retries >= MFU_MAX_CRC_RETRIES) {
|
||||
// if no blocks read - error out
|
||||
if (i==0) {
|
||||
OnError(2);
|
||||
return;
|
||||
} else {
|
||||
//stop at last successful read block and return what we got
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
//stop at last successful read block and return what we got
|
||||
break;
|
||||
retries++;
|
||||
i--;
|
||||
}
|
||||
} else {
|
||||
retries = 0;
|
||||
countblocks++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue