]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
FIX: thanks @tony, for pointing out a "end" statement inside tnp3sim.lua
authoriceman1001 <iceman@iuse.se>
Fri, 16 Oct 2015 21:16:46 +0000 (23:16 +0200)
committericeman1001 <iceman@iuse.se>
Fri, 16 Oct 2015 21:16:46 +0000 (23:16 +0200)
ADD: @marshmello42 fixs for t55x7

armsrc/BigBuf.c
armsrc/BigBuf.h
armsrc/lfops.c
armsrc/lfsampling.c
armsrc/lfsampling.h
client/cmdlf.c
client/cmdlfpcf7931.c
client/cmdlft55xx.c
client/scripts/tnp3sim.lua

index 3499d7c76b7221854e274a14e637f4c31c347f51..64ad91ff6cc64e359f8c0cd827792f4f6c766e25 100644 (file)
@@ -50,8 +50,14 @@ uint8_t *BigBuf_get_EM_addr(void)
 
 // clear ALL of BigBuf
 void BigBuf_Clear(void)
+{
+       BigBuf_Clear_ext(true);
+}
+// clear ALL of BigBuf
+void BigBuf_Clear_ext(bool verbose)
 {
        memset(BigBuf,0,BIGBUF_SIZE);
+       if (verbose) 
        Dbprintf("Buffer cleared (%i bytes)",BIGBUF_SIZE);
 }
 
index b859ffda9f1c4ab78f591fc8deaee4741f83046e..3f1b05c2f65929fa89802496dc87e0a5841c9759 100644 (file)
@@ -25,6 +25,7 @@ extern uint8_t *BigBuf_get_addr(void);
 extern uint8_t *BigBuf_get_EM_addr(void);
 extern uint16_t BigBuf_max_traceLen(void);
 extern void BigBuf_Clear(void);
+extern void BigBuf_Clear_ext(bool verbose);
 extern uint8_t *BigBuf_malloc(uint16_t);
 extern void BigBuf_free(void);
 extern void BigBuf_free_keep_EM(void);
index 31fe4ca970db134dcb8f884dfeb77f9d47a68370..4a0dca162779a388dd83deccc45d77bbb1e4af71 100644 (file)
@@ -242,11 +242,13 @@ void AcquireTiType(void)
        int i, j, n;
        // tag transmission is <20ms, sampling at 2M gives us 40K samples max
        // each sample is 1 bit stuffed into a uint32_t so we need 1250 uint32_t
- #define TIBUFLEN 1250
      #define TIBUFLEN 1250
 
        // clear buffer
-       uint32_t *BigBuf = (uint32_t *)BigBuf_get_addr();
-       memset(BigBuf,0,BigBuf_max_traceLen()/sizeof(uint32_t));
+       uint32_t *buf = (uint32_t *)BigBuf_get_addr();
+
+       //clear buffer now so it does not interfere with timing later
+       BigBuf_Clear_ext(false);
 
        // Set up the synchronous serial port
        AT91C_BASE_PIOA->PIO_PDR = GPIO_SSC_DIN;
