mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-07 13:41:18 -07:00
Improved askdemod to detect transitions from peak to peak, instead of zero-crossings, works much better for more tag types (all tags in the traces directory at least).
Now just use "askdemod 1" or "askdemod 0" and do not give the clock rate as argument (not necessary anymore)
This commit is contained in:
parent
ababf78201
commit
15db5fb71a
1 changed files with 89 additions and 92 deletions
|
@ -1822,60 +1822,54 @@ static void CmdFlexdemod(char *str)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic command to demodulate ASK. bit length in argument.
|
* Generic command to demodulate ASK.
|
||||||
* Giving the bit length helps discriminate ripple effects
|
|
||||||
* upon zero crossing for noisy traces.
|
|
||||||
*
|
*
|
||||||
* Second is convention: positive or negative (High mod means zero
|
* Argument is convention: positive or negative (High mod means zero
|
||||||
* or high mod means one)
|
* or high mod means one)
|
||||||
*
|
*
|
||||||
* Updates the Graph trace with 0/1 values
|
* Updates the Graph trace with 0/1 values
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* sl : bit length in terms of number of samples per bit
|
|
||||||
* (use yellow/purple markers to compute).
|
|
||||||
* c : 0 or 1
|
* c : 0 or 1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void Cmdaskdemod(char *str) {
|
static void Cmdaskdemod(char *str) {
|
||||||
int i;
|
int i;
|
||||||
int sign = 1;
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int c = 0;
|
int c,high,low = 0;
|
||||||
int t1 = 0;
|
|
||||||
|
|
||||||
// TODO: complain if we do not give 2 arguments here !
|
// TODO: complain if we do not give 2 arguments here !
|
||||||
sscanf(str, "%i %i", &n, &c);
|
sscanf(str, "%i", &c);
|
||||||
if (c == 0) {
|
|
||||||
c = 1 ;
|
/* Detect high and lows and clock */
|
||||||
} else {
|
for (i = 0; i < GraphTraceLen; i++)
|
||||||
c = -1;
|
{
|
||||||
|
if (GraphBuffer[i] > high)
|
||||||
|
high = GraphBuffer[i];
|
||||||
|
else if (GraphBuffer[i] < low)
|
||||||
|
low = GraphBuffer[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GraphBuffer[0]*c > 0) {
|
if (GraphBuffer[0] > 0) {
|
||||||
GraphBuffer[0] = 1;
|
GraphBuffer[0] = 1-c;
|
||||||
} else {
|
} else {
|
||||||
GraphBuffer[0] = 0;
|
GraphBuffer[0] = c;
|
||||||
}
|
}
|
||||||
for(i=1;i<GraphTraceLen;i++) {
|
for(i=1;i<GraphTraceLen;i++) {
|
||||||
/* Analyse signal within the symbol length */
|
/* Transitions are detected at each peak
|
||||||
/* Decide if we crossed a zero */
|
* Transitions are either:
|
||||||
if (GraphBuffer[i]*sign < 0) {
|
* - we're low: transition if we hit a high
|
||||||
/* Crossed a zero, check if this is a ripple or not */
|
* - we're high: transition if we hit a low
|
||||||
if ( (i-t1) > n/4 ) {
|
* (we need to do it this way because some tags keep high or
|
||||||
sign = -sign;
|
* low for long periods, others just reach the peak and go
|
||||||
t1=i;
|
* down)
|
||||||
if (GraphBuffer[i]*c > 0){
|
*/
|
||||||
GraphBuffer[i]=1;
|
if ((GraphBuffer[i]==high) && (GraphBuffer[i-1] == c)) {
|
||||||
} else {
|
GraphBuffer[i]=1-c;
|
||||||
GraphBuffer[i]=0;
|
} else if ((GraphBuffer[i]==low) && (GraphBuffer[i-1] == (1-c))){
|
||||||
}
|
GraphBuffer[i] = c;
|
||||||
} else {
|
|
||||||
/* This is a ripple, set the current sample value
|
|
||||||
to the same as previous */
|
|
||||||
GraphBuffer[i] = GraphBuffer[i-1];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
/* No transition */
|
||||||
GraphBuffer[i] = GraphBuffer[i-1];
|
GraphBuffer[i] = GraphBuffer[i-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2101,8 +2095,11 @@ static void Cmdmanchesterdemod(char *str) {
|
||||||
/* If we're not working with 1/0s, demod based off clock */
|
/* If we're not working with 1/0s, demod based off clock */
|
||||||
if (high != 1)
|
if (high != 1)
|
||||||
{
|
{
|
||||||
bit = 0;
|
bit = 0; /* We assume the 1st bit is zero, it may not be
|
||||||
for (i = 0; i < (int)(GraphTraceLen / clock); i++)
|
* the case: this routine (I think) has an init problem.
|
||||||
|
* Ed.
|
||||||
|
*/
|
||||||
|
for (; i < (int)(GraphTraceLen / clock); i++)
|
||||||
{
|
{
|
||||||
hithigh = 0;
|
hithigh = 0;
|
||||||
hitlow = 0;
|
hitlow = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue