Generic tracing; removed iso14a_XX-functions, removed traceLen as global varible
[legacy-proxmark3.git] / client / cmdlfio.c
blob14ce5498dc3f16752410019f2f652f5c38520f85
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <inttypes.h>
5 #include <limits.h>
6 #include "proxmark3.h"
7 #include "data.h"
8 #include "graph.h"
9 #include "ui.h"
10 #include "cmdparser.h"
11 #include "cmdmain.h"
12 #include "cmddata.h"
13 #include "cmdlf.h"
15 static int CmdHelp(const char *Cmd);
17 int CmdIODemodFSK(const char *Cmd)
19 int findone=0;
20 if(Cmd[0]=='1') findone=1;
22 UsbCommand c={CMD_IO_DEMOD_FSK};
23 c.arg[0]=findone;
24 SendCommand(&c);
25 return 0;
28 int CmdIOProxDemod(const char *Cmd){
29 if (GraphTraceLen < 4800) {
30 PrintAndLog("too short; need at least 4800 samples");
31 return 0;
33 GraphTraceLen = 4800;
34 for (int i = 0; i < GraphTraceLen; ++i) {
35 GraphBuffer[i] = (GraphBuffer[i] < 0) ? 0 : 1;
37 RepaintGraphWindow();
38 return 0;
41 int CmdIOClone(const char *Cmd)
43 unsigned int hi = 0, lo = 0;
44 int n = 0, i = 0;
45 UsbCommand c;
48 //if (1 == sscanf(str, "0x%"SCNx32, &hi)) {
49 // value now contains the value in the string--decimal 255, in this case.
50 //}
52 while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
53 hi = (hi << 4) | (lo >> 28);
54 lo = (lo << 4) | (n & 0xf);
57 PrintAndLog("Cloning tag with ID %08x %08x", hi, lo);
58 PrintAndLog("Press pm3-button to abort simulation");
59 c.cmd = CMD_IO_CLONE_TAG;
60 c.arg[0] = hi;
61 c.arg[1] = lo;
63 SendCommand(&c);
64 return 0;
67 static command_t CommandTable[] =
69 {"help", CmdHelp, 1, "This help"},
70 {"demod", CmdIOProxDemod, 1, "Demodulate Stream"},
71 {"fskdemod", CmdIODemodFSK, 0, "['1'] Realtime IO FSK demodulator (option '1' for one tag only)"},
72 {"clone", CmdIOClone, 0, "Clone ioProx Tag"},
73 {NULL, NULL, 0, NULL}
76 int CmdLFIO(const char *Cmd)
78 CmdsParse(CommandTable, Cmd);
79 return 0;
82 int CmdHelp(const char *Cmd)
84 CmdsHelp(CommandTable);
85 return 0;