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