@@ -284,7 +286,7 @@ void AcquireTiType(void)
        i = 0;
        for(;;) {
                if(AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
-                       BigBuf[i] = AT91C_BASE_SSC->SSC_RHR;    // store 32 bit values in buffer
+                       buf[i] = AT91C_BASE_SSC->SSC_RHR;       // store 32 bit values in buffer
                        i++; if(i >= TIBUFLEN) break;
                }
                WDT_HIT();
@@ -295,11 +297,12 @@ void AcquireTiType(void)
        AT91C_BASE_PIOA->PIO_ASR = GPIO_SSC_DIN | GPIO_SSC_DOUT;
 
        char *dest = (char *)BigBuf_get_addr();
-       n = TIBUFLEN*32;
+       n = TIBUFLEN * 32;
+       
        // unpack buffer
-       for (i=TIBUFLEN-1; i>=0; i--) {
-               for (j=0; j<32; j++) {
-                       if(BigBuf[i] & (1 << j)) {
+       for (i = TIBUFLEN-1; i >= 0; i--) {
+               for (j = 0; j < 32; j++) {
+                       if(buf[i] & (1 << j)) {
                                dest[--n] = 1;
                        } else {
                                dest[--n] = -1;
@@ -324,8 +327,7 @@ void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc)
                crc = update_crc16(crc, (idhi>>16)&0xff);
                crc = update_crc16(crc, (idhi>>24)&0xff);
        }
-       Dbprintf("Writing to tag: %x%08x, crc=%x",
-                       (unsigned int) idhi, (unsigned int) idlo, crc);
+       Dbprintf("Writing to tag: %x%08x, crc=%x",      (unsigned int) idhi, (unsigned int) idlo, crc);
 
        // TI tags charge at 134.2Khz
        FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz
@@ -389,12 +391,11 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol)
        FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT);
 
        AT91C_BASE_PIOA->PIO_PER = GPIO_SSC_DOUT | GPIO_SSC_CLK;
-
        AT91C_BASE_PIOA->PIO_OER = GPIO_SSC_DOUT;
        AT91C_BASE_PIOA->PIO_ODR = GPIO_SSC_CLK;
 
  #define SHORT_COIL()  LOW(GPIO_SSC_DOUT)
- #define OPEN_COIL()           HIGH(GPIO_SSC_DOUT)
+ #define OPEN_COIL()   HIGH(GPIO_SSC_DOUT)
 
        i = 0;
        for(;;) {
@@ -406,16 +407,15 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol)
                        }
                        WDT_HIT();
                }
-               if (ledcontrol)
-                       LED_D_ON();
+               if (ledcontrol) LED_D_ON();
 
                if(tab[i])
                        OPEN_COIL();
                else
                        SHORT_COIL();
 
-               if (ledcontrol)
-                       LED_D_OFF();
+               if (ledcontrol) LED_D_OFF();
+               
                //wait until SSC_CLK goes LOW
                while(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK) {
                        if(BUTTON_PRESS()) {
@@ -569,12 +569,9 @@ void CmdHIDsimTAG(int hi, int lo, int ledcontrol)
                }
        }
 
-       if (ledcontrol)
-               LED_A_ON();
+       if (ledcontrol) LED_A_ON();
        SimulateTagLowFrequency(n, 0, ledcontrol);
-
-       if (ledcontrol)
-               LED_A_OFF();
+       if (ledcontrol) LED_A_OFF();
 }
 
 // prepare a waveform pattern in the buffer based on the ID given then
@@ -677,21 +674,10 @@ void CmdASKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
        if (separator==1) Dbprintf("sorry but separator option not yet available"); 
 
        Dbprintf("Simulating with clk: %d, invert: %d, encoding: %d, separator: %d, n: %d",clk, invert, encoding, separator, n);
-       //DEBUG
-       //Dbprintf("First 32:");
-       //uint8_t *dest = BigBuf_get_addr();
-       //i=0;
-       //Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
-       //i+=16;
-       //Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
 
-       if (ledcontrol)
-               LED_A_ON();
-       
+       if (ledcontrol) LED_A_ON();
        SimulateTagLowFrequency(n, 0, ledcontrol);
-
-       if (ledcontrol)
-               LED_A_OFF();
+       if (ledcontrol) LED_A_OFF();
 }
 
 //carrier can be 2,4 or 8
@@ -720,7 +706,7 @@ static void pskSimBit(uint8_t waveLen, int *n, uint8_t clk, uint8_t *curPhase, b
 // args clock, carrier, invert,
 void CmdPSKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
 {
-       int ledcontrol=1;
+       int ledcontrol = 1;
        int n=0, i=0;
        uint8_t clk = arg1 >> 8;
        uint8_t carrier = arg1 & 0xFF;
@@ -734,26 +720,16 @@ void CmdPSKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
                }
        }
        Dbprintf("Simulating with Carrier: %d, clk: %d, invert: %d, n: %d",carrier, clk, invert, n);
