X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/da1f16d6ef6f9433b9a5a3475541ebbf45c1ba72..371535d566ef790b75c6a8e1d412c97345eb3067:/common/lfdemod.c diff --git a/common/lfdemod.c b/common/lfdemod.c index 8bbe5beb..11340ef0 100644 --- a/common/lfdemod.c +++ b/common/lfdemod.c @@ -25,15 +25,13 @@ void dummy(char *fmt, ...){} #define prnt dummy #endif -uint8_t justNoise(uint8_t *BitStream, size_t size) -{ - static const uint8_t THRESHOLD = 123; - //test samples are not just noise - uint8_t justNoise1 = 1; - for(size_t idx=0; idx < size && justNoise1 ;idx++){ - justNoise1 = BitStream[idx] < THRESHOLD; - } - return justNoise1; +//test samples are not just noise +uint8_t justNoise(uint8_t *bits, size_t size) { + #define THRESHOLD 123 + uint8_t val = 1; + for(size_t idx=0; idx < size && val ;idx++) + val = bits[idx] < THRESHOLD; + return val; } //by marshmellow @@ -698,6 +696,19 @@ int VikingDemod_AM(uint8_t *dest, size_t *size) { return (int) startIdx; } +// by iceman +// find Visa2000 preamble in already demoded data +int Visa2kDemod_AM(uint8_t *dest, size_t *size) { + if (*size < 96*2) return -1; //make sure buffer has data + size_t startIdx = 0; + uint8_t preamble[] = {0,1,0,1,0,1,1,0,0,1,0,0,1,0,0,1,0,1,0,1,0,0,1,1,0,0,1,1,0,0,1,0}; + uint8_t errChk = preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx); + if (errChk == 0) return -2; //preamble not found + if (*size != 96) return -3; //wrong demoded size + //return start position + return (int) startIdx; +} + // find presco preamble 0x10D in already demoded data int PrescoDemod(uint8_t *dest, size_t *size) { //make sure buffer has data