-int CmdHFList(const char *Cmd)
-{
- bool showWaitCycles = false;
- bool markCRCBytes = false;
- bool loadFromFile = false;
- bool PCSCtrace = false;
- bool saveToFile = false;
- char param1 = '\0';
- char param2 = '\0';
- char param3 = '\0';
- char param4 = '\0';
- char type[40] = {0};
- char filename[FILE_PATH_SIZE] = {0};
- uint8_t protocol = 0;
-
- // parse command line
- int tlen = param_getstr(Cmd, 0, type, sizeof(type));
- if (param_getlength(Cmd, 1) == 1) {
- param1 = param_getchar(Cmd, 1);
- } else {
- param_getstr(Cmd, 1, filename, sizeof(filename));
- }
- if (param_getlength(Cmd, 2) == 1) {
- param2 = param_getchar(Cmd, 2);
- } else if (strlen(filename) == 0) {
- param_getstr(Cmd, 2, filename, sizeof(filename));
- }
- if (param_getlength(Cmd, 3) == 1) {
- param3 = param_getchar(Cmd, 3);
- } else if (strlen(filename) == 0) {
- param_getstr(Cmd, 3, filename, sizeof(filename));
- }
- if (param_getlength(Cmd, 4) == 1) {
- param4 = param_getchar(Cmd, 4);
- } else if (strlen(filename) == 0) {
- param_getstr(Cmd, 4, filename, sizeof(filename));
- }
-
- // Validate params
- bool errors = false;
-
- if(tlen == 0) {
- errors = true;
- }
-
- if(param1 == 'h'
- || (param1 != 0 && param1 != 'f' && param1 != 'c' && param1 != 'l' && param1 != 'p')
- || (param2 != 0 && param2 != 'f' && param2 != 'c' && param2 != 'l' && param1 != 'p')
- || (param3 != 0 && param3 != 'f' && param3 != 'c' && param3 != 'l' && param1 != 'p')
- || (param4 != 0 && param4 != 'f' && param4 != 'c' && param4 != 'l' && param4 != 'p')) {
- errors = true;
- }
-
- if(!errors) {
- if (strcmp(type, "iclass") == 0) protocol = ICLASS;
- else if(strcmp(type, "14a") == 0) protocol = ISO_14443A;
- else if(strcmp(type, "mf") == 0) protocol = PROTO_MIFARE;
- else if(strcmp(type, "14b") == 0) protocol = ISO_14443B;
- else if(strcmp(type, "topaz") == 0) protocol = TOPAZ;
- else if(strcmp(type, "7816") == 0) protocol = ISO_7816_4;
- else if(strcmp(type, "14-4") == 0) protocol = ISO_14443_4;
- else if(strcmp(type, "15") == 0) protocol = ISO_15693;
- else if(strcmp(type, "raw") == 0) protocol = -1;//No crc, no annotations
- else if (strcmp(type, "save") == 0) saveToFile = true;
- else errors = true;
- }
-
- if (param1 == 'f' || param2 == 'f' || param3 == 'f' || param4 == 'f') {
- showWaitCycles = true;
- }
+int CmdHFList(const char *Cmd) {
+
+ CLIParserInit("hf list", "\nList or save protocol data.",
+ "examples: hf list 14a -f -- interpret as ISO14443A communication and display Frame Delay Times\n"\
+ " hf list iclass -- interpret as iClass trace\n"\
+ " hf list -s myCardTrace.trc -- save trace for later use\n"\
+ " hf list 14a -l myCardTrace.trc -- load trace and interpret as ISO14443A communication\n");
+ void* argtable[] = {
+ arg_param_begin,
+ arg_lit0("f", "fdt", "display fdt (frame delay times)"),
+ arg_lit0("r", "relative", "show relative times (gap and duration)"),
+ arg_lit0("c", "crc" , "mark CRC bytes"),
+ arg_lit0("p", "pcsc", "show trace buffer from PCSC card reader instead of PM3"),
+ arg_str0("l", "load", "<filename>", "load trace from file"),
+ arg_str0("s", "save", "<filename>", "save trace to file"),
+ arg_lit0("u", "us", "display times in microseconds instead of clock cycles"),
+ arg_str0(NULL, NULL, "<protocol>", "protocol to interpret. Possible values:\n"\
+ "\traw - just show raw data without annotations (default)\n"\
+ "\t14a - interpret data as ISO14443A communications\n"\
+ "\tmf - interpret data as ISO14443A communications and decrypt Mifare Crypto1 stream\n"\
+ "\t14b - interpret data as ISO14443B communications\n"\
+ "\t15 - interpret data as ISO15693 communications\n"\
+ "\ticlass - interpret data as iClass communications\n"\
+ "\ttopaz - interpret data as Topaz communications\n"\
+ "\t7816 - interpret data as 7816-4 APDU communications\n"\
+ "\t14-4 - interpret data as ISO14443-4 communications"),
+ arg_param_end
+ };