]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/cmdlfcotag.c
ef935bb0daf737081682f754213e0717a79a899c
1 //-----------------------------------------------------------------------------
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
8 // Low frequency COTAG commands
9 //-----------------------------------------------------------------------------
10 #include "cmdlfcotag.h" // COTAG function declarations
12 static int CmdHelp(const char *Cmd
);
14 int usage_lf_cotag_read(void){
15 PrintAndLog("Usage: lf COTAG read [h] <signaldata>");
16 PrintAndLog("Options:");
17 PrintAndLog(" h : This help");
18 PrintAndLog(" <0|1|2> : 0 - HIGH/LOW signal; maxlength bigbuff");
19 PrintAndLog(" : 1 - translation of HI/LO into bytes with manchester 0,1");
20 PrintAndLog(" : 2 - raw signal; maxlength bigbuff");
22 PrintAndLog("Sample:");
23 PrintAndLog(" lf cotag read 0");
24 PrintAndLog(" lf cotag read 1");
27 int CmdCOTAGDemod(const char *Cmd
) {
31 // When reading a COTAG.
32 // 0 = HIGH/LOW signal - maxlength bigbuff
33 // 1 = translation for HI/LO into bytes with manchester 0,1 - length 300
34 // 2 = raw signal - maxlength bigbuff
35 int CmdCOTAGRead(const char *Cmd
) {
37 if (Cmd
[0] == 'h' || Cmd
[0] == 'H') return usage_lf_cotag_read();
39 uint8_t bits
[320] = {0};
40 uint32_t rawsignal
= 0;
41 sscanf(Cmd
, "%u", &rawsignal
);
43 UsbCommand c
= {CMD_COTAG
, {rawsignal
, 0, 0}};
46 if ( !WaitForResponseTimeout(CMD_ACK
, NULL
, 7000) ) {
47 PrintAndLog("command execution time out");
56 getSamples("", true); break;
59 GetFromBigBuf(bits
, sizeof(bits
), 0);
61 if ( !WaitForResponseTimeout(CMD_ACK
, &response
, 500) ) {
62 if (g_debugMode
) PrintAndLog("timeout while waiting for reply.");
66 size_t size
= sizeof(bits
);
67 int err
= manrawdecode(bits
, &size
, 1);
69 if (g_debugMode
) PrintAndLog("DEBUG: Error - COTAG too many errors: %d", err
);
72 PrintAndLog("%s", sprint_bin(bits
, size
));
73 setDemodBuf(bits
, size
, 0);
82 static command_t CommandTable
[] = {
83 {"help", CmdHelp
, 1, "This help"},
84 {"demod", CmdCOTAGDemod
, 1, "Tries to decode a COTAG signal"},
85 {"read", CmdCOTAGRead
, 0, "Attempt to read and extract tag data"},
89 int CmdLFCOTAG(const char *Cmd
) {
91 CmdsParse(CommandTable
, Cmd
);
95 int CmdHelp(const char *Cmd
) {
96 CmdsHelp(CommandTable
);