]> cvs.zerfleddert.de Git - proxmark3-svn/blame - client/cmdlf.c
PCF7931: Print found single/consecutive block(s), fixes to block 1 check
[proxmark3-svn] / client / cmdlf.c
CommitLineData
a553f267 1//-----------------------------------------------------------------------------
2// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
3//
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
6// the license.
7//-----------------------------------------------------------------------------
8// Low frequency commands
9//-----------------------------------------------------------------------------
10
ad939de5 11#include "cmdlf.h"
12
7fe9b0b7 13#include <stdio.h>
590f8ff9 14#include <stdlib.h>
7fe9b0b7 15#include <string.h>
393c3ef9 16#include <limits.h>
b9957414 17#include <stdbool.h>
18#include <stdint.h>
ad939de5 19#include "comms.h"
29ada8fc 20#include "lfdemod.h" // for psk2TOpsk1
6923d3f1 21#include "util.h" // for parsing cli command utils
22#include "ui.h" // for show graph controls
23#include "graph.h" // for graph data
24#include "cmdparser.h" // for getting cli commands included in cmdmain.h
25#include "cmdmain.h" // for sending cmds to device
6923d3f1 26#include "cmddata.h" // for `lf search`
27#include "cmdlfawid.h" // for awid menu
28#include "cmdlfem4x.h" // for em4x menu
29#include "cmdlfhid.h" // for hid menu
30#include "cmdlfhitag.h" // for hitag menu
31#include "cmdlfio.h" // for ioprox menu
32#include "cmdlft55xx.h" // for t55xx menu
33#include "cmdlfti.h" // for ti menu
34#include "cmdlfpresco.h" // for presco menu
35#include "cmdlfpcf7931.h"// for pcf7931 menu
36#include "cmdlfpyramid.h"// for pyramid menu
37#include "cmdlfviking.h" // for viking menu
e04475c4 38#include "cmdlfcotag.h" // for COTAG menu
8b6abef5 39#include "cmdlfvisa2000.h" // for VISA2000 menu
0fb65a26 40#include "cmdlfindala.h" // for indala menu
946a84c3 41#include "cmdlfgproxii.h"// for gproxii menu
4db6f3bb 42#include "cmdlffdx.h" // for fdx-b menu
5bce72d5 43#include "cmdlfparadox.h"// for paradox menu
44#include "cmdlfnexwatch.h"//for nexwatch menu
a9968da3 45#include "cmdlfjablotron.h" //for jablotron menu
46#include "cmdlfnoralsy.h"// for noralsy menu
c3caf040 47#include "cmdlfsecurakey.h"//for securakey menu
69f42a05 48#include "cmdlfpac.h" // for pac menu
e04475c4 49
fac69c3d 50bool g_lf_threshold_set = false;
7fe9b0b7 51static int CmdHelp(const char *Cmd);
52
21a615cb 53
54
f86d6b55 55int usage_lf_cmdread(void)
21a615cb 56{
779d9a0e 57 PrintAndLog("Usage: lf cmdread d <delay period> z <zero period> o <one period> c <cmdbytes> ");
21a615cb 58 PrintAndLog("Options: ");
59 PrintAndLog(" h This help");
779d9a0e 60 PrintAndLog(" d <delay> delay OFF period between bits (0 for bitbang mode)");
61 PrintAndLog(" z <zero> time period ZERO (antenna off in bitbang mode)");
62 PrintAndLog(" o <one> time period ONE (antenna on in bitbang mode)");
21a615cb 63 PrintAndLog(" c <cmd> Command bytes");
64 PrintAndLog(" ************* All periods in microseconds");
779d9a0e 65 PrintAndLog(" ************* Use lf config to configure options.");
21a615cb 66 PrintAndLog("Examples:");
67 PrintAndLog(" lf cmdread d 80 z 100 o 200 c 11000");
779d9a0e 68 PrintAndLog(" lf cmdread d 80 z 100 o 100 c 11000");
21a615cb 69 return 0;
70}
71
7fe9b0b7 72/* send a command before reading */
73int CmdLFCommandRead(const char *Cmd)
74{
e0165dcf 75 UsbCommand c = {CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K};
7cb8516c 76 bool errors = false;
21a615cb 77 //uint8_t divisor = 95; //125khz
78 uint8_t cmdp = 0;
21a615cb 79 while(param_getchar(Cmd, cmdp) != 0x00)
80 {
81 switch(param_getchar(Cmd, cmdp))
82 {
83 case 'h':
84 return usage_lf_cmdread();
21a615cb 85 case 'c':
874572d4 86 param_getstr(Cmd, cmdp+1, (char *)&c.d.asBytes, sizeof(c.d.asBytes));
21a615cb 87 cmdp+=2;
88 break;
89 case 'd':
90 c.arg[0] = param_get32ex(Cmd, cmdp+1, 0, 10);
91 cmdp+=2;
92 break;
93 case 'z':
94 c.arg[1] = param_get32ex(Cmd, cmdp+1, 0, 10);
95 cmdp+=2;
96 break;
97 case 'o':
98 c.arg[2] = param_get32ex(Cmd, cmdp+1, 0, 10);
99 cmdp+=2;
100 break;
101 default:
102 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
103 errors = 1;
104 break;
105 }
106 if(errors) break;
107 }
108 // No args
109 if(cmdp == 0) errors = 1;
110
111 //Validations
112 if(errors) return usage_lf_cmdread();
113
21a615cb 114 clearCommandBuffer();
e0165dcf 115 SendCommand(&c);
779d9a0e 116
117 WaitForResponse(CMD_ACK,NULL);
118 getSamples(0, true);
119
120
e0165dcf 121 return 0;
7fe9b0b7 122}
123
124int CmdFlexdemod(const char *Cmd)
125{
e0165dcf 126 int i;
127 for (i = 0; i < GraphTraceLen; ++i) {
128 if (GraphBuffer[i] < 0) {
129 GraphBuffer[i] = -1;
130 } else {
131 GraphBuffer[i] = 1;
132 }
133 }
7fe9b0b7 134
f6650679 135 #define LONG_WAIT 100
e0165dcf 136 int start;
137 for (start = 0; start < GraphTraceLen - LONG_WAIT; start++) {
138 int first = GraphBuffer[start];
139 for (i = start; i < start + LONG_WAIT; i++) {
140 if (GraphBuffer[i] != first) {
141 break;
142 }
143 }
144 if (i == (start + LONG_WAIT)) {
145 break;
146 }
147 }
148 if (start == GraphTraceLen - LONG_WAIT) {
149 PrintAndLog("nothing to wait for");
150 return 0;
151 }
152
153 GraphBuffer[start] = 2;
154 GraphBuffer[start+1] = -2;
3fe4ff4f 155 uint8_t bits[64] = {0x00};
7fe9b0b7 156
3fe4ff4f 157 int bit, sum;
e0165dcf 158 i = start;
159 for (bit = 0; bit < 64; bit++) {
3fe4ff4f 160 sum = 0;
161 for (int j = 0; j < 16; j++) {
e0165dcf 162 sum += GraphBuffer[i++];
163 }
3fe4ff4f 164
165 bits[bit] = (sum > 0) ? 1 : 0;
166
e0165dcf 167 PrintAndLog("bit %d sum %d", bit, sum);
168 }
169
170 for (bit = 0; bit < 64; bit++) {
171 int j;
172 int sum = 0;
173 for (j = 0; j < 16; j++) {
174 sum += GraphBuffer[i++];
175 }
176 if (sum > 0 && bits[bit] != 1) {
177 PrintAndLog("oops1 at %d", bit);
178 }
179 if (sum < 0 && bits[bit] != 0) {
180 PrintAndLog("oops2 at %d", bit);
181 }
182 }
7fe9b0b7 183
3fe4ff4f 184 // HACK writing back to graphbuffer.
e0165dcf 185 GraphTraceLen = 32*64;
186 i = 0;
187 int phase = 0;
188 for (bit = 0; bit < 64; bit++) {
3fe4ff4f 189
190 phase = (bits[bit] == 0) ? 0 : 1;
191
e0165dcf 192 int j;
193 for (j = 0; j < 32; j++) {
194 GraphBuffer[i++] = phase;
195 phase = !phase;
196 }
197 }
198
199 RepaintGraphWindow();
200 return 0;
0fb65a26 201}
2414f978 202
f86d6b55 203int usage_lf_read(void)
f6d9fb17 204{
31abe49f 205 PrintAndLog("Usage: lf read");
f6d9fb17
MHS
206 PrintAndLog("Options: ");
207 PrintAndLog(" h This help");
1fbf8956 208 PrintAndLog(" s silent run no printout");
b9957414 209 PrintAndLog(" [# samples] # samples to collect (optional)");
31abe49f
MHS
210 PrintAndLog("Use 'lf config' to set parameters.");
211 return 0;
212}
f86d6b55 213int usage_lf_snoop(void)
31abe49f
MHS
214{
215 PrintAndLog("Usage: lf snoop");
216 PrintAndLog("Options: ");
217 PrintAndLog(" h This help");
218 PrintAndLog("This function takes no arguments. ");
219 PrintAndLog("Use 'lf config' to set parameters.");
220 return 0;
221}
222
f86d6b55 223int usage_lf_config(void)
31abe49f
MHS
224{
225 PrintAndLog("Usage: lf config [H|<divisor>] [b <bps>] [d <decim>] [a 0|1]");
226 PrintAndLog("Options: ");
2de26056 227 PrintAndLog(" h This help");
228 PrintAndLog(" L Low frequency (125 KHz)");
229 PrintAndLog(" H High frequency (134 KHz)");
230 PrintAndLog(" q <divisor> Manually set divisor. 88-> 134 KHz, 95-> 125 KHz");
231 PrintAndLog(" b <bps> Sets resolution of bits per sample. Default (max): 8");
232 PrintAndLog(" d <decim> Sets decimation. A value of N saves only 1 in N samples. Default: 1");
233 PrintAndLog(" a [0|1] Averaging - if set, will average the stored sample value when decimating. Default: 1");
234 PrintAndLog(" t <threshold> Sets trigger threshold. 0 means no threshold (range: 0-128)");
235 PrintAndLog(" s <smplstoskip> Sets a number of samples to skip before capture. Default: 0");
f6d9fb17 236 PrintAndLog("Examples:");
31abe49f 237 PrintAndLog(" lf config b 8 L");
2de26056 238 PrintAndLog(" Samples at 125KHz, 8bps.");
31abe49f 239 PrintAndLog(" lf config H b 4 d 3");
2de26056 240 PrintAndLog(" Samples at 134KHz, averages three samples into one, stored with ");
241 PrintAndLog(" a resolution of 4 bits per sample.");
31abe49f 242 PrintAndLog(" lf read");
2de26056 243 PrintAndLog(" Performs a read (active field)");
31abe49f 244 PrintAndLog(" lf snoop");
2de26056 245 PrintAndLog(" Performs a snoop (no active field)");
f6d9fb17
MHS
246 return 0;
247}
31abe49f
MHS
248
249int CmdLFSetConfig(const char *Cmd)
7fe9b0b7 250{
31abe49f
MHS
251
252 uint8_t divisor = 0;//Frequency divisor
253 uint8_t bps = 0; // Bits per sample
254 uint8_t decimation = 0; //How many to keep
255 bool averaging = 1; // Defaults to true
7cb8516c 256 bool errors = false;
31abe49f
MHS
257 int trigger_threshold =-1;//Means no change
258 uint8_t unsigned_trigg = 0;
2de26056 259 int samples_to_skip = -1;
f6d9fb17
MHS
260
261 uint8_t cmdp =0;
31abe49f 262 while(param_getchar(Cmd, cmdp) != 0x00)
f6d9fb17 263 {
31abe49f
MHS
264 switch(param_getchar(Cmd, cmdp))
265 {
266 case 'h':
267 return usage_lf_config();
268 case 'H':
269 divisor = 88;
270 cmdp++;
271 break;
272 case 'L':
273 divisor = 95;
274 cmdp++;
275 break;
276 case 'q':
277 errors |= param_getdec(Cmd,cmdp+1,&divisor);
278 cmdp+=2;
279 break;
280 case 't':
281 errors |= param_getdec(Cmd,cmdp+1,&unsigned_trigg);
282 cmdp+=2;
2b11c7c7 283 if(!errors) {
284 trigger_threshold = unsigned_trigg;
fac69c3d 285 if (trigger_threshold > 0) g_lf_threshold_set = true;
2b11c7c7 286 }
31abe49f
MHS
287 break;
288 case 'b':
289 errors |= param_getdec(Cmd,cmdp+1,&bps);
290 cmdp+=2;
291 break;
292 case 'd':
293 errors |= param_getdec(Cmd,cmdp+1,&decimation);
294 cmdp+=2;
295 break;
296 case 'a':
297 averaging = param_getchar(Cmd,cmdp+1) == '1';
298 cmdp+=2;
299 break;
2de26056 300 case 's':
301 samples_to_skip = param_get32ex(Cmd,cmdp+1,0,10);
302 cmdp+=2;
303 break;
31abe49f
MHS
304 default:
305 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
306 errors = 1;
307 break;
308 }
309 if(errors) break;
f6d9fb17 310 }
31abe49f 311 if(cmdp == 0)
f6d9fb17 312 {
31abe49f 313 errors = 1;// No args
f6d9fb17 314 }
31abe49f 315
f6d9fb17
MHS
316 //Validations
317 if(errors)
318 {
31abe49f 319 return usage_lf_config();
f6d9fb17 320 }
f6d9fb17 321 //Bps is limited to 8, so fits in lower half of arg1
72c5877a 322 if(bps >> 4) bps = 8;
f6d9fb17 323
31abe49f 324 sample_config config = {
2de26056 325 decimation,bps,averaging,divisor,trigger_threshold,samples_to_skip
31abe49f
MHS
326 };
327 //Averaging is a flag on high-bit of arg[1]
328 UsbCommand c = {CMD_SET_LF_SAMPLING_CONFIG};
329 memcpy(c.d.asBytes,&config,sizeof(sample_config));
709665b5 330 clearCommandBuffer();
31abe49f
MHS
331 SendCommand(&c);
332 return 0;
333}
f6d9fb17 334
b9957414 335bool lf_read(bool silent, uint32_t samples) {
61aaee35 336 if (IsOffline()) return false;
b9957414 337 UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_125K, {silent,samples,0}};
338 clearCommandBuffer();
339 //And ship it to device
340 SendCommand(&c);
341
342 UsbCommand resp;
343 if (g_lf_threshold_set) {
344 WaitForResponse(CMD_ACK,&resp);
345 } else {
346 if ( !WaitForResponseTimeout(CMD_ACK,&resp,2500) ) {
347 PrintAndLog("command execution time out");
348 return false;
349 }
350 }
c68f5fc7 351 // resp.arg[0] is bits read not bytes read.
352 getSamples(resp.arg[0]/8, silent);
b9957414 353
354 return true;
355}
356
7fe9b0b7 357int CmdLFRead(const char *Cmd)
358{
1fbf8956 359 uint8_t cmdp = 0;
b9957414 360 bool silent = false;
1fbf8956 361 if (param_getchar(Cmd, cmdp) == 'h')
31abe49f
MHS
362 {
363 return usage_lf_read();
364 }
b9957414 365 if (param_getchar(Cmd, cmdp) == 's') {
366 silent = true; //suppress print
367 cmdp++;
2b11c7c7 368 }
b9957414 369 uint32_t samples = param_get32ex(Cmd, cmdp, 0, 10);
370 return lf_read(silent, samples);
31abe49f 371}
f6d9fb17 372
31abe49f
MHS
373int CmdLFSnoop(const char *Cmd)
374{
375 uint8_t cmdp =0;
376 if(param_getchar(Cmd, cmdp) == 'h')
377 {
378 return usage_lf_snoop();
379 }
380
381 UsbCommand c = {CMD_LF_SNOOP_RAW_ADC_SAMPLES};
709665b5 382 clearCommandBuffer();
f6d9fb17
MHS
383 SendCommand(&c);
384 WaitForResponse(CMD_ACK,NULL);
b9957414 385 getSamples(0, true);
386
f6d9fb17 387 return 0;
7fe9b0b7 388}
389
390static void ChkBitstream(const char *str)
391{
e0165dcf 392 int i;
78f5b1a7 393
e0165dcf 394 /* convert to bitstream if necessary */
b915fda3 395 for (i = 0; i < (int)(GraphTraceLen / 2); i++){
396 if (GraphBuffer[i] > 1 || GraphBuffer[i] < 0) {
e0165dcf 397 CmdGetBitStream("");
398 break;
399 }
400 }
7fe9b0b7 401}
2767fc02 402//Attempt to simulate any wave in buffer (one bit per output sample)
403// converts GraphBuffer to bitstream (based on zero crossings) if needed.
7fe9b0b7 404int CmdLFSim(const char *Cmd)
405{
e0165dcf 406 int i,j;
407 static int gap;
7fe9b0b7 408
e0165dcf 409 sscanf(Cmd, "%i", &gap);
7fe9b0b7 410
8c8317a5 411 // convert to bitstream if necessary
e0165dcf 412 ChkBitstream(Cmd);
7fe9b0b7 413
2767fc02 414 //can send only 512 bits at a time (1 byte sent per bit...)
e0165dcf 415 printf("Sending [%d bytes]", GraphTraceLen);
416 for (i = 0; i < GraphTraceLen; i += USB_CMD_DATA_SIZE) {
8c8317a5 417 UsbCommand c = {CMD_DOWNLOADED_SIM_SAMPLES_125K, {i, 0, 0}};
52ab55ab 418
e0165dcf 419 for (j = 0; j < USB_CMD_DATA_SIZE; j++) {
420 c.d.asBytes[j] = GraphBuffer[i+j];
421 }
422 SendCommand(&c);
423 WaitForResponse(CMD_ACK,NULL);
424 printf(".");
425 }
7fe9b0b7 426
e0165dcf 427 printf("\n");
428 PrintAndLog("Starting to simulate");
429 UsbCommand c = {CMD_SIMULATE_TAG_125K, {GraphTraceLen, gap, 0}};
709665b5 430 clearCommandBuffer();
e0165dcf 431 SendCommand(&c);
432 return 0;
7fe9b0b7 433}
434
abd6112f 435int usage_lf_simfsk(void)
436{
e0165dcf 437 //print help
438 PrintAndLog("Usage: lf simfsk [c <clock>] [i] [H <fcHigh>] [L <fcLow>] [d <hexdata>]");
439 PrintAndLog("Options: ");
440 PrintAndLog(" h This help");
441 PrintAndLog(" c <clock> Manually set clock - can autodetect if using DemodBuffer");
442 PrintAndLog(" i invert data");
443 PrintAndLog(" H <fcHigh> Manually set the larger Field Clock");
444 PrintAndLog(" L <fcLow> Manually set the smaller Field Clock");
445 //PrintAndLog(" s TBD- -to enable a gap between playback repetitions - default: no gap");
446 PrintAndLog(" d <hexdata> Data to sim as hex - omit to sim from DemodBuffer");
447 PrintAndLog("\n NOTE: if you set one clock manually set them all manually");
448 return 0;
abd6112f 449}
450
451int usage_lf_simask(void)
452{
e0165dcf 453 //print help
454 PrintAndLog("Usage: lf simask [c <clock>] [i] [b|m|r] [s] [d <raw hex to sim>]");
455 PrintAndLog("Options: ");
456 PrintAndLog(" h This help");
457 PrintAndLog(" c <clock> Manually set clock - can autodetect if using DemodBuffer");
458 PrintAndLog(" i invert data");
459 PrintAndLog(" b sim ask/biphase");
460 PrintAndLog(" m sim ask/manchester - Default");
461 PrintAndLog(" r sim ask/raw");
29ada8fc 462 PrintAndLog(" s add t55xx Sequence Terminator gap - default: no gaps (only manchester)");
e0165dcf 463 PrintAndLog(" d <hexdata> Data to sim as hex - omit to sim from DemodBuffer");
464 return 0;
abd6112f 465}
466
872e3d4d 467int usage_lf_simpsk(void)
468{
e0165dcf 469 //print help
470 PrintAndLog("Usage: lf simpsk [1|2|3] [c <clock>] [i] [r <carrier>] [d <raw hex to sim>]");
471 PrintAndLog("Options: ");
472 PrintAndLog(" h This help");
473 PrintAndLog(" c <clock> Manually set clock - can autodetect if using DemodBuffer");
474 PrintAndLog(" i invert data");
475 PrintAndLog(" 1 set PSK1 (default)");
476 PrintAndLog(" 2 set PSK2");
477 PrintAndLog(" 3 set PSK3");
478 PrintAndLog(" r <carrier> 2|4|8 are valid carriers: default = 2");
479 PrintAndLog(" d <hexdata> Data to sim as hex - omit to sim from DemodBuffer");
480 return 0;
872e3d4d 481}
712ebfa6 482
f86d6b55 483// by marshmellow - sim fsk data given clock, fcHigh, fcLow, invert
abd6112f 484// - allow pull data from DemodBuffer
485int CmdLFfskSim(const char *Cmd)
486{
2767fc02 487 //might be able to autodetect FCs and clock from Graphbuffer if using demod buffer
488 // otherwise will need FChigh, FClow, Clock, and bitstream
e0165dcf 489 uint8_t fcHigh=0, fcLow=0, clk=0;
490 uint8_t invert=0;
7cb8516c 491 bool errors = false;
874572d4 492 char hexData[64] = {0x00}; // store entered hex data
e0165dcf 493 uint8_t data[255] = {0x00};
494 int dataLen = 0;
495 uint8_t cmdp = 0;
496 while(param_getchar(Cmd, cmdp) != 0x00)
497 {
498 switch(param_getchar(Cmd, cmdp))
499 {
500 case 'h':
501 return usage_lf_simfsk();
502 case 'i':
503 invert = 1;
504 cmdp++;
505 break;
506 case 'c':
507 errors |= param_getdec(Cmd,cmdp+1,&clk);
508 cmdp+=2;
509 break;
510 case 'H':
511 errors |= param_getdec(Cmd,cmdp+1,&fcHigh);
512 cmdp+=2;
513 break;
514 case 'L':
515 errors |= param_getdec(Cmd,cmdp+1,&fcLow);
516 cmdp+=2;
517 break;
518 //case 's':
519 // separator=1;
520 // cmdp++;
521 // break;
522 case 'd':
874572d4 523 dataLen = param_getstr(Cmd, cmdp+1, hexData, sizeof(hexData));
e0165dcf 524 if (dataLen==0) {
7cb8516c 525 errors=true;
e0165dcf 526 } else {
527 dataLen = hextobinarray((char *)data, hexData);
528 }
7cb8516c 529 if (dataLen==0) errors=true;
e0165dcf 530 if (errors) PrintAndLog ("Error getting hex data");
531 cmdp+=2;
532 break;
533 default:
534 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
7cb8516c 535 errors = true;
e0165dcf 536 break;
537 }
538 if(errors) break;
539 }
540 if(cmdp == 0 && DemodBufferLen == 0)
541 {
7cb8516c 542 errors = true;// No args
e0165dcf 543 }
544
545 //Validations
546 if(errors)
547 {
548 return usage_lf_simfsk();
549 }
0f321d63 550 int firstClockEdge = 0;
e0165dcf 551 if (dataLen == 0){ //using DemodBuffer
552 if (clk==0 || fcHigh==0 || fcLow==0){ //manual settings must set them all
0f321d63 553 uint8_t ans = fskClocks(&fcHigh, &fcLow, &clk, 0, &firstClockEdge);
e0165dcf 554 if (ans==0){
555 if (!fcHigh) fcHigh=10;
556 if (!fcLow) fcLow=8;
557 if (!clk) clk=50;
558 }
559 }
560 } else {
561 setDemodBuf(data, dataLen, 0);
562 }
2767fc02 563
564 //default if not found
e0165dcf 565 if (clk == 0) clk = 50;
566 if (fcHigh == 0) fcHigh = 10;
567 if (fcLow == 0) fcLow = 8;
568
569 uint16_t arg1, arg2;
570 arg1 = fcHigh << 8 | fcLow;
571 arg2 = invert << 8 | clk;
572 size_t size = DemodBufferLen;
573 if (size > USB_CMD_DATA_SIZE) {
574 PrintAndLog("DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
575 size = USB_CMD_DATA_SIZE;
576 }
577 UsbCommand c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}};
578
579 memcpy(c.d.asBytes, DemodBuffer, size);
709665b5 580 clearCommandBuffer();
e0165dcf 581 SendCommand(&c);
582 return 0;
abd6112f 583}
584
585// by marshmellow - sim ask data given clock, invert, manchester or raw, separator
586// - allow pull data from DemodBuffer
587int CmdLFaskSim(const char *Cmd)
588{
e0165dcf 589 //autodetect clock from Graphbuffer if using demod buffer
2767fc02 590 // needs clock, invert, manchester/raw as m or r, separator as s, and bitstream
e0165dcf 591 uint8_t encoding = 1, separator = 0;
e0165dcf 592 uint8_t clk=0, invert=0;
7cb8516c 593 bool errors = false;
874572d4 594 char hexData[64] = {0x00};
e0165dcf 595 uint8_t data[255]= {0x00}; // store entered hex data
596 int dataLen = 0;
597 uint8_t cmdp = 0;
598 while(param_getchar(Cmd, cmdp) != 0x00)
599 {
600 switch(param_getchar(Cmd, cmdp))
601 {
602 case 'h':
603 return usage_lf_simask();
604 case 'i':
605 invert = 1;
606 cmdp++;
607 break;
608 case 'c':
609 errors |= param_getdec(Cmd,cmdp+1,&clk);
610 cmdp+=2;
611 break;
612 case 'b':
613 encoding=2; //biphase
614 cmdp++;
615 break;
616 case 'm':
617 encoding=1;
618 cmdp++;
619 break;
620 case 'r':
621 encoding=0;
622 cmdp++;
623 break;
624 case 's':
625 separator=1;
626 cmdp++;
627 break;
628 case 'd':
874572d4 629 dataLen = param_getstr(Cmd, cmdp+1, hexData, sizeof(hexData));
e0165dcf 630 if (dataLen==0) {
7cb8516c 631 errors=true;
e0165dcf 632 } else {
633 dataLen = hextobinarray((char *)data, hexData);
634 }
7cb8516c 635 if (dataLen==0) errors=true;
e0165dcf 636 if (errors) PrintAndLog ("Error getting hex data, datalen: %d",dataLen);
637 cmdp+=2;
638 break;
639 default:
640 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
7cb8516c 641 errors = true;
e0165dcf 642 break;
643 }
644 if(errors) break;
645 }
646 if(cmdp == 0 && DemodBufferLen == 0)
647 {
7cb8516c 648 errors = true;// No args
e0165dcf 649 }
650
651 //Validations
652 if(errors)
653 {
654 return usage_lf_simask();
655 }
656 if (dataLen == 0){ //using DemodBuffer
657 if (clk == 0) clk = GetAskClock("0", false, false);
658 } else {
659 setDemodBuf(data, dataLen, 0);
660 }
661 if (clk == 0) clk = 64;
662 if (encoding == 0) clk = clk/2; //askraw needs to double the clock speed
663 uint16_t arg1, arg2;
664 size_t size=DemodBufferLen;
665 arg1 = clk << 8 | encoding;
666 arg2 = invert << 8 | separator;
667 if (size > USB_CMD_DATA_SIZE) {
668 PrintAndLog("DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
669 size = USB_CMD_DATA_SIZE;
670 }
671 UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}};
672 PrintAndLog("preparing to sim ask data: %d bits", size);
673 memcpy(c.d.asBytes, DemodBuffer, size);
709665b5 674 clearCommandBuffer();
e0165dcf 675 SendCommand(&c);
676 return 0;
abd6112f 677}
678
872e3d4d 679// by marshmellow - sim psk data given carrier, clock, invert
680// - allow pull data from DemodBuffer or parameters
681int CmdLFpskSim(const char *Cmd)
682{
e0165dcf 683 //might be able to autodetect FC and clock from Graphbuffer if using demod buffer
684 //will need carrier, Clock, and bitstream
685 uint8_t carrier=0, clk=0;
686 uint8_t invert=0;
7cb8516c 687 bool errors = false;
874572d4 688 char hexData[64] = {0x00}; // store entered hex data
e0165dcf 689 uint8_t data[255] = {0x00};
690 int dataLen = 0;
691 uint8_t cmdp = 0;
692 uint8_t pskType = 1;
693 while(param_getchar(Cmd, cmdp) != 0x00)
694 {
695 switch(param_getchar(Cmd, cmdp))
696 {
697 case 'h':
698 return usage_lf_simpsk();
699 case 'i':
700 invert = 1;
701 cmdp++;
702 break;
703 case 'c':
704 errors |= param_getdec(Cmd,cmdp+1,&clk);
705 cmdp+=2;
706 break;
707 case 'r':
708 errors |= param_getdec(Cmd,cmdp+1,&carrier);
709 cmdp+=2;
710 break;
711 case '1':
712 pskType=1;
713 cmdp++;
714 break;
715 case '2':
716 pskType=2;
717 cmdp++;
718 break;
719 case '3':
720 pskType=3;
721 cmdp++;
722 break;
723 case 'd':
874572d4 724 dataLen = param_getstr(Cmd, cmdp+1, hexData, sizeof(hexData));
e0165dcf 725 if (dataLen==0) {
7cb8516c 726 errors=true;
e0165dcf 727 } else {
728 dataLen = hextobinarray((char *)data, hexData);
729 }
7cb8516c 730 if (dataLen==0) errors=true;
e0165dcf 731 if (errors) PrintAndLog ("Error getting hex data");
732 cmdp+=2;
733 break;
734 default:
735 PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
7cb8516c 736 errors = true;
e0165dcf 737 break;
738 }
739 if (errors) break;
740 }
741 if (cmdp == 0 && DemodBufferLen == 0)
742 {
7cb8516c 743 errors = true;// No args
e0165dcf 744 }
745
746 //Validations
747 if (errors)
748 {
749 return usage_lf_simpsk();
750 }
751 if (dataLen == 0){ //using DemodBuffer
752 PrintAndLog("Getting Clocks");
7cb8516c 753 if (clk==0) clk = GetPskClock("", false, false);
e0165dcf 754 PrintAndLog("clk: %d",clk);
7cb8516c 755 if (!carrier) carrier = GetPskCarrier("", false, false);
e0165dcf 756 PrintAndLog("carrier: %d", carrier);
757 } else {
758 setDemodBuf(data, dataLen, 0);
759 }
760
761 if (clk <= 0) clk = 32;
762 if (carrier == 0) carrier = 2;
763 if (pskType != 1){
764 if (pskType == 2){
765 //need to convert psk2 to psk1 data before sim
766 psk2TOpsk1(DemodBuffer, DemodBufferLen);
767 } else {
768 PrintAndLog("Sorry, PSK3 not yet available");
769 }
770 }
771 uint16_t arg1, arg2;
772 arg1 = clk << 8 | carrier;
773 arg2 = invert;
774 size_t size=DemodBufferLen;
775 if (size > USB_CMD_DATA_SIZE) {
776 PrintAndLog("DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
777 size=USB_CMD_DATA_SIZE;
778 }
779 UsbCommand c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}};
780 PrintAndLog("DEBUG: Sending DemodBuffer Length: %d", size);
781 memcpy(c.d.asBytes, DemodBuffer, size);
709665b5 782 clearCommandBuffer();
e0165dcf 783 SendCommand(&c);
784
785 return 0;
872e3d4d 786}
abd6112f 787
7fe9b0b7 788int CmdLFSimBidir(const char *Cmd)
789{
e0165dcf 790 // Set ADC to twice the carrier for a slight supersampling
791 // HACK: not implemented in ARMSRC.
792 PrintAndLog("Not implemented yet.");
793 UsbCommand c = {CMD_LF_SIMULATE_BIDIR, {47, 384, 0}};
794 SendCommand(&c);
795 return 0;
7fe9b0b7 796}
797
7fe9b0b7 798int CmdVchDemod(const char *Cmd)
799{
e0165dcf 800 // Is this the entire sync pattern, or does this also include some
801 // data bits that happen to be the same everywhere? That would be
802 // lovely to know.
803 static const int SyncPattern[] = {
804 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
805 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
806 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
807 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
808 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
809 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
810 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
811 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
812 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
813 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
814 };
815
816 // So first, we correlate for the sync pattern, and mark that.
817 int bestCorrel = 0, bestPos = 0;
818 int i;
819 // It does us no good to find the sync pattern, with fewer than
820 // 2048 samples after it...
821 for (i = 0; i < (GraphTraceLen-2048); i++) {
822 int sum = 0;
823 int j;
824 for (j = 0; j < arraylen(SyncPattern); j++) {
825 sum += GraphBuffer[i+j]*SyncPattern[j];
826 }
827 if (sum > bestCorrel) {
828 bestCorrel = sum;
829 bestPos = i;
830 }
831 }
832 PrintAndLog("best sync at %d [metric %d]", bestPos, bestCorrel);
833
834 char bits[257];
835 bits[256] = '\0';
836
837 int worst = INT_MAX;
838 int worstPos = 0;
839
840 for (i = 0; i < 2048; i += 8) {
841 int sum = 0;
842 int j;
843 for (j = 0; j < 8; j++) {
844 sum += GraphBuffer[bestPos+i+j];
845 }
846 if (sum < 0) {
847 bits[i/8] = '.';
848 } else {
849 bits[i/8] = '1';
850 }
851 if(abs(sum) < worst) {
852 worst = abs(sum);
853 worstPos = i;
854 }
855 }
856 PrintAndLog("bits:");
857 PrintAndLog("%s", bits);
858 PrintAndLog("worst metric: %d at pos %d", worst, worstPos);
859
860 if (strcmp(Cmd, "clone")==0) {
861 GraphTraceLen = 0;
862 char *s;
863 for(s = bits; *s; s++) {
864 int j;
865 for(j = 0; j < 16; j++) {
866 GraphBuffer[GraphTraceLen++] = (*s == '1') ? 1 : 0;
867 }
868 }
869 RepaintGraphWindow();
870 }
871 return 0;
7fe9b0b7 872}
873
d0b05864 874
875//by marshmellow
876int CheckChipType(char cmdp) {
877 uint32_t wordData = 0;
878
61aaee35 879 if (IsOffline() || cmdp == '1') return 0;
537f80f2 880
3fd7fce4 881 save_restoreGB(GRAPH_SAVE);
882 save_restoreDB(GRAPH_SAVE);
537f80f2 883 //check for em4x05/em4x69 chips first
884 if (EM4x05Block0Test(&wordData)) {
d0b05864 885 PrintAndLog("\nValid EM4x05/EM4x69 Chip Found\nTry lf em 4x05... commands\n");
3fd7fce4 886 save_restoreGB(GRAPH_RESTORE);
887 save_restoreDB(GRAPH_RESTORE);
d0b05864 888 return 1;
889 }
890
537f80f2 891 //check for t55xx chip...
892 if (tryDetectP1(true)) {
b97311b1 893 PrintAndLog("\nValid T55xx Chip Found\nTry lf t55xx ... commands\n");
3fd7fce4 894 save_restoreGB(GRAPH_RESTORE);
895 save_restoreDB(GRAPH_RESTORE);
b97311b1 896 return 1;
897 }
3fd7fce4 898 save_restoreGB(GRAPH_RESTORE);
899 save_restoreDB(GRAPH_RESTORE);
b97311b1 900 return 0;
d0b05864 901}
902
d5a72d2f 903//by marshmellow
904int CmdLFfind(const char *Cmd)
905{
d0b05864 906 uint32_t wordData = 0;
e0165dcf 907 int ans=0;
e04475c4 908 size_t minLength = 1000;
e0165dcf 909 char cmdp = param_getchar(Cmd, 0);
910 char testRaw = param_getchar(Cmd, 1);
911 if (strlen(Cmd) > 3 || cmdp == 'h' || cmdp == 'H') {
912 PrintAndLog("Usage: lf search <0|1> [u]");
913 PrintAndLog(" <use data from Graphbuffer> , if not set, try reading data from tag.");
914 PrintAndLog(" [Search for Unknown tags] , if not set, reads only known tags.");
915 PrintAndLog("");
916 PrintAndLog(" sample: lf search = try reading data from tag & search for known tags");
917 PrintAndLog(" : lf search 1 = use data from GraphBuffer & search for known tags");
918 PrintAndLog(" : lf search u = try reading data from tag & search for known and unknown tags");
919 PrintAndLog(" : lf search 1 u = use data from GraphBuffer & search for known and unknown tags");
920
921 return 0;
922 }
923
61aaee35 924 if (!IsOffline() && (cmdp != '1')) {
b9957414 925 lf_read(true, 30000);
e04475c4 926 } else if (GraphTraceLen < minLength) {
e0165dcf 927 PrintAndLog("Data in Graphbuffer was too small.");
928 return 0;
929 }
930 if (cmdp == 'u' || cmdp == 'U') testRaw = 'u';
931
932 PrintAndLog("NOTE: some demods output possible binary\n if it finds something that looks like a tag");
933 PrintAndLog("False Positives ARE possible\n");
934 PrintAndLog("\nChecking for known tags:\n");
935
e04475c4 936 size_t testLen = minLength;
937 // only run if graphbuffer is just noise as it should be for hitag/cotag
938 if (graphJustNoise(GraphBuffer, testLen)) {
939 // only run these tests if we are in online mode
61aaee35 940 if (!IsOffline() && (cmdp != '1')) {
d0b05864 941 // test for em4x05 in reader talk first mode.
942 if (EM4x05Block0Test(&wordData)) {
943 PrintAndLog("\nValid EM4x05/EM4x69 Chip Found\nUse lf em 4x05readword/dump commands to read\n");
944 return 1;
945 }
217cfb6b 946 ans=CmdLFHitagReader("26"); // 26 = RHT2F_UID_ONLY
e04475c4 947 if (ans==0) {
948 return 1;
949 }
950 ans=CmdCOTAGRead("");
b97311b1 951 if (ans>0) {
e04475c4 952 PrintAndLog("\nValid COTAG ID Found!");
953 return 1;
954 }
955 }
a468b427 956 PrintAndLog("\nNo Data Found! - maybe not an LF tag?\n");
e04475c4 957 return 0;
958 }
959
b97311b1 960 // TODO test for modulation then only test formats that use that modulation
961
e0165dcf 962 ans=CmdFSKdemodIO("");
963 if (ans>0) {
964 PrintAndLog("\nValid IO Prox ID Found!");
d0b05864 965 return CheckChipType(cmdp);
e0165dcf 966 }
967
968 ans=CmdFSKdemodPyramid("");
969 if (ans>0) {
970 PrintAndLog("\nValid Pyramid ID Found!");
d0b05864 971 return CheckChipType(cmdp);
e0165dcf 972 }
973
974 ans=CmdFSKdemodParadox("");
975 if (ans>0) {
976 PrintAndLog("\nValid Paradox ID Found!");
d0b05864 977 return CheckChipType(cmdp);
e0165dcf 978 }
979
980 ans=CmdFSKdemodAWID("");
981 if (ans>0) {
982 PrintAndLog("\nValid AWID ID Found!");
d0b05864 983 return CheckChipType(cmdp);
e0165dcf 984 }
985
986 ans=CmdFSKdemodHID("");
987 if (ans>0) {
988 PrintAndLog("\nValid HID Prox ID Found!");
d0b05864 989 return CheckChipType(cmdp);
e0165dcf 990 }
991
e0165dcf 992 ans=CmdAskEM410xDemod("");
993 if (ans>0) {
994 PrintAndLog("\nValid EM410x ID Found!");
d0b05864 995 return CheckChipType(cmdp);
e0165dcf 996 }
997
8b6abef5 998 ans=CmdVisa2kDemod("");
999 if (ans>0) {
1000 PrintAndLog("\nValid Visa2000 ID Found!");
1001 return CheckChipType(cmdp);
1002 }
1003
e0165dcf 1004 ans=CmdG_Prox_II_Demod("");
1005 if (ans>0) {
1006 PrintAndLog("\nValid G Prox II ID Found!");
d0b05864 1007 return CheckChipType(cmdp);
e0165dcf 1008 }
1009
b97311b1 1010 ans=CmdFdxDemod(""); //biphase
ecfcb34c 1011 if (ans>0) {
1012 PrintAndLog("\nValid FDX-B ID Found!");
d0b05864 1013 return CheckChipType(cmdp);
ecfcb34c 1014 }
1015
b97311b1 1016 ans=EM4x50Read("", false); //ask
23f0a7d8 1017 if (ans>0) {
1018 PrintAndLog("\nValid EM4x50 ID Found!");
1019 return 1;
a9968da3 1020 }
1021
1022 ans=CmdJablotronDemod("");
1023 if (ans>0) {
1024 PrintAndLog("\nValid Jablotron ID Found!");
1025 return CheckChipType(cmdp);
1026 }
1027
1028 ans=CmdNoralsyDemod("");
1029 if (ans>0) {
1030 PrintAndLog("\nValid Noralsy ID Found!");
1031 return CheckChipType(cmdp);
1032 }
411105e0 1033
c3caf040 1034 ans=CmdSecurakeyDemod("");
1035 if (ans>0) {
1036 PrintAndLog("\nValid Securakey ID Found!");
1037 return CheckChipType(cmdp);
1038 }
1039
415274a7 1040 ans=CmdVikingDemod("");
1041 if (ans>0) {
1042 PrintAndLog("\nValid Viking ID Found!");
d0b05864 1043 return CheckChipType(cmdp);
a9968da3 1044 }
415274a7 1045
b97311b1 1046 ans=CmdIndalaDecode(""); //psk
6fe5c94b 1047 if (ans>0) {
1048 PrintAndLog("\nValid Indala ID Found!");
d0b05864 1049 return CheckChipType(cmdp);
6fe5c94b 1050 }
1051
411105e0 1052 ans=CmdPSKNexWatch("");
1053 if (ans>0) {
1054 PrintAndLog("\nValid NexWatch ID Found!");
d0b05864 1055 return CheckChipType(cmdp);
411105e0 1056 }
1057
69f42a05 1058 ans=CmdPacDemod("");
1059 if (ans>0) {
1060 PrintAndLog("\nValid PAC/Stanley ID Found!");
1061 return CheckChipType(cmdp);
1062 }
1063
e0165dcf 1064 PrintAndLog("\nNo Known Tags Found!\n");
b97311b1 1065 if (testRaw=='u' || testRaw=='U') {
3fd7fce4 1066 //ans=CheckChipType(cmdp);
d0b05864 1067 //test unknown tag formats (raw mode)0
e0165dcf 1068 PrintAndLog("\nChecking for Unknown tags:\n");
c4f51073 1069 ans=AutoCorrelate(GraphBuffer, GraphBuffer, GraphTraceLen, 4000, false, false);
e0165dcf 1070 if (ans > 0) PrintAndLog("Possible Auto Correlation of %d repeating samples",ans);
7cb8516c 1071 ans=GetFskClock("",false,false);
b97311b1 1072 if (ans != 0) { //fsk
7cb8516c 1073 ans=FSKrawDemod("",true);
e0165dcf 1074 if (ans>0) {
1075 PrintAndLog("\nUnknown FSK Modulated Tag Found!");
f516ff08 1076 return CheckChipType(cmdp);
e0165dcf 1077 }
1078 }
7cb8516c 1079 bool st = true;
1080 ans=ASKDemod_ext("0 0 0",true,false,1,&st);
e0165dcf 1081 if (ans>0) {
1082 PrintAndLog("\nUnknown ASK Modulated and Manchester encoded Tag Found!");
1083 PrintAndLog("\nif it does not look right it could instead be ASK/Biphase - try 'data rawdemod ab'");
f516ff08 1084 return CheckChipType(cmdp);
e0165dcf 1085 }
1086 ans=CmdPSK1rawDemod("");
1087 if (ans>0) {
1088 PrintAndLog("Possible unknown PSK1 Modulated Tag Found above!\n\nCould also be PSK2 - try 'data rawdemod p2'");
1089 PrintAndLog("\nCould also be PSK3 - [currently not supported]");
0e2ddb41 1090 PrintAndLog("\nCould also be NRZ - try 'data rawdemod nr'");
f516ff08 1091 return CheckChipType(cmdp);
e0165dcf 1092 }
f1004b34 1093 ans = CheckChipType(cmdp);
e0165dcf 1094 PrintAndLog("\nNo Data Found!\n");
1095 }
1096 return 0;
d5a72d2f 1097}
1098
7fe9b0b7 1099static command_t CommandTable[] =
1100{
e0165dcf 1101 {"help", CmdHelp, 1, "This help"},
9b99a6db 1102 {"awid", CmdLFAWID, 1, "{ AWID RFIDs... }"},
1103 {"cotag", CmdLFCOTAG, 1, "{ COTAG CHIPs... }"},
1104 {"em", CmdLFEM4X, 1, "{ EM4X CHIPs & RFIDs... }"},
1105 {"fdx", CmdLFFdx, 1, "{ FDX-B RFIDs... }"},
1106 {"gproxii", CmdLF_G_Prox_II, 1, "{ G Prox II RFIDs... }"},
1107 {"hid", CmdLFHID, 1, "{ HID RFIDs... }"},
1108 {"hitag", CmdLFHitag, 1, "{ Hitag CHIPs... }"},
1109 {"io", CmdLFIO, 1, "{ ioProx RFIDs... }"},
1110 {"indala", CmdLFINDALA, 1, "{ Indala RFIDs... }"},
a9968da3 1111 {"jablotron", CmdLFJablotron, 1, "{ Jablotron RFIDs... }"},
5bce72d5 1112 {"nexwatch", CmdLFNexWatch, 1, "{ NexWatch RFIDs... }"},
a9968da3 1113 {"noralsy", CmdLFNoralsy, 1, "{ Noralsy RFIDs... }"},
69f42a05 1114 {"pac", CmdLFPac, 1, "{ PAC/Stanley RFIDs... }"},
5bce72d5 1115 {"paradox", CmdLFParadox, 1, "{ Paradox RFIDs... }"},
9b99a6db 1116 {"presco", CmdLFPresco, 1, "{ Presco RFIDs... }"},
1117 {"pcf7931", CmdLFPCF7931, 1, "{ PCF7931 CHIPs... }"},
6923d3f1 1118 {"pyramid", CmdLFPyramid, 1, "{ Farpointe/Pyramid RFIDs... }"},
c3caf040 1119 {"securakey", CmdLFSecurakey, 1, "{ Securakey RFIDs... }"},
9b99a6db 1120 {"t55xx", CmdLFT55XX, 1, "{ T55xx CHIPs... }"},
1121 {"ti", CmdLFTI, 1, "{ TI CHIPs... }"},
1122 {"viking", CmdLFViking, 1, "{ Viking RFIDs... }"},
1123 {"visa2000", CmdLFVisa2k, 1, "{ Visa2000 RFIDs... }"},
21a615cb 1124 {"cmdread", CmdLFCommandRead, 0, "<d period> <z period> <o period> <c command> ['H'] -- Modulate LF reader field to send command before read (all periods in microseconds) (option 'H' for 134)"},
e0165dcf 1125 {"config", CmdLFSetConfig, 0, "Set config for LF sampling, bit/sample, decimation, frequency"},
1126 {"flexdemod", CmdFlexdemod, 1, "Demodulate samples for FlexPass"},
e0165dcf 1127 {"read", CmdLFRead, 0, "['s' silent] Read 125/134 kHz LF ID-only tag. Do 'lf read h' for help"},
1128 {"search", CmdLFfind, 1, "[offline] ['u'] Read and Search for valid known tag (in offline mode it you can load first then search) - 'u' to search for unknown tags"},
1129 {"sim", CmdLFSim, 0, "[GAP] -- Simulate LF tag from buffer with optional GAP (in microseconds)"},
aa53efc3 1130 {"simask", CmdLFaskSim, 0, "[clock] [invert <1|0>] [biphase/manchester/raw <'b'|'m'|'r'>] [msg separator 's'] [d <hexdata>] -- Simulate LF ASK tag from demodbuffer or input"},
e0165dcf 1131 {"simfsk", CmdLFfskSim, 0, "[c <clock>] [i] [H <fcHigh>] [L <fcLow>] [d <hexdata>] -- Simulate LF FSK tag from demodbuffer or input"},
1132 {"simpsk", CmdLFpskSim, 0, "[1|2|3] [c <clock>] [i] [r <carrier>] [d <raw hex to sim>] -- Simulate LF PSK tag from demodbuffer or input"},
1133 {"simbidir", CmdLFSimBidir, 0, "Simulate LF tag (with bidirectional data transmission between reader and tag)"},
e0165dcf 1134 {"snoop", CmdLFSnoop, 0, "['l'|'h'|<divisor>] [trigger threshold]-- Snoop LF (l:125khz, h:134khz)"},
e0165dcf 1135 {"vchdemod", CmdVchDemod, 1, "['clone'] -- Demodulate samples for VeriChip"},
e0165dcf 1136 {NULL, NULL, 0, NULL}
7fe9b0b7 1137};
1138
1139int CmdLF(const char *Cmd)
1140{
e0165dcf 1141 CmdsParse(CommandTable, Cmd);
1142 return 0;
7fe9b0b7 1143}
1144
1145int CmdHelp(const char *Cmd)
1146{
e0165dcf 1147 CmdsHelp(CommandTable);
1148 return 0;
7fe9b0b7 1149}
Impressum, Datenschutz