-       //Dbprintf("DEBUG: First 32:");
-       //uint8_t *dest = BigBuf_get_addr();
-       //i=0;
-       //Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
-       //i+=16;
-       //Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
                   
-       if (ledcontrol)
-               LED_A_ON();
+       if (ledcontrol) LED_A_ON();
        SimulateTagLowFrequency(n, 0, ledcontrol);
-
-       if (ledcontrol)
-               LED_A_OFF();
+       if (ledcontrol) LED_A_OFF();
 }
 
 // loop to get raw HID waveform then FSK demodulate the TAG ID from it
 void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
 {
        uint8_t *dest = BigBuf_get_addr();
-       //const size_t sizeOfBigBuff = BigBuf_max_traceLen();
        size_t size = 0; 
        uint32_t hi2=0, hi=0, lo=0;
        int idx=0;
@@ -767,7 +743,6 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
 
                DoAcquisition_default(-1,true);
                // FSK demodulator
-               //size = sizeOfBigBuff;  //variable size will change after demod so re initialize it before use
                size = 50*128*2; //big enough to catch 2 sequences of largest format
                idx = HIDdemodFSK(dest, &size, &hi2, &hi, &lo);
                
@@ -775,12 +750,16 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
                        // go over previously decoded manchester data and decode into usable tag ID
                        if (hi2 != 0){ //extra large HID tags  88/192 bits
                                Dbprintf("TAG ID: %x%08x%08x (%d)",
-                                 (unsigned int) hi2, (unsigned int) hi, (unsigned int) lo, (unsigned int) (lo>>1) & 0xFFFF);
+                                 (unsigned int) hi2,
+                                 (unsigned int) hi,
+                                 (unsigned int) lo,
+                                 (unsigned int) (lo>>1) & 0xFFFF
+                                 );
                        }else {  //standard HID tags 44/96 bits
-                               //Dbprintf("TAG ID: %x%08x (%d)",(unsigned int) hi, (unsigned int) lo, (unsigned int) (lo>>1) & 0xFFFF); //old print cmd
                                uint8_t bitlen = 0;
                                uint32_t fc = 0;
                                uint32_t cardnum = 0;
+                               
                                if (((hi>>5)&1) == 1){//if bit 38 is set then < 37 bit format is used
                                        uint32_t lo2=0;
                                        lo2=(((hi & 31) << 12) | (lo>>20)); //get bits 21-37 to check for format len bit
@@ -818,11 +797,13 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
                                                fc = ((hi&0xF)<<12)|(lo>>20);
                                        }
                                }
