]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdlfpresco.c
gcc10 compiler fixes:
[proxmark3-svn] / client / cmdlfpresco.c
index abae165d20dc58036a61c0792c0556db6d8cf2d4..865b384b38b0964e48d2796dd459d0f33c64d7f1 100644 (file)
@@ -5,11 +5,15 @@
 // the license.
 //-----------------------------------------------------------------------------
 // Low frequency Presco tag commands
+// ASK/Manchester, rf/32, 128 bits (complete)
 //-----------------------------------------------------------------------------
+
+#include "cmdlfpresco.h"
+
 #include <string.h>
 #include <inttypes.h>
-#include "cmdlfpresco.h"
-#include "proxmark3.h"
+#include <stdio.h>
+#include "comms.h"
 #include "ui.h"
 #include "util.h"
 #include "graph.h"
@@ -66,10 +70,10 @@ int GetWiegandFromPresco(const char *Cmd, uint32_t *sitecode, uint32_t *usercode
                                *fullcode = param_get32ex(Cmd, cmdp+1, 0, 10);
                                cmdp+=2;
                                break;
-                       case 'P':
-                       case 'p':
+                       case 'D':
+                       case 'd':
                                //param get string int param_getstr(const char *line, int paramnum, char * str)
-                               stringlen = param_getstr(Cmd, cmdp+1, id);
+                               stringlen = param_getstr(Cmd, cmdp+1, id, sizeof(id));
                                if (stringlen < 2) return -1;
                                cmdp+=2;
                                break;
@@ -89,7 +93,7 @@ int GetWiegandFromPresco(const char *Cmd, uint32_t *sitecode, uint32_t *usercode
        if(cmdp == 0) errors = 1;
 
        //Validations
-       if(errors) return -1;
+       if(errors || (stringlen == 0 && !hex) ) return -1;
 
        if (!hex) {
                for (int index =0; index < strlen(id); ++index) {
@@ -128,7 +132,7 @@ int CmdPrescoDemod(const char *Cmd) {
                return 0;
        }
        size_t size = DemodBufferLen;
-       //call lfdemod.c demod for Viking
+       //call lfdemod.c demod for presco
        int ans = PrescoDemod(DemodBuffer, &size);
        if (ans < 0) {
                if (g_debugMode) PrintAndLog("Error Presco_Demod %d", ans);
@@ -142,8 +146,9 @@ int CmdPrescoDemod(const char *Cmd) {
        uint32_t cardid = raw4;
        PrintAndLog("Presco Tag Found: Card ID %08X", cardid);
        PrintAndLog("Raw: %08X%08X%08X%08X", raw1,raw2,raw3,raw4);
-       setDemodBuf(DemodBuffer+ans, 128, 0);
-       
+       setDemodBuf(DemodBuffer, 128, ans);
+       setClockGrid(g_DemodClock, g_DemodStartIdx + (ans*g_DemodClock));
+
        uint32_t sitecode = 0, usercode = 0, fullcode = 0;
        bool Q5=false;
        char cmd[12] = {0};
@@ -159,9 +164,7 @@ int CmdPrescoRead(const char *Cmd) {
        // Presco Number: 123456789 --> Sitecode 30 | usercode 8665
 
        // read lf silently
-       CmdLFRead("s");
-       // get samples silently
-       getSamples("30000",false);
+       lf_read(true, 10000);
        // demod and output Presco ID   
        return CmdPrescoDemod(Cmd);
 }
@@ -178,7 +181,7 @@ int CmdPrescoClone(const char *Cmd) {
        if (GetWiegandFromPresco(Cmd, &sitecode, &usercode, &fullcode, &Q5) == -1) return usage_lf_presco_clone();
 
        if (Q5)
-               blocks[0] = T5555_MODULATION_MANCHESTER | 32<<T5555_BITRATE_SHIFT | 4<<T5555_MAXBLOCK_SHIFT | T5555_ST_TERMINATOR;
+               blocks[0] = T5555_MODULATION_MANCHESTER | ((32-2)>>1)<<T5555_BITRATE_SHIFT | 4<<T5555_MAXBLOCK_SHIFT | T5555_ST_TERMINATOR;
 
        if ((sitecode & 0xFF) != sitecode) {
                sitecode &= 0xFF;
Impressum, Datenschutz