Merge pull request #122 from RfidResearchGroup/computeSignalProperties

Replace isNoise by computeSignalProperties and removeSignalOffset
This commit is contained in:
Iceman
2019-03-09 08:35:37 +01:00
committed by GitHub
7 changed files with 85 additions and 129 deletions

View File

@@ -1393,15 +1393,13 @@ int CmdHide(const char *Cmd) {
//zero mean GraphBuffer
int CmdHpf(const char *Cmd) {
int i, accum = 0;
for (i = 10; i < GraphTraceLen; ++i)
accum += GraphBuffer[i];
accum /= (GraphTraceLen - 10);
for (i = 0; i < GraphTraceLen; ++i)
GraphBuffer[i] -= accum;
uint8_t bits[GraphTraceLen];
size_t size = getFromGraphBuf(bits);
removeSignalOffset(bits, size);
// push it back to graph
setGraphBuf(bits, size);
// set signal properties low/high/mean/amplitude and is_noise detection
computeSignalProperties(bits, size);
RepaintGraphWindow();
return 0;
@@ -1471,12 +1469,11 @@ int getSamples(int n, bool silent) {
GraphTraceLen = n;
}
//ICEMAN todo
uint8_t bits[GraphTraceLen];
size_t size = getFromGraphBuf(bits);
// set signal properties low/high/mean/amplitude and is_noice detection
isNoise(bits, size);
// set signal properties low/high/mean/amplitude and is_noise detection
computeSignalProperties(bits, size);
setClockGrid(0, 0);
DemodBufferLen = 0;
RepaintGraphWindow();
@@ -1610,15 +1607,19 @@ int CmdLoad(const char *Cmd) {
fclose(f);
PrintAndLogEx(SUCCESS, "loaded %d samples", GraphTraceLen);
uint8_t bits[GraphTraceLen];
size_t size = getFromGraphBuf(bits);
// set signal properties low/high/mean/amplitude and is_noise detection
removeSignalOffset(bits, size);
// push it back to graph
setGraphBuf(bits, size);
// set signal properties low/high/mean/amplitude and is_noise detection
computeSignalProperties(bits, size);
setClockGrid(0,0);
DemodBufferLen = 0;
RepaintGraphWindow();
//ICEMAN todo
// set signal properties low/high/mean/amplitude and isnoice detection
uint8_t bits[GraphTraceLen];
size_t size = getFromGraphBuf(bits);
isNoise(bits, size);
return 0;
}
@@ -1683,11 +1684,11 @@ int CmdNorm(const char *Cmd) {
}
}
//ICEMAN todo
// set signal properties low/high/mean/amplitude and isnoice detection
uint8_t bits[GraphTraceLen];
size_t size = getFromGraphBuf(bits);
isNoise(bits, size);
// set signal properties low/high/mean/amplitude and is_noise detection
computeSignalProperties(bits, size);
RepaintGraphWindow();
return 0;
}
@@ -1773,11 +1774,11 @@ int CmdDirectionalThreshold(const char *Cmd) {
directionalThreshold(GraphBuffer, GraphBuffer, GraphTraceLen, up, down);
//ICEMAN todo
// set signal properties low/high/mean/amplitude and isnoice detection
uint8_t bits[GraphTraceLen];
size_t size = getFromGraphBuf(bits);
isNoise(bits, size);
// set signal properties low/high/mean/amplitude and is_noice detection
computeSignalProperties(bits, size);
RepaintGraphWindow();
return 0;
@@ -1805,11 +1806,10 @@ int CmdZerocrossings(const char *Cmd) {
}
}
//ICEMAN todo
// set signal properties low/high/mean/amplitude and isnoice detection
uint8_t bits[GraphTraceLen];
size_t size = getFromGraphBuf(bits);
isNoise(bits, size);
// set signal properties low/high/mean/amplitude and is_noise detection
computeSignalProperties(bits, size);
RepaintGraphWindow();
return 0;
@@ -2063,13 +2063,11 @@ int CmdDataIIR(const char *Cmd){
//iceIIR_Butterworth(GraphBuffer, GraphTraceLen);
iceSimple_Filter(GraphBuffer, GraphTraceLen, k);
//ICEMAN todo
// set signal properties low/high/mean/amplitude and isnoice detection
uint8_t bits[GraphTraceLen];
size_t size = getFromGraphBuf(bits);
isNoise(bits, size);
RepaintGraphWindow();
// set signal properties low/high/mean/amplitude and is_noise detection
computeSignalProperties(bits, size);
RepaintGraphWindow();
return 0;
}

View File

@@ -800,7 +800,7 @@ int EM4x50Read(const char *Cmd, bool verbose) {
uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0};
size_t size = getFromGraphBuf(bits);
isNoise(bits, size);
computeSignalProperties(bits, size);
signal_t *sp = getSignalProperties();
high = sp->high;
@@ -999,9 +999,12 @@ bool downloadSamplesEM(){
PrintAndLogEx(WARNING, "command execution time out");
return false;
}
setGraphBuf(got, sizeof(got));
if (isNoise(got, sizeof(got))) {
setGraphBuf(got, sizeof(got));
// set signal properties low/high/mean/amplitude and is_noise detection
computeSignalProperties(got, sizeof(got));
RepaintGraphWindow();
if (getSignalProperties()->isnoise) {
PrintAndLogEx(DEBUG, "No tag found");
return false;
}

View File

@@ -1331,7 +1331,10 @@ bool AquireData( uint8_t page, uint8_t block, bool pwdmode, uint32_t password )
return false;
}
setGraphBuf(got, sizeof(got));
return !isNoise(got, sizeof(got));
// set signal properties low/high/mean/amplitude and is_noise detection
computeSignalProperties(got, sizeof(got));
RepaintGraphWindow();
return !getSignalProperties()->isnoise;
}
char * GetBitRateStr(uint32_t id, bool xmode) {

View File

@@ -463,7 +463,7 @@ bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint3
return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_FLASHMEM_DOWNLOADED);
}
case SIM_MEM: {
//UsbCommand c = {CMD_DOWNLOAND_SIM_MEM, {start_index, bytes, 0}};
//UsbCommand c = {CMD_DOWNLOAD_SIM_MEM, {start_index, bytes, 0}};
//SendCommand(&c);
//return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_DOWNLOADED_SIMMEM);
return false;