]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdlfem4x.c
Fix args number and example for guard
[proxmark3-svn] / client / cmdlfem4x.c
index b8509c750e7b411d3ad45633532e46402cbd7ebd..88d292ff61ec14c3f167e990f5b329fd105054db 100644 (file)
@@ -546,8 +546,10 @@ bool downloadSamplesEM(){
 bool doPreambleSearch(size_t *startIdx){
        
        // sanity check
-       if ( DemodBufferLen < EM_PREAMBLE_LEN) 
+       if ( DemodBufferLen < EM_PREAMBLE_LEN) {
+               if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305 demodbuffer too small");
                return FALSE;
+       }
        
        // skip first two 0 bits as they might have been missed in the demod 
        uint8_t preamble[EM_PREAMBLE_LEN] = {0,0,1,0,1,0};
@@ -591,8 +593,8 @@ bool detectFSK(){
 // PSK clocks should be easy to detect ( but difficult to demod a non-repeating pattern... )
 bool detectPSK(){      
        int     ans = GetPskClock("", FALSE, FALSE);
-       if (!ans) {
-               if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305: PSK clock failed");                
+       if (ans <= 0) {
+               if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305: PSK clock failed");
                return FALSE;
        }
        PrintAndLog("PSK response possibly found, run `data rawd p1` to attempt to demod");
@@ -601,7 +603,7 @@ bool detectPSK(){
 // try manchester - NOTE: ST only applies to T55x7 tags.
 bool detectASK_MAN(){
        bool stcheck = FALSE;
-       int ans = ASKDemod_ext("0 0 0", TRUE, FALSE, 1, &stcheck);
+       int ans = ASKDemod_ext("0 0 0", FALSE, FALSE, 1, &stcheck);
        if (!ans) {
                if (g_debugMode) PrintAndLog("DEBUG: Error - EM4305: ASK/Manchester Demod failed");
                return FALSE;
@@ -636,7 +638,6 @@ int setDemodBufferEM(uint8_t bitsNeeded, size_t idx){
 // should cover 90% of known used configs
 // the rest will need to be manually demoded for now...
 int demodEM4x05resp(uint8_t bitsNeeded) {
-
        size_t startIdx = 0;    
        
        if (detectASK_MAN() && doPreambleSearch( &startIdx ))
@@ -650,7 +651,7 @@ int demodEM4x05resp(uint8_t bitsNeeded) {
        
        if (detectPSK() && doPreambleSearch( &startIdx )) 
                return setDemodBufferEM(bitsNeeded, startIdx);
-       
+
        return -1;
 }
 
@@ -694,7 +695,11 @@ int CmdReadWord(const char *Cmd) {
 
        //attempt demod:
        //need 32 bits from a read word
-       return demodEM4x05resp(44);
+       int result = demodEM4x05resp(44);
+       if (result == -1)
+               PrintAndLog("Read failed");
+       
+       return result;
 }
 
 int CmdWriteWord(const char *Cmd) {
Impressum, Datenschutz