]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdlfhid.c
CHG: `data plot`- the marking of clock, looks better without borders. It only connec...
[proxmark3-svn] / client / cmdlfhid.c
index 3c0faf3e8e74d9344d7a6c86b307a32cbd9c6f07..6ed6c4fd998706825fc4fea0623876775b92cb85 100644 (file)
 
 #include "cmdlfhid.h"
 
 
 #include "cmdlfhid.h"
 
+#ifndef BITS
+# define BITS 96
+#endif
+
 static int CmdHelp(const char *Cmd);
 
 int usage_lf_hid_wiegand(void){
 static int CmdHelp(const char *Cmd);
 
 int usage_lf_hid_wiegand(void){
@@ -97,7 +101,7 @@ static bool sendTry(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint32_t delay, ui
 }
 
 int CmdHIDDemodFSK(const char *Cmd) {
 }
 
 int CmdHIDDemodFSK(const char *Cmd) {
-       int findone = ( Cmd[0] == '1' ) ? 1 : 0;
+       uint8_t findone = ( Cmd[0] == '1' ) ? 1 : 0;
        UsbCommand c = {CMD_HID_DEMOD_FSK, {findone, 0 , 0}};
        clearCommandBuffer();
        SendCommand(&c);
        UsbCommand c = {CMD_HID_DEMOD_FSK, {findone, 0 , 0}};
        clearCommandBuffer();
        SendCommand(&c);
@@ -176,22 +180,30 @@ typedef struct {
  } wiegand_t;
 
 static void addHIDMarker(uint8_t fmtlen, uint8_t *out) {    
  } wiegand_t;
 
 static void addHIDMarker(uint8_t fmtlen, uint8_t *out) {    
+       // temp array
+       uint8_t arr[BITS];
+       memset(arr, 0, BITS);
+
+       // copy inpu
+       uint8_t pos = sizeof(arr)-fmtlen;
+       memcpy(arr+pos, out, fmtlen);
+                       
        switch(fmtlen) {
                case 26:{
        switch(fmtlen) {
                case 26:{
-                       uint8_t len = 37;
-                       uint8_t tmp[len];
-                       memset(tmp, 0, len);
-                       uint8_t idx = 37-fmtlen;
-                       memcpy(tmp+idx, out, fmtlen);
-                       tmp[idx] = 1; // start sentinel?
-                       tmp[0]  = 1; // bit indicates that a format smaller than 37 is used
-                       memcpy(out, tmp, len);
+                       // start sentinel, BITS-bit 27 = 1
+                       arr[BITS-27] = 1;
+                       // fmt smaller than 37 used,  bit37 = 1
+                       arr[BITS-38]  = 1;
+                       memcpy(out, arr, BITS);
                        break;
                }
                case 34:
                        break;
                }
                case 34:
-                               // set bit format for less than 37 bit format
-                               // 5+32= 1
-                               //*hi = (1 << 5) | (fc >> 15);
+                       // start sentinel, BITS-bit 27 = 1
+                       arr[BITS-35] = 1;
+                       
+                       // fmt smaller than 37 used,  bit37 = 1
+                       arr[BITS-38]  = 1;
+                       memcpy(out, arr, BITS);
                        break;
                default:break;
        }
                        break;
                default:break;
        }
@@ -302,7 +314,7 @@ int CmdHIDWiegand(const char *Cmd) {
        uint64_t cardnum = 0;
        uint64_t blocks = 0, wiegand = 0; 
 
        uint64_t cardnum = 0;
        uint64_t blocks = 0, wiegand = 0; 
 
-       uint8_t bits[96];
+       uint8_t bits[BITS];
        uint8_t *bs = bits;
        memset(bs, 0, sizeof(bits));
        
        uint8_t *bs = bits;
        memset(bs, 0, sizeof(bits));
        
@@ -320,16 +332,16 @@ int CmdHIDWiegand(const char *Cmd) {
        for (uint8_t i = 0; i < sizeof(fmtlen); i++){
                memset(bits, 0x00, sizeof(bits));
                calcWiegand( fmtlen[i], fc, cardnum, bs);
        for (uint8_t i = 0; i < sizeof(fmtlen); i++){
                memset(bits, 0x00, sizeof(bits));
                calcWiegand( fmtlen[i], fc, cardnum, bs);
-               printf("ice:: %s", sprint_bin(bs, fmtlen[i]));
+               printf("ice:: %s \n", sprint_bin(bs, fmtlen[i]));
                wiegand = (uint64_t)bytebits_to_byte(bs, 32) << 32 | bytebits_to_byte(bs+32, 32);
                
                addHIDMarker(fmtlen[i], bs);    
                wiegand = (uint64_t)bytebits_to_byte(bs, 32) << 32 | bytebits_to_byte(bs+32, 32);
                
                addHIDMarker(fmtlen[i], bs);    
-               printf("ice:: %s", sprint_bin(bs, 37));
-               blocks = (uint64_t)bytebits_to_byte(bs, 32) << 32 | bytebits_to_byte(bs+32, 32);
+               printf("ice:: %s\n", sprint_bin(bs, BITS));
+               blocks = (uint64_t)bytebits_to_byte(bs+32, 32) << 32 | bytebits_to_byte(bs+64, 32);
                uint8_t shifts = 64-fmtlen[i];          
                wiegand >>= shifts;
                
                uint8_t shifts = 64-fmtlen[i];          
                wiegand >>= shifts;
                
-               PrintAndLog(" %u | %03u | %03u  | %llu  | %llX  |  %llX",
+               PrintAndLog(" %u | %03u | %03u  | %" PRIu64 "  | %" PRIX64 "  |  %" PRIX64 ,
                        fmtlen[i],
                        oem,
                        fc,
                        fmtlen[i],
                        oem,
                        fc,
Impressum, Datenschutz