- }
- char *crc = crcError ? "!crc" :" ";
-
- EndOfTransmissionTimestamp = timestamp + duration;
-
- if(!isResponse)
- {
- if(iclass)
- annotateIclass(explanation,sizeof(explanation),frame,data_len);
- else
- annotateIso14443a(explanation,sizeof(explanation),frame,data_len);
- }
-
- int num_lines = (data_len - 1)/16 + 1;
- for (int j = 0; j < num_lines; j++) {
- if (j == 0) {
- PrintAndLog(" %9d | %9d | %s | %-64s| %s| %s",
- (timestamp - first_timestamp),
- (EndOfTransmissionTimestamp - first_timestamp),
- (isResponse ? "Tag" : "Rdr"),
- line[j],
- (j == num_lines-1) ? crc : " ",
- (j == num_lines-1) ? explanation : "");
- } else {
- PrintAndLog(" | | | %-64s| %s| %s",
- line[j],
- (j == num_lines-1)?crc:" ",
- (j == num_lines-1) ? explanation : "");
- }
- }
-
- bool next_isResponse = *((uint16_t *)(trace + tracepos + 6)) & 0x8000;
-
- if (showWaitCycles && !isResponse && next_isResponse) {
- uint32_t next_timestamp = *((uint32_t *)(trace + tracepos));
- if (next_timestamp != 0x44444444) {
- PrintAndLog(" %9d | %9d | %s | fdt (Frame Delay Time): %d",
- (EndOfTransmissionTimestamp - first_timestamp),
- (next_timestamp - first_timestamp),
- " ",
- (next_timestamp - EndOfTransmissionTimestamp));
- }
- }
- return tracepos;
-}
-
-int CmdHFList(const char *Cmd)
-{
- bool showWaitCycles = false;
- char type[40] = {0};
- int tlen = param_getstr(Cmd,0,type);
- char param = param_getchar(Cmd, 1);
- bool errors = false;
- bool iclass = false;
- //Validate params
- if(tlen == 0 || (strcmp(type, "iclass") != 0 && strcmp(type,"14a") != 0))
- {
- errors = true;
- }
- if(param == 'h' || (param !=0 && param != 'f'))
- {
- errors = true;
- }
-
- if (errors) {
- PrintAndLog("List protocol data in trace buffer.");
- PrintAndLog("Usage: hf list [14a|iclass] [f]");
- PrintAndLog(" 14a - interpret data as iso14443a communications");
- PrintAndLog(" iclass - interpret data as iclass communications");
- PrintAndLog(" f - show frame delay times as well");
- PrintAndLog("");
- PrintAndLog("example: hf list 14a f");
- PrintAndLog("example: hf list iclass");
- return 0;
- }
- if(strcmp(type, "iclass") == 0)
- {
- iclass = true;
- }
-
- if (param == 'f') {
- showWaitCycles = true;
- }
-
-
- uint8_t trace[TRACE_SIZE];
- uint16_t tracepos = 0;
- GetFromBigBuf(trace, TRACE_SIZE, 0);
- WaitForResponse(CMD_ACK, NULL);
-
- PrintAndLog("Recorded Activity");
- PrintAndLog("");
- PrintAndLog("Start = Start of Start Bit, End = End of last modulation. Src = Source of Transfer");
- PrintAndLog("iso14443a - All times are in carrier periods (1/13.56Mhz)");
- PrintAndLog("iClass - Timings are not as accurate");
- PrintAndLog("");
- PrintAndLog(" Start | End | Src | Data (! denotes parity error) | CRC | Annotation |");
- PrintAndLog("-----------|-----------|-----|-----------------------------------------------------------------|-----|--------------------|");
-
- while(tracepos < TRACE_SIZE)
- {
- tracepos = printTraceLine(tracepos, trace, iclass, showWaitCycles);