chg: 'hf mfu read'

chg: 'hf mfu dump'  - 5 retries if failed readblock.  Loop for CRC error or incomplete reads.

This will make reading / dumping more stable.
This commit is contained in:
iceman1001 2018-03-15 19:59:33 +01:00
parent a7fd398d33
commit ce418fb720

View file

@ -334,7 +334,7 @@ int mifare_ultra_auth(uint8_t *keybytes){
return 1;
}
int mifare_ultra_readblock(uint8_t blockNo, uint8_t *blockData) {
int mifare_ultra_readblockEx(uint8_t blockNo, uint8_t *blockData) {
uint16_t len = 0;
uint8_t bt[2] = {0x00, 0x00};
uint8_t receivedAnswer[MAX_FRAME_SIZE] = {0x00};
@ -360,6 +360,25 @@ int mifare_ultra_readblock(uint8_t blockNo, uint8_t *blockData) {
memcpy(blockData, receivedAnswer, 14);
return 0;
}
int mifare_ultra_readblock(uint8_t blockNo, uint8_t *blockData) {
#define MFU_MAX_CRC_RETRIES 5
uint8_t retries = 0;
uint8_t res;
for (retries = 0; retries < MFU_MAX_CRC_RETRIES; ++retries) {
res = mifare_ultra_readblockEx(blockNo, blockData);
// break if OK, or NACK.
switch ( res ) {
case 0:
case 1:
break;
default:
continue;
}
}
return res;
}
int mifare_classic_writeblock(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t *blockData) {
// variables