mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-07 13:41:18 -07:00
add inversion option to mandemod and fix indentation
This commit is contained in:
parent
cef010bc72
commit
ac174b297a
1 changed files with 24 additions and 14 deletions
|
@ -2065,7 +2065,7 @@ static void Cmdmanchestermod(char *str)
|
||||||
* Typical values can be 64, 32, 128...
|
* Typical values can be 64, 32, 128...
|
||||||
*/
|
*/
|
||||||
static void Cmdmanchesterdemod(char *str) {
|
static void Cmdmanchesterdemod(char *str) {
|
||||||
int i, j;
|
int i, j, invert= 0;
|
||||||
int bit;
|
int bit;
|
||||||
int clock;
|
int clock;
|
||||||
int lastval;
|
int lastval;
|
||||||
|
@ -2077,6 +2077,16 @@ static void Cmdmanchesterdemod(char *str) {
|
||||||
int bit2idx = 0;
|
int bit2idx = 0;
|
||||||
int warnings = 0;
|
int warnings = 0;
|
||||||
|
|
||||||
|
/* check if we're inverting output */
|
||||||
|
if(*str == 'i')
|
||||||
|
{
|
||||||
|
PrintToScrollback("Inverting output");
|
||||||
|
invert= 1;
|
||||||
|
do
|
||||||
|
++str;
|
||||||
|
while(*str == ' '); // in case a 2nd argument was given
|
||||||
|
}
|
||||||
|
|
||||||
/* Holds the decoded bitstream: each clock period contains 2 bits */
|
/* Holds the decoded bitstream: each clock period contains 2 bits */
|
||||||
/* later simplified to 1 bit after manchester decoding. */
|
/* later simplified to 1 bit after manchester decoding. */
|
||||||
/* Add 10 bits to allow for noisy / uncertain traces without aborting */
|
/* Add 10 bits to allow for noisy / uncertain traces without aborting */
|
||||||
|
@ -2147,7 +2157,7 @@ static void Cmdmanchesterdemod(char *str) {
|
||||||
if (!hithigh || !hitlow)
|
if (!hithigh || !hitlow)
|
||||||
bit ^= 1;
|
bit ^= 1;
|
||||||
|
|
||||||
BitStream[bit2idx++] = bit;
|
BitStream[bit2idx++] = bit ^ invert;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2199,9 +2209,9 @@ static void Cmdmanchesterdemod(char *str) {
|
||||||
// to stop output at the final bitidx2 value, not bitidx
|
// to stop output at the final bitidx2 value, not bitidx
|
||||||
for (i = 0; i < bitidx; i += 2) {
|
for (i = 0; i < bitidx; i += 2) {
|
||||||
if ((BitStream[i] == 0) && (BitStream[i+1] == 1)) {
|
if ((BitStream[i] == 0) && (BitStream[i+1] == 1)) {
|
||||||
BitStream[bit2idx++] = 1;
|
BitStream[bit2idx++] = 1 ^ invert;
|
||||||
} else if ((BitStream[i] == 1) && (BitStream[i+1] == 0)) {
|
} else if ((BitStream[i] == 1) && (BitStream[i+1] == 0)) {
|
||||||
BitStream[bit2idx++] = 0;
|
BitStream[bit2idx++] = 0 ^ invert;
|
||||||
} else {
|
} else {
|
||||||
// We cannot end up in this state, this means we are unsynchronized,
|
// We cannot end up in this state, this means we are unsynchronized,
|
||||||
// move up 1 bit:
|
// move up 1 bit:
|
||||||
|
@ -2444,7 +2454,7 @@ static struct {
|
||||||
"losamples", CmdLosamples,0, "[128 - 16000] -- Get raw samples for LF tag",
|
"losamples", CmdLosamples,0, "[128 - 16000] -- Get raw samples for LF tag",
|
||||||
"losim", CmdLosim,0, " Simulate LF tag",
|
"losim", CmdLosim,0, " Simulate LF tag",
|
||||||
"ltrim", CmdLtrim,1, "<samples> -- Trim samples from left of trace",
|
"ltrim", CmdLtrim,1, "<samples> -- Trim samples from left of trace",
|
||||||
"mandemod", Cmdmanchesterdemod,1, "[clock rate] -- Try a Manchester demodulation on a binary stream",
|
"mandemod", Cmdmanchesterdemod,1, "[i] [clock rate] -- Manchester demodulate binary stream (option 'i' to invert output)",
|
||||||
"manmod", Cmdmanchestermod,1, "[clock rate] -- Manchester modulate a binary stream",
|
"manmod", Cmdmanchestermod,1, "[clock rate] -- Manchester modulate a binary stream",
|
||||||
"norm", CmdNorm,1, " Normalize max/min to +/-500",
|
"norm", CmdNorm,1, " Normalize max/min to +/-500",
|
||||||
"plot", CmdPlot,1, " Show graph window",
|
"plot", CmdPlot,1, " Show graph window",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue