summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
549daaf)
don't have any tags capable to test and not yet hooked up to data
rawdemod...
uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
uint8_t g_debugMode=0;
size_t DemodBufferLen=0;
uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
uint8_t g_debugMode=0;
size_t DemodBufferLen=0;
+size_t g_demodStartIdx=0;
+uint8_t g_demodClock=0;
+
static int CmdHelp(const char *Cmd);
//set the demod buffer with given array of binary (one bit per byte)
static int CmdHelp(const char *Cmd);
//set the demod buffer with given array of binary (one bit per byte)
+//should be moved to cmdlfem4x.c
int AskEm410xDecode(bool verbose, uint32_t *hi, uint64_t *lo )
{
size_t idx = 0;
int AskEm410xDecode(bool verbose, uint32_t *hi, uint64_t *lo )
{
size_t idx = 0;
+//should be moved to cmdlfem4x.c
int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo, bool verbose)
{
bool st = true;
int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo, bool verbose)
{
bool st = true;
return AskEm410xDecode(verbose, hi, lo);
}
return AskEm410xDecode(verbose, hi, lo);
}
+//should be moved to cmdlfem4x.c
//by marshmellow
//takes 3 arguments - clock, invert and maxErr as integers
//attempts to demodulate ask while decoding manchester
//by marshmellow
//takes 3 arguments - clock, invert and maxErr as integers
//attempts to demodulate ask while decoding manchester
sscanf(Cmd, "%i %i", &invert, &maxErr);
size=i;
sscanf(Cmd, "%i %i", &invert, &maxErr);
size=i;
- errCnt=manrawdecode(BitStream, &size, invert);
+ uint8_t alignPos = 0;
+ errCnt=manrawdecode(BitStream, &size, invert, &alignPos);
if (errCnt>=maxErr){
PrintAndLog("Too many errors: %d",errCnt);
return 0;
if (errCnt>=maxErr){
PrintAndLog("Too many errors: %d",errCnt);
return 0;
return ASKbiphaseDemod(Cmd, true);
}
return ASKbiphaseDemod(Cmd, true);
}
+//could be split to a gProxII file
//by marshmellow
//attempts to demodulate and identify a G_Prox_II verex/chubb card
//WARNING: if it fails during some points it will destroy the DemodBuffer data
//by marshmellow
//attempts to demodulate and identify a G_Prox_II verex/chubb card
//WARNING: if it fails during some points it will destroy the DemodBuffer data
+//could be moved to a viking file
//by marshmellow
//see ASKDemod for what args are accepted
int CmdVikingDemod(const char *Cmd)
//by marshmellow
//see ASKDemod for what args are accepted
int CmdVikingDemod(const char *Cmd)
return FSKrawDemod(Cmd, true);
}
return FSKrawDemod(Cmd, true);
}
//by marshmellow (based on existing demod + holiman's refactor)
//HID Prox demod - FSK RF/50 with preamble of 00011101 (then manchester encoded)
//print full HID Prox ID and some bit format details if found
//by marshmellow (based on existing demod + holiman's refactor)
//HID Prox demod - FSK RF/50 with preamble of 00011101 (then manchester encoded)
//print full HID Prox ID and some bit format details if found
//by marshmellow
//Paradox Prox demod - FSK RF/50 with preamble of 00001111 (then manchester encoded)
//print full Paradox Prox ID and some bit format details if found
//by marshmellow
//Paradox Prox demod - FSK RF/50 with preamble of 00001111 (then manchester encoded)
//print full Paradox Prox ID and some bit format details if found
if (GraphBuffer[i] >= upThres && GraphBuffer[i] > lastValue)
{
lastValue = GraphBuffer[i]; // Buffer last value as we overwrite it.
if (GraphBuffer[i] >= upThres && GraphBuffer[i] > lastValue)
{
lastValue = GraphBuffer[i]; // Buffer last value as we overwrite it.
}
// Apply second threshold to samples heading down
else if (GraphBuffer[i] <= downThres && GraphBuffer[i] < lastValue)
{
lastValue = GraphBuffer[i]; // Buffer last value as we overwrite it.
}
// Apply second threshold to samples heading down
else if (GraphBuffer[i] <= downThres && GraphBuffer[i] < lastValue)
{
lastValue = GraphBuffer[i]; // Buffer last value as we overwrite it.
-//take 11 10 01 11 00 and make 01100 ... miller decoding
+//take 11 10 01 11 00 and make 01100 ... miller decoding
//check for phase errors - should never have half a 1 or 0 by itself and should never exceed 1111 or 0000 in a row
//decodes miller encoded binary
//NOTE askrawdemod will NOT demod miller encoded ask unless the clock is manually set to 1/2 what it is detected as!
//check for phase errors - should never have half a 1 or 0 by itself and should never exceed 1111 or 0000 in a row
//decodes miller encoded binary
//NOTE askrawdemod will NOT demod miller encoded ask unless the clock is manually set to 1/2 what it is detected as!
-/*int millerRawDecode(uint8_t *BitStream, size_t *size, int invert) {
+int millerRawDecode(uint8_t *BitStream, size_t *size, int invert) {
if (*size < 16) return -1;
if (*size < 16) return -1;
- uint16_t MaxBits = 512, errCnt = 0, bestErr = 1000, bestRun = 0;
- size_t i, ii, bitCnt=0;
- uint8_t alignCnt = 0, curBit = BitStream[0];
+ uint16_t MaxBits = 512, errCnt = 0;
+ size_t i, bitCnt=0;
+ uint8_t alignCnt = 0, curBit = BitStream[0], alignedIdx = 0;
+ uint8_t halfClkErr = 0;
//find alignment, needs 4 1s or 0s to properly align
//find alignment, needs 4 1s or 0s to properly align
- for (i=1; i < *size; i++) {
+ for (i=1; i < *size-1; i++) {
alignCnt = (BitStream[i] == curBit) ? alignCnt+1 : 0;
curBit = BitStream[i];
if (alignCnt == 4) break;
alignCnt = (BitStream[i] == curBit) ? alignCnt+1 : 0;
curBit = BitStream[i];
if (alignCnt == 4) break;
if (g_debugMode) prnt("ERROR MillerDecode: alignment not found so either your bitstream is not miller or your data does not have a 101 in it");
return -1;
}
if (g_debugMode) prnt("ERROR MillerDecode: alignment not found so either your bitstream is not miller or your data does not have a 101 in it");
return -1;
}
+ alignedIdx = (i-1) % 2;
+ for (i=alignedIdx; i < *size-3; i+=2) {
+ halfClkErr = (uint8_t)((halfClkErr << 1 | BitStream[i]) & 0xFF);
+ if ( (halfClkErr & 0x7) == 5 || (halfClkErr & 0x7) == 2 || (i > 2 && (halfClkErr & 0x7) == 0) || (halfClkErr & 0x1F) == 0x1F) {
+ errCnt++;
+ BitStream[bitCnt++] = 7;
+ continue;
+ }
+ BitStream[bitCnt++] = BitStream[i] ^ BitStream[i+1] ^ invert;
+ if (bitCnt > MaxBits) break;
+ }
+ *size = bitCnt;
+ return errCnt;
+}
//by marshmellow
//take 01 or 10 = 1 and 11 or 00 = 0
//by marshmellow
//take 01 or 10 = 1 and 11 or 00 = 0
// by iceman
// find Visa2000 preamble in already demoded data
int Visa2kDemod_AM(uint8_t *dest, size_t *size) {
// by iceman
// find Visa2000 preamble in already demoded data
int Visa2kDemod_AM(uint8_t *dest, size_t *size) {