+int usage_lf_cmdread(void) {
+ PrintAndLog("Usage: lf cmdread d <delay period> z <zero period> o <one period> c <cmdbytes> [H]");
+ PrintAndLog("Options:");
+ PrintAndLog(" h This help");
+ PrintAndLog(" L Low frequency (125 KHz)");
+ PrintAndLog(" H High frequency (134 KHz)");
+ PrintAndLog(" d <delay> delay OFF period, (decimal)");
+ PrintAndLog(" z <zero> time period ZERO, (decimal)");
+ PrintAndLog(" o <one> time period ONE, (decimal)");
+ PrintAndLog(" c <cmd> Command bytes (in ones and zeros)");
+ PrintAndLog(" ************* All periods in microseconds (ms)");
+ PrintAndLog("Examples:");
+ PrintAndLog(" lf cmdread d 80 z 100 o 200 c 11000");
+ PrintAndLog(" lf cmdread d 80 z 100 o 100 c 11000 H");
+ return 0;
+}
+int usage_lf_read(void){
+ PrintAndLog("Usage: lf read [h] [s]");
+ PrintAndLog("Options:");
+ PrintAndLog(" h This help");
+ PrintAndLog(" s silent run no printout");
+ PrintAndLog("Use 'lf config' to set parameters.");
+ return 0;
+}
+int usage_lf_snoop(void) {
+ PrintAndLog("Snoop low frequence signal. Use 'lf config' to set parameters.");
+ PrintAndLog("Usage: lf snoop [h]");
+ PrintAndLog("Options:");
+ PrintAndLog(" h This help");
+ return 0;
+}
+int usage_lf_config(void) {
+ PrintAndLog("Usage: lf config [h] [H|<divisor>] [b <bps>] [d <decim>] [a 0|1]");
+ PrintAndLog("Options:");
+ PrintAndLog(" h This help");
+ PrintAndLog(" L Low frequency (125 KHz)");
+ PrintAndLog(" H High frequency (134 KHz)");
+ PrintAndLog(" q <divisor> Manually set divisor. 88-> 134KHz, 95-> 125 Hz");
+ PrintAndLog(" b <bps> Sets resolution of bits per sample. Default (max): 8");
+ PrintAndLog(" d <decim> Sets decimation. A value of N saves only 1 in N samples. Default: 1");
+ PrintAndLog(" a [0|1] Averaging - if set, will average the stored sample value when decimating. Default: 1");
+ PrintAndLog(" t <threshold> Sets trigger threshold. 0 means no threshold (range: 0-128)");
+ PrintAndLog("Examples:");
+ PrintAndLog(" lf config b 8 L");
+ PrintAndLog(" Samples at 125KHz, 8bps.");
+ PrintAndLog(" lf config H b 4 d 3");
+ PrintAndLog(" Samples at 134KHz, averages three samples into one, stored with ");
+ PrintAndLog(" a resolution of 4 bits per sample.");
+ PrintAndLog(" lf read");
+ PrintAndLog(" Performs a read (active field)");
+ PrintAndLog(" lf snoop");
+ PrintAndLog(" Performs a snoop (no active field)");
+ return 0;
+}
+int usage_lf_simfsk(void) {
+ PrintAndLog("Usage: lf simfsk [c <clock>] [i] [H <fcHigh>] [L <fcLow>] [d <hexdata>]");
+ PrintAndLog("Options:");
+ PrintAndLog(" h This help");
+ PrintAndLog(" c <clock> Manually set clock - can autodetect if using DemodBuffer");
+ PrintAndLog(" i invert data");
+ PrintAndLog(" H <fcHigh> Manually set the larger Field Clock");
+ PrintAndLog(" L <fcLow> Manually set the smaller Field Clock");
+ //PrintAndLog(" s TBD- -to enable a gap between playback repetitions - default: no gap");
+ PrintAndLog(" d <hexdata> Data to sim as hex - omit to sim from DemodBuffer");
+ PrintAndLog("\n NOTE: if you set one clock manually set them all manually");
+ return 0;
+}
+int usage_lf_simask(void) {
+ PrintAndLog("Usage: lf simask [c <clock>] [i] [b|m|r] [s] [d <raw hex to sim>]");
+ PrintAndLog("Options:");
+ PrintAndLog(" h This help");
+ PrintAndLog(" c <clock> Manually set clock - can autodetect if using DemodBuffer");
+ PrintAndLog(" i invert data");
+ PrintAndLog(" b sim ask/biphase");
+ PrintAndLog(" m sim ask/manchester - Default");
+ PrintAndLog(" r sim ask/raw");
+ PrintAndLog(" s add t55xx Sequence Terminator gap - default: no gaps (only manchester)");
+ PrintAndLog(" d <hexdata> Data to sim as hex - omit to sim from DemodBuffer");
+ return 0;
+}
+int usage_lf_simpsk(void) {
+ PrintAndLog("Usage: lf simpsk [1|2|3] [c <clock>] [i] [r <carrier>] [d <raw hex to sim>]");
+ PrintAndLog("Options:");
+ PrintAndLog(" h This help");
+ PrintAndLog(" c <clock> Manually set clock - can autodetect if using DemodBuffer");
+ PrintAndLog(" i invert data");
+ PrintAndLog(" 1 set PSK1 (default)");
+ PrintAndLog(" 2 set PSK2");
+ PrintAndLog(" 3 set PSK3");
+ PrintAndLog(" r <carrier> 2|4|8 are valid carriers: default = 2");
+ PrintAndLog(" d <hexdata> Data to sim as hex - omit to sim from DemodBuffer");
+ return 0;
+}
+int usage_lf_find(void){
+ PrintAndLog("Usage: lf search [h] <0|1> [u]");
+ PrintAndLog("");
+ PrintAndLog("Options:");
+ PrintAndLog(" h This help");
+ PrintAndLog(" <0|1> Use data from Graphbuffer, if not set, try reading data from tag.");
+ PrintAndLog(" u Search for Unknown tags, if not set, reads only known tags.");
+ PrintAndLog("Examples:");
+ PrintAndLog(" lf search = try reading data from tag & search for known tags");
+ PrintAndLog(" lf search 1 = use data from GraphBuffer & search for known tags");
+ PrintAndLog(" lf search u = try reading data from tag & search for known and unknown tags");
+ PrintAndLog(" lf search 1 u = use data from GraphBuffer & search for known and unknown tags");
+ return 0;
+}
+
+
+/* send a LF command before reading */
+int CmdLFCommandRead(const char *Cmd) {
+
+ bool errors = FALSE;
+ bool useHighFreq = FALSE;
+ uint16_t one = 0, zero = 0;
+ uint8_t cmdp = 0;
+ UsbCommand c = {CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, {0,0,0}};
+
+ while(param_getchar(Cmd, cmdp) != 0x00) {
+ switch(param_getchar(Cmd, cmdp)) {
+ case 'h':
+ return usage_lf_cmdread();
+ case 'H':
+ useHighFreq = TRUE;
+ cmdp++;
+ break;
+ case 'L':
+ cmdp++;
+ break;
+ case 'c':
+ param_getstr(Cmd, cmdp+1, (char *)&c.d.asBytes);
+ cmdp+=2;
+ break;
+ case 'd':
+ c.arg[0] = param_get32ex(Cmd, cmdp+1, 0, 10);
+ cmdp+=2;
+ break;
+ case 'z':
+ zero = param_get32ex(Cmd, cmdp+1, 0, 10) & 0xFFFF;
+ cmdp+=2;
+ break;
+ case 'o':
+ one = param_get32ex(Cmd, cmdp+1, 0, 10) & 0xFFFF;
+ cmdp+=2;
+ break;
+ default:
+ PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));
+ errors = 1;
+ break;
+ }
+ if(errors) break;
+ }
+ // No args
+ if (cmdp == 0) errors = TRUE;