-                               //Dbprintf("TAG ID: %x%08x (%d)",
-                               // (unsigned int) hi, (unsigned int) lo, (unsigned int) (lo>>1) & 0xFFFF);
                                Dbprintf("TAG ID: %x%08x (%d) - Format Len: %dbit - FC: %d - Card: %d",
-                                                (unsigned int) hi, (unsigned int) lo, (unsigned int) (lo>>1) & 0xFFFF,
-                                                (unsigned int) bitlen, (unsigned int) fc, (unsigned int) cardnum);
+                                                (unsigned int) hi,
+                                                (unsigned int) lo,
+                                                (unsigned int) (lo>>1) & 0xFFFF,
+                                                (unsigned int) bitlen,
+                                                (unsigned int) fc,
+                                                (unsigned int) cardnum);
                        }
                        if (findone){
                                if (ledcontrol) LED_A_OFF();
@@ -843,7 +824,6 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
 void CmdAWIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
 {
        uint8_t *dest = BigBuf_get_addr();
-       //const size_t sizeOfBigBuff = BigBuf_max_traceLen();
        size_t size; 
        int idx=0;
        // Configure to go in 125Khz listen mode
@@ -856,7 +836,6 @@ void CmdAWIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
 
                DoAcquisition_default(-1,true);
                // FSK demodulator
-               //size = sizeOfBigBuff;  //variable size will change after demod so re initialize it before use
                size = 50*128*2; //big enough to catch 2 sequences of largest format
                idx = AWIDdemodFSK(dest, &size);
                
@@ -1041,7 +1020,7 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
                        code = bytebits_to_byte(dest+idx,32);
                        code2 = bytebits_to_byte(dest+idx+32,32);
                        version = bytebits_to_byte(dest+idx+27,8); //14,4
-               facilitycode = bytebits_to_byte(dest+idx+18,8);
+                       facilitycode = bytebits_to_byte(dest+idx+18,8);
                        number = (bytebits_to_byte(dest+idx+36,8)<<8)|(bytebits_to_byte(dest+idx+45,8)); //36,9
 
                        crc = bytebits_to_byte(dest+idx+54,8);
@@ -1056,7 +1035,6 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
                        // if we're only looking for one tag
                        if (findone){
                                if (ledcontrol) LED_A_OFF();
-                               //LED_A_OFF();
                                *high=code;
                                *low=code2;
                                return;
@@ -1139,6 +1117,7 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
 #define WRITE_GAP 20*8 // was 160 // SPEC:  1*8 to 20*8 - typ 10*8 (or 10fc)
 #define WRITE_0   16*8 // was 144 // SPEC: 16*8 to 32*8 - typ 24*8 (or 24fc)
 #define WRITE_1   50*8 // was 400 // SPEC: 48*8 to 64*8 - typ 56*8 (or 56fc)  432 for T55x7; 448 for E5550
+#define READ_GAP  52*8 
 
 //  VALUES TAKEN FROM EM4x function: SendForward
 //  START_GAP = 440;       (55*8) cycles at 125Khz (8us = 1cycle)
@@ -1154,6 +1133,12 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
 // T0 = TIMER_CLOCK1 / 125000 = 192
 // 1 Cycle = 8 microseconds(us)  == 1 field clock
 
+void TurnReadLFOn(int delay) {
+       FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
+       // Give it a bit of time for the resonant antenna to settle.
+       SpinDelayUs(delay); //155*8 //50*8
+}
+
 // Write one bit to card
 void T55xxWriteBit(int bit) {
        FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
@@ -1183,18 +1168,18 @@ void T55xxWriteBlock(uint32_t Data, uint32_t Block, uint32_t Pwd, uint8_t PwdMod
        T55xxWriteBit(0); //Page 0
        
        if (PwdMode == 1){
-               // Send pwd
+               // Send Pwd
                for (i = 0x80000000; i != 0; i >>= 1)
                        T55xxWriteBit(Pwd & i);
        }
-       // Send lock bit
+       // Send Lock bit
        T55xxWriteBit(0);
 
-       // Send data
+       // Send Data
        for (i = 0x80000000; i != 0; i >>= 1)
                T55xxWriteBit(Data & i);
 
-       // Send block number
+       // Send Block number
        for (i = 0x04; i != 0; i >>= 1)
                T55xxWriteBit(Block & i);
 
@@ -1202,24 +1187,21 @@ void T55xxWriteBlock(uint32_t Data, uint32_t Block, uint32_t Pwd, uint8_t PwdMod
        // so wait a little more)
        TurnReadLFOn(20 * 1000);
        
-       // field off
+       // turn field off
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
        cmd_send(CMD_ACK,0,0,0,0,0);
        LED_A_OFF();    
 }
 
-void TurnReadLFOn(int delay) {
-       FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
-       // Give it a bit of time for the resonant antenna to settle.
-       SpinDelayUs(delay);
-}
-
 // Read one card block in page 0
 void T55xxReadBlock(uint32_t Block, uint32_t Pwd, uint8_t PwdMode) {
        LED_A_ON();
        
        uint32_t i = 0;
        
+       //clear buffer now so it does not interfere with timing later
+       BigBuf_Clear_ext(false);
+
        //make sure block is at max 7
        Block &= 0x7;
 
@@ -1227,6 +1209,7 @@ void T55xxReadBlock(uint32_t Block, uint32_t Pwd, uint8_t PwdMode) {
        LFSetupFPGAForADC(95, true);
        
        // Trigger T55x7 in mode.
+  // Trigger T55x7 Direct Access Mode
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
        SpinDelayUs(START_GAP);
        
@@ -1235,24 +1218,24 @@ void T55xxReadBlock(uint32_t Block, uint32_t Pwd, uint8_t PwdMode) {
        T55xxWriteBit(0); //Page 0
 
        if (PwdMode == 1){
-               // Send pwd
+               // Send Pwd
                for (i = 0x80000000; i != 0; i >>= 1)
                        T55xxWriteBit(Pwd & i);
        }
-       // Send a zero bit seperation
+       // Send a zero bit separation
        T55xxWriteBit(0);
        
-       // Send block number
+       // Send Block number
        for (i = 0x04; i != 0; i >>= 1)
                T55xxWriteBit(Block & i);
 
        // Turn field on to read the response
-       TurnReadLFOn(START_GAP);
+       TurnReadLFOn(READ_GAP);
        
        // Acquisition
        doT55x7Acquisition();
        
-       // field off
+       // turn field off
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
        cmd_send(CMD_ACK,0,0,0,0,0);    
        LED_A_OFF();
@@ -1262,10 +1245,13 @@ void T55xxReadBlock(uint32_t Block, uint32_t Pwd, uint8_t PwdMode) {
 void T55xxReadTrace(void){
        LED_A_ON();
 
+       //clear buffer now so it does not interfere with timing later
+       BigBuf_Clear_ext(false);
+
        // Set up FPGA, 125kHz
        LFSetupFPGAForADC(95, true);
        
-       // Trigger T55x7 in mode.
+  // Trigger T55x7 Direct Access Mode
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
        SpinDelayUs(START_GAP);
 
@@ -1274,12 +1260,12 @@ void T55xxReadTrace(void){
        T55xxWriteBit(1); //Page 1
 
        // Turn field on to read the response
-       TurnReadLFOn(START_GAP);
+       TurnReadLFOn(READ_GAP);
 
        // Acquisition
        doT55x7Acquisition();
 
-       // field off
+       // turn field off
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
        cmd_send(CMD_ACK,0,0,0,0,0);
        LED_A_OFF();
@@ -1501,8 +1487,11 @@ void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo)
                // Clock rate is stored in bits 8-15 of the card value
                clock = (card & 0xFF00) >> 8;
                Dbprintf("Clock rate: %d", clock);
-               switch (clock)
-               {
+               switch (clock) {
+               case 50:
+                       clock = T55x7_BITRATE_RF_50;
+               case 40:
+                       clock = T55x7_BITRATE_RF_40;
                case 32:
                        clock = T55x7_BITRATE_RF_32;
                        break;
@@ -1721,15 +1710,14 @@ void EM4xLogin(uint32_t Password) {
 
 void EM4xReadWord(uint8_t Address, uint32_t Pwd, uint8_t PwdMode) {
 
+       uint8_t fwd_bit_count;
        uint8_t *dest = BigBuf_get_addr();
-       uint16_t bufferlength = BigBuf_max_traceLen();
+       uint16_t bufsize = BigBuf_max_traceLen();
        uint32_t i = 0;
 
-       // Clear destination buffer before sending the command  0x80 = average.
-       memset(dest, 0x80, bufferlength);
+       //clear buffer now so it does not interfere with timing later
+       BigBuf_Clear_ext(false);
        
-    uint8_t fwd_bit_count;
-
        //If password mode do login
        if (PwdMode == 1) EM4xLogin(Pwd);
 
@@ -1753,7 +1741,7 @@ void EM4xReadWord(uint8_t Address, uint32_t Pwd, uint8_t PwdMode) {
                if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
                        dest[i] = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
                        ++i;
-                       if (i >= bufferlength) break;
+                       if (i >= bufsize) break;
                }
        }
 
@@ -1786,11 +1774,10 @@ void CopyViKingtoT55x7(uint32_t block1, uint32_t block2) {
     LED_D_ON();
     T55xxWriteBlock(block1,1,0,0);
     T55xxWriteBlock(block2,2,0,0);
-    T55xxWriteBlock(T55x7_MODULATION_MANCHESTER | T55x7_BITRATE_RF_32 | 2 << T5555_MAXBLOCK_SHIFT,0,0,1);
+       T55xxWriteBlock(T55x7_MODULATION_MANCHESTER | T55x7_BITRATE_RF_32 | 2 << T55x7_MAXBLOCK_SHIFT,0,0,0);
+    // T55xxWriteBlock(T55x7_MODULATION_MANCHESTER | T55x7_BITRATE_RF_32 | 2 << T5555_MAXBLOCK_SHIFT,0,0,1);
        // ICEMAN NOTES:
        // Shouldn't this one be: T55x7_MAXBLOCK_SHIFT  and 0 in password mode
-       // like this:
-       // T55xxWriteBlock(T55x7_MODULATION_MANCHESTER | T55x7_BITRATE_RF_32 | 2 << T55x7_MAXBLOCK_SHIFT,0,0,0);
     LED_D_OFF();
 }
 
index 339434215512a7e9536dc9d19a371b14857a7dde..8b4ab7781f33d801feff362f20f78b609b397d8b 100644 (file)
@@ -266,7 +266,7 @@ void doT55x7Acquisition(void){
        if ( bufsize > T55xx_SAMPLES_SIZE )
                bufsize = T55xx_SAMPLES_SIZE;
 
-       memset(dest, 0, bufsize);
+       //memset(dest, 0, bufsize);
                
        uint16_t i = 0;
        bool startFound = false;
index 460e6d8b59aecaf52ce95ede96265334f24c3cd2..a88def55548cde4ab636a52140b3030a0ea0f14a 100644 (file)
@@ -47,7 +47,6 @@ uint32_t DoAcquisition_config( bool silent);
 **/
 void LFSetupFPGAForADC(int divisor, bool lf_field);
 
-
 /**
  * Called from the USB-handler to set the sampling configuration
  * The sampling config is used for std reading and snooping.
index c67f34a8491a905397d23c6d70b17853d0b010fa..36c076280f7600d7854c591e2f9b206d1b486a71 100644 (file)
@@ -36,26 +36,25 @@ static int CmdHelp(const char *Cmd);
 
 int usage_lf_cmdread()
 {
-       PrintAndLog("Usage: lf cmdread  <delay off>  <zero> <one> <cmdbytes> [H] ");
+       PrintAndLog("Usage: lf cmdread  <delay off> <zero> <one> <cmdbytes> [H|L]");
        PrintAndLog("Options:        ");
        PrintAndLog("       h             This help");
-       PrintAndLog("       L             Low frequency (125 KHz)");
-       PrintAndLog("       H             High frequency (134 KHz)");
-       PrintAndLog("       H             delay OFF");
-       PrintAndLog("       H             time period ZERO");
-       PrintAndLog("       H             time period ONE");
+       PrintAndLog("      <delay off>    delay offset");
+       PrintAndLog("      <zero>         time period ZERO");
+       PrintAndLog("      <one>          time period ONE");
+       PrintAndLog("      [H|L]          Frequency Low (125 KHz) / High (134 KHz)");
        PrintAndLog("Examples:");
        PrintAndLog("      lf cmdread 80 100 200 11000");
        PrintAndLog("      lf cmdread 80 100 100 11000 H");
        return 0;
 }
 
-/* send a command before reading */
+/* send a LF command before reading */
 int CmdLFCommandRead(const char *Cmd)
 {
        static char dummy[3] = {0x20,0x00,0x00};
        bool errors = FALSE;
-       uint8_t divisor = 0; //125khz
+       uint8_t divisor = 95; //125khz
        uint8_t cmdp =0;
        while(param_getchar(Cmd, cmdp) != 0x00)
        {
index c0a45cfc15d0bc26757d91d0f9f7cb1a53ac6d2b..23efd2e7336b03543c605001fb24a1060c78e010 100644 (file)
@@ -66,7 +66,7 @@ int usage_pcf7931_write(){
        PrintAndLog("Options:");
        PrintAndLog("       h                      This help");
        PrintAndLog("       blockaddress   Block to save [0-7]");
-       PrintAndLog("       byteaddress    Index of byte inside block to write [0-16]");
+       PrintAndLog("       byteaddress    Index of byte inside block to write [0-15]");
        PrintAndLog("       data           one byte of data (hex)");
        PrintAndLog("Examples:");
        PrintAndLog("      lf pcf7931 write 2 1 FF");
@@ -136,7 +136,7 @@ int CmdLFPCF7931Write(const char *Cmd){
        if ( param_getdec(Cmd, 0, &block) ) return usage_pcf7931_write();
        if ( param_getdec(Cmd, 1, &bytepos) ) return usage_pcf7931_write();
        
-       if ( (block > 7) || (bytepos > 16) ) return usage_pcf7931_write();
+       if ( (block > 7) || (bytepos > 15) ) return usage_pcf7931_write();
 
        data    = param_get8ex(Cmd, 2, 0, 16);
        
@@ -159,8 +159,8 @@ int CmdLFPCF7931Write(const char *Cmd){
 static command_t CommandTable[] = 
 {
        {"help",        CmdHelp,                        1, "This help"},
-       {"read",        CmdLFPCF7931Read,       1, "Read content of a PCF7931 transponder"},
-       {"write",       CmdLFPCF7931Write,      1, "Write data on a PCF7931 transponder."},
+       {"read",   CmdLFPCF7931Read,   0, "Read content of a PCF7931 transponder"},
+       {"write",  CmdLFPCF7931Write,  0, "Write data on a PCF7931 transponder."},
        {"config",      CmdLFPCF7931Config, 1, "Configure the password, the tags initialization delay and time offsets (optional)"},
        {NULL, NULL, 0, NULL}
 };
index e652c788589a43173dfd7b16c5bec5e78e5aa21a..3b56881b7247cf459b47fab12492956bb99ba58d 100644 (file)
@@ -262,8 +262,8 @@ int CmdT55xxReadBlock(const char *Cmd) {
        uint8_t got[12000];\r
        GetFromBigBuf(got,sizeof(got),0);\r
        WaitForResponse(CMD_ACK,NULL);\r
-       setGraphBuf(got, 12000);\r
-       DemodBufferLen=0;\r
+       setGraphBuf(got, sizeof(got));\r
+       //DemodBufferLen=0;\r
        if (!DecodeT55xxBlock()) return 3;\r
        char blk[10]={0};\r
        sprintf(blk,"%d", block);\r
@@ -680,8 +680,8 @@ int CmdT55xxWriteBlock(const char *Cmd)
                return 1;\r
        }\r
        \r
-       UsbCommand resp;\r
        UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}};\r
+       UsbCommand resp;\r
        c.d.asBytes[0] = 0x0; \r
 \r
        PrintAndLog("Writing to block: %d  data  : 0x%08X", block, data);\r
index fa9d1c22d998db91d36065d07849001cad899ab5..4325ea3fbfbed09e13525d3ed3ac2f0a97de7892 100644 (file)
@@ -197,7 +197,6 @@ local function ValidateCheckSums(blocks)
        calc = CalcCheckSum(blocks,2,3)
        if crc == calc then isOk='Ok' else isOk = 'Error' end   
        io.write( ('TYPE 3 area 2: %04x = %04x -- %s\n'):format(crc,calc,isOk))
-end
 
        local cmd
        local blockdata
Impressum, Datenschutz