]> cvs.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlfio.c
Merge pull request #3 from Proxmark/master
[proxmark3-svn] / client / cmdlfio.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <inttypes.h>
5 #include <limits.h>
6 //#include "proxusb.h"
7 #include "proxmark3.h"
8 #include "data.h"
9 #include "graph.h"
10 #include "ui.h"
11 #include "cmdparser.h"
12 #include "cmdmain.h"
13 #include "cmddata.h"
14 #include "cmdlf.h"
15
16 static int CmdHelp(const char *Cmd);
17
18 int CmdIODemodFSK(const char *Cmd)
19 {
20 int findone=0;
21 if(Cmd[0]=='1') findone=1;
22 UsbCommand c={CMD_IO_DEMOD_FSK};
23 c.arg[0]=findone;
24 SendCommand(&c);
25 return 0;
26 }
27
28
29 int CmdIOProxDemod(const char *Cmd){
30 if (GraphTraceLen < 4800) {
31 PrintAndLog("too short; need at least 4800 samples");
32 return 0;
33 }
34
35 GraphTraceLen = 4800;
36 for (int i = 0; i < GraphTraceLen; ++i) {
37 if (GraphBuffer[i] < 0) {
38 GraphBuffer[i] = 0;
39 } else {
40 GraphBuffer[i] = 1;
41 }
42 }
43 RepaintGraphWindow();
44 return 0;
45 }
46
47 int CmdIOClone(const char *Cmd)
48 {
49 unsigned int hi = 0, lo = 0;
50 int n = 0, i = 0;
51 UsbCommand c;
52
53
54 //if (1 == sscanf(str, "0x%"SCNx32, &hi)) {
55 // value now contains the value in the string--decimal 255, in this case.
56 //}
57
58 while (sscanf(&Cmd[i++], "%1x", &n ) == 1) {
59 hi = (hi << 4) | (lo >> 28);
60 lo = (lo << 4) | (n & 0xf);
61 }
62
63 PrintAndLog("Cloning tag with ID %08x %08x", hi, lo);
64
65 c.cmd = CMD_IO_CLONE_TAG;
66 c.arg[0] = hi;
67 c.arg[1] = lo;
68
69 SendCommand(&c);
70 return 0;
71 }
72
73 static command_t CommandTable[] =
74 {
75 {"help", CmdHelp, 1, "This help"},
76 {"demod", CmdIOProxDemod, 1, "Demodulate Stream"},
77 {"fskdemod", CmdIODemodFSK, 0, "['1'] Realtime IO FSK demodulator (option '1' for one tag only)"},
78 {"clone", CmdIOClone, 0, "Clone ioProx Tag"},
79 {NULL, NULL, 0, NULL}
80 };
81
82 int CmdLFIO(const char *Cmd)
83 {
84 CmdsParse(CommandTable, Cmd);
85 return 0;
86 }
87
88 int CmdHelp(const char *Cmd)
89 {
90 CmdsHelp(CommandTable);
91 return 0;
92 }
Impressum, Datenschutz