- // strip
- while (*cmd==' ' || *cmd=='\t') cmd++;
-
- while (cmd[i]!='\0') {
- if (cmd[i]==' ' || cmd[i]=='\t') { i++; continue; }
- if (cmd[i]=='-') {
- switch (cmd[i+1]) {
- case 'r':
- reply = false;
- break;
- case 'c':
- crc = true;
- break;
- case 'p':
- power = true;
- break;
- case 'a':
- active = true;
- break;
- case 's':
- active_select = true;
- break;
- case 'b':
- sscanf(cmd+i+2,"%d",&temp);
- numbits = temp & 0xFFFF;
- i+=3;
- while(cmd[i]!=' ' && cmd[i]!='\0') { i++; }
- i-=2;
- break;
- case 't':
- bTimeout = true;
- sscanf(cmd+i+2,"%d",&temp);
- timeout = temp;
- i+=3;
- while(cmd[i]!=' ' && cmd[i]!='\0') { i++; }
- i-=2;
- break;
- case 'T':
- topazmode = true;
- break;
- case '3':
- no_rats = true;
- break;
- default:
- PrintAndLog("Invalid option");
- return 0;
- }
- i+=2;
- continue;
- }
- if ((cmd[i]>='0' && cmd[i]<='9') ||
- (cmd[i]>='a' && cmd[i]<='f') ||
- (cmd[i]>='A' && cmd[i]<='F') ) {
- buf[strlen(buf)+1]=0;
- buf[strlen(buf)]=cmd[i];
- i++;
-
- if (strlen(buf)>=2) {
- sscanf(buf,"%x",&temp);
- data[datalen]=(uint8_t)(temp & 0xff);
- *buf=0;
- if (datalen > sizeof(data)-1) {
- if (crc)
- PrintAndLog("Buffer is full, we can't add CRC to your data");
- break;
- } else {
- datalen++;
- }
- }
- continue;
- }
- PrintAndLog("Invalid char on input");
+ // extract parameters
+ CLIParserInit("hf 14a raw", "Send raw hex data to tag",
+ "Sample:\n"\
+ "\thf 14a raw -pa -b7 -t1000 52 -- execute WUPA\n"\
+ "\thf 14a raw -p 9320 -- anticollision\n"\
+ "\thf 14a raw -psc 60 00 -- select and mifare AUTH\n");
+ void* argtable[] = {
+ arg_param_begin,
+ arg_lit0("rR", "nreply", "do not read response"),
+ arg_lit0("cC", "crc", "calculate and append CRC"),
+ arg_lit0("pP", "power", "leave the signal field ON after receive"),
+ arg_lit0("aA", "active", "active signal field ON without select"),
+ arg_lit0("sS", "actives", "active signal field ON with select"),
+ arg_int0("bB", "bits", NULL, "number of bits to send. Useful for send partial byte"),
+ arg_int0("t", "timeout", NULL, "timeout in ms"),
+ arg_lit0("T", "topaz", "use Topaz protocol to send command"),
+ arg_lit0("3", NULL, "ISO14443-3 select only (skip RATS)"),
+ arg_strx1(NULL, NULL, "<data (hex)>", NULL),
+ arg_param_end
+ };
+ // defaults
+ arg_get_int(6) = 0;
+ arg_get_int(7) = 0;
+
+ if (CLIParserParseString(cmd, argtable, arg_getsize(argtable), false)){
+ CLIParserFree();