]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/iso14443a.c
hf mf sniff: small fixes
[proxmark3-svn] / armsrc / iso14443a.c
index a0fe232671e86418eda924b0c52857e58a03bb7e..7d589f0e64f6354227db678b703d379ba71b4909 100644 (file)
@@ -189,13 +189,14 @@ void iso14a_set_trigger(bool enable) {
 
 
 void iso14a_set_timeout(uint32_t timeout) {
-       iso14a_timeout = timeout - (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8);
+       // adjust timeout by FPGA delays and 2 additional ssp_frames to detect SOF
+       iso14a_timeout = timeout + (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8) + 2;
        if(MF_DBGLEVEL >= 3) Dbprintf("ISO14443A Timeout set to %ld (%dms)", timeout, timeout / 106);
 }
 
 
 uint32_t iso14a_get_timeout(void) {
-       return iso14a_timeout + (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8);
+       return iso14a_timeout - (DELAY_AIR2ARM_AS_READER + DELAY_ARM2AIR_AS_READER)/(16*8) - 2;
 }
 
 //-----------------------------------------------------------------------------
@@ -1955,9 +1956,9 @@ int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, void *data) {
        } else{
                // S-Block WTX 
                while((data_bytes[0] & 0xF2) == 0xF2) {
-                       uint32_t save_iso14a_timeout = iso14a_timeout;
+                       uint32_t save_iso14a_timeout = iso14a_get_timeout();
                        // temporarily increase timeout
-                       iso14a_timeout = MAX((data_bytes[1] & 0x3f) * iso14a_timeout, MAX_ISO14A_TIMEOUT);
+                       iso14a_set_timeout(MAX((data_bytes[1] & 0x3f) * save_iso14a_timeout, MAX_ISO14A_TIMEOUT));
                        // Transmit WTX back 
                        // byte1 - WTXM [1..59]. command FWT=FWT*WTXM
                        data_bytes[1] = data_bytes[1] & 0x3f; // 2 high bits mandatory set to 0b
@@ -1969,7 +1970,7 @@ int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, void *data) {
                        len = ReaderReceive(data, parity);
                        data_bytes = data;
                        // restore timeout
-                       iso14a_timeout = save_iso14a_timeout;
+                       iso14a_set_timeout(save_iso14a_timeout);
                }
 
                // if we received an I- or R(ACK)-Block with a block number equal to the
@@ -2481,7 +2482,7 @@ void RAMFUNC SniffMifare(uint8_t param) {
        for(uint32_t sniffCounter = 0; true; ) {
        
                if(BUTTON_PRESS()) {
-                       DbpString("cancelled by button");
+                       DbpString("Canceled by button.");
                        break;
                }
 
@@ -2575,7 +2576,7 @@ void RAMFUNC SniffMifare(uint8_t param) {
 
        } // main cycle
 
-       DbpString("COMMAND FINISHED");
+       DbpString("COMMAND FINISHED.");
 
        FpgaDisableSscDma();
        MfSniffEnd();
Impressum, Datenschutz