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