From 21a615cb3bd9142902017135b33be42248f36a33 Mon Sep 17 00:00:00 2001 From: marshmellow42 Date: Sat, 17 Oct 2015 10:48:54 -0400 Subject: [PATCH] begin update lf commands with help text and cmd structure. update changelog for recent changes --- CHANGELOG.md | 4 ++ armsrc/apps.h | 2 +- armsrc/lfops.c | 2 +- client/cmdlf.c | 100 +++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 91 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a489c981..21292088 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Added `data hex2bin` and `data bin2hex` for command line conversion between binary and hexadecimal (holiman) ### Changed +- added lf t5xx read with password safety check and warning text +- Adjusted LF FSK demod to account for cross threshold fluctuations (898 count waves will adjust the 9 to 8 now...) more accurate. +- Adjusted timings for t55xx commands. more reliable now. +- `lf cmdread` adjusted input methods and added help text (marshmellow & iceman) - changed `lf config t ` to be 0 - 128 and will trigger on + or - threshold value (marshmellow) - `hf iclass dump` cli options - can now dump AA1 and AA2 with different keys in one run (does not go to muliple pages for the larger tags yet) - Revised workflow for StandAloneMode14a (Craig Young) diff --git a/armsrc/apps.h b/armsrc/apps.h index d1286b48..aaace18b 100644 --- a/armsrc/apps.h +++ b/armsrc/apps.h @@ -58,7 +58,7 @@ extern uint8_t bits_per_sample ; extern bool averaging; void AcquireRawAdcSamples125k(int divisor); -void ModThenAcquireRawAdcSamples125k(int delay_off,int period_0,int period_1,uint8_t *command); +void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint32_t period_1, uint8_t *command); void ReadTItag(void); void WriteTItag(uint32_t idhi, uint32_t idlo, uint16_t crc); diff --git a/armsrc/lfops.c b/armsrc/lfops.c index 9f3d9ab3..cf04c31b 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -25,7 +25,7 @@ * @param period_1 * @param command */ -void ModThenAcquireRawAdcSamples125k(int delay_off, int period_0, int period_1, uint8_t *command) +void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint32_t period_1, uint8_t *command) { int divisor_used = 95; // 125 KHz diff --git a/client/cmdlf.c b/client/cmdlf.c index edf6c3a9..6b8a31b2 100644 --- a/client/cmdlf.c +++ b/client/cmdlf.c @@ -33,17 +33,82 @@ static int CmdHelp(const char *Cmd); + + +int usage_lf_cmdread() +{ + PrintAndLog("Usage: lf cmdread d z o c [H] "); + PrintAndLog("Options: "); + PrintAndLog(" h This help"); + PrintAndLog(" L Low frequency (125 KHz)"); + PrintAndLog(" H High frequency (134 KHz)"); + PrintAndLog(" d delay OFF period"); + PrintAndLog(" z time period ZERO"); + PrintAndLog(" o time period ONE"); + PrintAndLog(" c Command bytes"); + PrintAndLog(" ************* All periods in microseconds"); + 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; +} + /* send a command before reading */ int CmdLFCommandRead(const char *Cmd) { - static char dummy[3]; - - dummy[0]= ' '; - + static char dummy[3] = {0x20,0x00,0x00}; UsbCommand c = {CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K}; - sscanf(Cmd, "%"lli" %"lli" %"lli" %s %s", &c.arg[0], &c.arg[1], &c.arg[2],(char*)(&c.d.asBytes),(char*)(&dummy+1)); - // in case they specified 'h' + bool errors = FALSE; + //uint8_t divisor = 95; //125khz + uint8_t cmdp = 0; + int strLength = 0; + while(param_getchar(Cmd, cmdp) != 0x00) + { + switch(param_getchar(Cmd, cmdp)) + { + case 'h': + return usage_lf_cmdread(); + case 'H': + //divisor = 88; + dummy[1]='h'; + cmdp++; + break; + case 'L': + cmdp++; + break; + case 'c': + strLength = 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': + c.arg[1] = param_get32ex(Cmd, cmdp+1, 0, 10); + cmdp+=2; + break; + case 'o': + c.arg[2] = param_get32ex(Cmd, cmdp+1, 0, 10); + cmdp+=2; + break; + default: + PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp)); + errors = 1; + break; + } + if(errors) break; + } + // No args + if(cmdp == 0) errors = 1; + + //Validations + if(errors) return usage_lf_cmdread(); + + // in case they specified 'H' strcpy((char *)&c.d.asBytes + strlen((char *)c.d.asBytes), dummy); + + clearCommandBuffer(); SendCommand(&c); return 0; } @@ -493,7 +558,12 @@ int CmdLFRead(const char *Cmd) //And ship it to device UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_125K, {arg1,0,0}}; SendCommand(&c); - WaitForResponse(CMD_ACK,NULL); + //WaitForResponse(CMD_ACK,NULL); + if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) { + PrintAndLog("command execution time out"); + return 1; + } + return 0; } @@ -1126,13 +1196,17 @@ int CmdLFfind(const char *Cmd) static command_t CommandTable[] = { {"help", CmdHelp, 1, "This help"}, - {"cmdread", CmdLFCommandRead, 0, " <'0' period> <'1' period> ['h'] -- Modulate LF reader field to send command before read (all periods in microseconds) (option 'h' for 134)"}, + {"awid", CmdLFAWID, 1, "{ AWID RFIDs... }"}, {"em4x", CmdLFEM4X, 1, "{ EM4X RFIDs... }"}, + {"hid", CmdLFHID, 1, "{ HID RFIDs... }"}, + {"hitag", CmdLFHitag, 1, "{ Hitag tags and transponders... }"}, + {"io", CmdLFIO, 1, "{ ioProx tags... }"}, + {"pcf7931", CmdLFPCF7931, 1, "{ PCF7931 RFIDs... }"}, + {"t55xx", CmdLFT55XX, 1, "{ T55xx RFIDs... }"}, + {"ti", CmdLFTI, 1, "{ TI RFIDs... }"}, + {"cmdread", CmdLFCommandRead, 0, " ['H'] -- Modulate LF reader field to send command before read (all periods in microseconds) (option 'H' for 134)"}, {"config", CmdLFSetConfig, 0, "Set config for LF sampling, bit/sample, decimation, frequency"}, {"flexdemod", CmdFlexdemod, 1, "Demodulate samples for FlexPass"}, - {"hid", CmdLFHID, 1, "{ HID RFIDs... }"}, - {"awid", CmdLFAWID, 1, "{ AWID RFIDs... }"}, - {"io", CmdLFIO, 1, "{ ioProx tags... }"}, {"indalademod", CmdIndalaDemod, 1, "['224'] -- Demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"}, {"indalaclone", CmdIndalaClone, 0, " ['l']-- Clone Indala to T55x7 (tag must be in antenna)(UID in HEX)(option 'l' for 224 UID"}, {"read", CmdLFRead, 0, "['s' silent] Read 125/134 kHz LF ID-only tag. Do 'lf read h' for help"}, @@ -1143,11 +1217,7 @@ static command_t CommandTable[] = {"simpsk", CmdLFpskSim, 0, "[1|2|3] [c ] [i] [r ] [d ] -- Simulate LF PSK tag from demodbuffer or input"}, {"simbidir", CmdLFSimBidir, 0, "Simulate LF tag (with bidirectional data transmission between reader and tag)"}, {"snoop", CmdLFSnoop, 0, "['l'|'h'|] [trigger threshold]-- Snoop LF (l:125khz, h:134khz)"}, - {"ti", CmdLFTI, 1, "{ TI RFIDs... }"}, - {"hitag", CmdLFHitag, 1, "{ Hitag tags and transponders... }"}, {"vchdemod", CmdVchDemod, 1, "['clone'] -- Demodulate samples for VeriChip"}, - {"t55xx", CmdLFT55XX, 1, "{ T55xx RFIDs... }"}, - {"pcf7931", CmdLFPCF7931, 1, "{PCF7931 RFIDs...}"}, {NULL, NULL, 0, NULL} }; -- 2.39.2