]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
ADD: adding a presco demod, given 0x10D as preamble, .. *work in progress*
authoriceman1001 <iceman@iuse.se>
Sun, 14 Feb 2016 10:58:25 +0000 (11:58 +0100)
committericeman1001 <iceman@iuse.se>
Sun, 14 Feb 2016 10:58:25 +0000 (11:58 +0100)
client/cmdlfpresco.c
common/lfdemod.c
common/lfdemod.h

index 4986071c48de242bf478fe502fcfa3bfe31ac11c..e6ac19e4fabceeddd8122b8d0f4b7165d8672f2b 100644 (file)
@@ -74,19 +74,44 @@ int GetPrescoBits(uint32_t sitecode, uint32_t usercode, uint8_t     *prescoBits) {
        if (bitLen != 88) return 0;
        return 1;
 }
+//see ASKDemod for what args are accepted
+int CmdPrescoDemod(const char *Cmd) {
+       if (!ASKDemod(Cmd, false, false, 1)) {
+               if (g_debugMode) PrintAndLog("ASKDemod failed");
+               return 0;
+       }
+       size_t size = DemodBufferLen;
+       //call lfdemod.c demod for Viking
+       int ans = PrescoDemod(DemodBuffer, &size);
+       if (ans < 0) {
+               if (g_debugMode) PrintAndLog("Error Presco_Demod %d", ans);
+               return 0;
+       }
+       //got a good demod
+       uint32_t raw1 = bytebits_to_byte(DemodBuffer+ans, 32);
+       uint32_t raw2 = bytebits_to_byte(DemodBuffer+ans+32, 32);
+       uint32_t cardid = bytebits_to_byte(DemodBuffer+ans+24, 32);
+       PrintAndLog("Presco Tag Found: Card ID %08X", cardid);
+       PrintAndLog("Raw: %08X%08X", raw1,raw2);
+       setDemodBuf(DemodBuffer+ans, 64, 0);
+       
+       // uint32_t sitecode = 0, usercode = 0;
+       // GetWiegandFromPresco(id, &sitecode, &usercode);
+       // PrintAndLog8("SiteCode %d  |  UserCode %d", sitecode, usercode);
+       
+       return 1;
+}
 
 //see ASKDemod for what args are accepted
 int CmdPrescoRead(const char *Cmd) {
-       PrintAndLog("Number: 123456789 --> Sitecode 30 | usercode 8665");
-//     GetWiegandFromPresco("123456789");
+       //      Presco Number: 123456789 --> Sitecode 30 | usercode 8665
 
        // read lf silently
-       //CmdLFRead("s");
+       CmdLFRead("s");
        // get samples silently
-       //getSamples("30000",false);
-       // demod and output viking ID   
-       //return CmdVikingDemod(Cmd);
-       return 0;
+       getSamples("30000",false);
+       // demod and output Presco ID   
+       return CmdPrescoDemod(Cmd);
 }
 
 int CmdPrescoClone(const char *Cmd) {
index 23b9c8b5d4a8326cead8f765f32e707f149cd906..967a98a88ea4d94733850f088012ee6536fca60f 100644 (file)
@@ -677,6 +677,20 @@ int VikingDemod_AM(uint8_t *dest, size_t *size) {
        return (int) startIdx;
 }
 
+// find presco preamble 0x10D in already demoded data
+int PrescoDemod(uint8_t *dest, size_t *size) {
+       //make sure buffer has data
+       if (*size < 64*2) return -2;
+
+       size_t startIdx = 0;
+       uint8_t preamble[] = {1,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0};
+       uint8_t errChk = preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx);
+       if (errChk == 0) return -4; //preamble not found
+       //return start position
+       return (int) startIdx;
+}
+
+
 // Ask/Biphase Demod then try to locate an ISO 11784/85 ID
 // BitStream must contain previously askrawdemod and biphasedemoded data
 int FDXBdemodBI(uint8_t *dest, size_t *size)
index a1d99e113f210cf592015c6140ed0f54b5e5ab44..f4ed9107d5a987c9f57acaa13d2ff78c682980a6 100644 (file)
@@ -53,5 +53,6 @@ int indala26decode(uint8_t *bitStream, size_t *size, uint8_t *invert);
 int ParadoxdemodFSK(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint32_t *lo);
 int PyramiddemodFSK(uint8_t *dest, size_t *size);
 int VikingDemod_AM(uint8_t *dest, size_t *size);
+int PrescoDemod(uint8_t *dest, size_t *size);
 
 #endif
Impressum, Datenschutz