mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-04 07:11:10 +08:00
locate start of the sequence and level
This commit is contained in:
parent
9813f85567
commit
2248eadc7f
1 changed files with 68 additions and 3 deletions
|
@ -27,6 +27,48 @@
|
|||
#include "ui.h"
|
||||
#include "cmdhf14a.h"
|
||||
#include "cmddata.h"
|
||||
#include "graph.h"
|
||||
|
||||
#define TEXKOM_NOISE_THRESHOLD (10)
|
||||
|
||||
inline uint32_t GetGraphBuffer(uint32_t indx) {
|
||||
if (g_GraphBuffer[indx] < -128)
|
||||
return 0;
|
||||
else
|
||||
return g_GraphBuffer[indx] + 128;
|
||||
}
|
||||
|
||||
static uint32_t TexkomSearchStart(uint32_t indx, uint8_t threshold) {
|
||||
// one bit length = 27, minimal noise = 60
|
||||
uint32_t lownoisectr = 0;
|
||||
for (uint32_t i = indx; i < g_GraphTraceLen; i++) {
|
||||
if (lownoisectr > 60) {
|
||||
if (GetGraphBuffer(i) > threshold)
|
||||
return i;
|
||||
} else {
|
||||
if (GetGraphBuffer(i) > threshold)
|
||||
lownoisectr = 0;
|
||||
else
|
||||
lownoisectr++;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t TexkomSearchMax(uint32_t indx, uint32_t len) {
|
||||
uint32_t res = 0;
|
||||
|
||||
for (uint32_t i = 0; i < len; i++) {
|
||||
if (i + indx > g_GraphTraceLen)
|
||||
break;
|
||||
|
||||
if (GetGraphBuffer(indx + i) > res)
|
||||
res = GetGraphBuffer(indx + i);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int CmdHFTexkomReader(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
|
@ -41,7 +83,7 @@ static int CmdHFTexkomReader(const char *Cmd) {
|
|||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
uint32_t samplesCount = 40000;
|
||||
uint32_t samplesCount = 12000;
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_ACQ_RAW_ADC, (uint8_t *)&samplesCount, sizeof(uint32_t));
|
||||
|
||||
|
@ -52,8 +94,31 @@ static int CmdHFTexkomReader(const char *Cmd) {
|
|||
}
|
||||
|
||||
uint32_t size = (resp.data.asDwords[0]);
|
||||
if (size > 0)
|
||||
getSamples(samplesCount, true);
|
||||
if (size > 0) {
|
||||
if (getSamples(samplesCount, true) != PM3_SUCCESS) {
|
||||
PrintAndLogEx(ERR, "Get samples error");
|
||||
return PM3_EFAILED;
|
||||
};
|
||||
}
|
||||
|
||||
uint32_t sindx = 0;
|
||||
while (sindx < samplesCount - 5) {
|
||||
sindx = TexkomSearchStart(sindx, TEXKOM_NOISE_THRESHOLD);
|
||||
if (sindx == 0 || sindx > samplesCount - 5)
|
||||
break;
|
||||
|
||||
uint32_t maxlvl = TexkomSearchMax(sindx, 1760);
|
||||
if (maxlvl < TEXKOM_NOISE_THRESHOLD) {
|
||||
sindx += 1700;
|
||||
continue;
|
||||
}
|
||||
PrintAndLogEx(WARNING, "--- indx: %d, max: %d", sindx, maxlvl);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
PrintAndLogEx(WARNING, "Texkom card is not found");
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue