X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/0d974852ce6c2b5ab634db92dfc07c8387e753c0..7fe9b0b742d7dae9c5af1d292d11840b5c3cbfae:/armsrc/lfops.c diff --git a/armsrc/lfops.c b/armsrc/lfops.c index eeaa5782..a7e1f1df 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -7,9 +7,7 @@ #include #include "apps.h" #include "hitag2.h" -#include "../common/crc16.c" - -int sprintf(char *dest, const char *fmt, ...); +#include "crc16.h" void AcquireRawAdcSamples125k(BOOL at134khz) { @@ -39,7 +37,6 @@ void DoAcquisition125k(void) BYTE *dest = (BYTE *)BigBuf; int n = sizeof(BigBuf); int i; - char output_string[64]; memset(dest, 0, n); i = 0; @@ -55,9 +52,8 @@ void DoAcquisition125k(void) if (i >= n) break; } } - sprintf(output_string, "read samples, dest[0]=%x dest[1]=%x", - dest[0], dest[1]); - DbpString(output_string); + Dbprintf("buffer samples: %02x %02x %02x %02x %02x %02x %02x %02x ...", + dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]); } void ModThenAcquireRawAdcSamples125k(int delay_off, int period_0, int period_1, BYTE *command) @@ -251,13 +247,10 @@ void ReadTItag(void) crc = update_crc16(crc, (shift1>>16)&0xff); crc = update_crc16(crc, (shift1>>24)&0xff); - char output_string[64]; - sprintf(output_string, "Info: Tag data_hi=%x, data_lo=%x, crc=%x", + Dbprintf("Info: Tag data: %x%08x, crc=%x", (unsigned int)shift1, (unsigned int)shift0, (unsigned int)shift2 & 0xFFFF); - DbpString(output_string); if (crc != (shift2&0xffff)) { - sprintf(output_string, "Error: CRC mismatch, expected %x", (unsigned int)crc); - DbpString(output_string); + Dbprintf("Error: CRC mismatch, expected %x", (unsigned int)crc); } else { DbpString("Info: CRC is good"); } @@ -349,7 +342,6 @@ void AcquireTiType(void) n = TIBUFLEN*32; // unpack buffer for (i=TIBUFLEN-1; i>=0; i--) { -// DbpIntegers(0, 0, BigBuf[i]); for (j=0; j<32; j++) { if(BigBuf[i] & (1 << j)) { dest[--n] = 1; @@ -365,11 +357,6 @@ void AcquireTiType(void) // if not provided a valid crc will be computed from the data and written. void WriteTItag(DWORD idhi, DWORD idlo, WORD crc) { - - // WARNING the order of the bytes in which we calc crc below needs checking - // i'm 99% sure the crc algorithm is correct, but it may need to eat the - // bytes in reverse or something - if(crc == 0) { crc = update_crc16(crc, (idlo)&0xff); crc = update_crc16(crc, (idlo>>8)&0xff); @@ -380,10 +367,8 @@ void WriteTItag(DWORD idhi, DWORD idlo, WORD crc) crc = update_crc16(crc, (idhi>>16)&0xff); crc = update_crc16(crc, (idhi>>24)&0xff); } - char output_string[64]; - sprintf(output_string, "Writing the following data to tag: %x, %x, %x", + Dbprintf("Writing to tag: %x%08x, crc=%x", (unsigned int) idhi, (unsigned int) idlo, crc); - DbpString(output_string); // TI tags charge at 134.2Khz FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz @@ -438,7 +423,7 @@ void WriteTItag(DWORD idhi, DWORD idlo, WORD crc) DbpString("Now use tiread to check"); } -void SimulateTagLowFrequency(int period, int ledcontrol) +void SimulateTagLowFrequency(int period, int gap, int ledcontrol) { int i; BYTE *tab = (BYTE *)BigBuf; @@ -483,7 +468,13 @@ void SimulateTagLowFrequency(int period, int ledcontrol) } i++; - if(i == period) i = 0; + if(i == period) { + i = 0; + if (gap) { + SHORT_COIL(); + SpinDelayUs(gap); + } + } } } @@ -777,7 +768,7 @@ void CmdHIDsimTAG(int hi, int lo, int ledcontrol) if (ledcontrol) LED_A_ON(); - SimulateTagLowFrequency(n, ledcontrol); + SimulateTagLowFrequency(n, 0, ledcontrol); if (ledcontrol) LED_A_OFF(); @@ -927,10 +918,8 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol) found=1; idx+=6; if (found && (hi|lo)) { - char output_string[64]; - sprintf(output_string, "TAG ID: %x %x %x", + Dbprintf("TAG ID: %x%08x (%d)", (unsigned int) hi, (unsigned int) lo, (unsigned int) (lo>>1) & 0xFFFF); - DbpString(output_string); /* if we're only looking for one tag */ if (findone) { @@ -962,10 +951,8 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol) found=1; idx+=6; if (found && (hi|lo)) { - char output_string[64]; - sprintf(output_string, "TAG ID: %x %x %x", + Dbprintf("TAG ID: %x%08x (%d)", (unsigned int) hi, (unsigned int) lo, (unsigned int) (lo>>1) & 0xFFFF); - DbpString(output_string); /* if we're only looking for one tag */ if (findone) {