void __attribute__((noreturn)) AppMain(void)
{
SpinDelay(100);
-
+ clear_trace();
if(common_area.magic != COMMON_AREA_MAGIC || common_area.version != 1) {
/* Initialize common area */
memset(&common_area, 0, sizeof(common_area));
int max = 0;
int gotFrame = FALSE;
-//# define DMA_BUFFER_SIZE 8
- int8_t *dmaBuf;
-
int lastRxCounter;
- int8_t *upTo;
int ci, cq;
int samples = 0;
// Clear out the state of the "UART" that receives from the tag.
- memset(BigBuf, 0x00, 400);
- Demod.output = (uint8_t *)BigBuf;
+ memset(Demod.output, 0x00, MAX_FRAME_SIZE);
+ Demod.output = ((uint8_t *)BigBuf) + RECV_RESP_OFFSET;
Demod.len = 0;
Demod.state = DEMOD_UNSYNCD;
// And the UART that receives from the reader
- Uart.output = (((uint8_t *)BigBuf) + 1024);
- Uart.byteCntMax = 100;
+ Uart.output = ((uint8_t *)BigBuf) + RECV_CMD_OFFSET;
+ Uart.byteCntMax = MAX_FRAME_SIZE;
Uart.state = STATE_UNSYNCD;
- // Setup for the DMA.
- dmaBuf = (int8_t *)(BigBuf + 32);
- upTo = dmaBuf;
+ // The DMA buffer, used to stream samples from the FPGA
+ int8_t *dmaBuf = ((int8_t *)BigBuf) + DMA_BUFFER_OFFSET;
+ int8_t *upTo= dmaBuf;
lastRxCounter = DEMOD_DMA_BUFFER_SIZE;
FpgaSetupSscDma((uint8_t *)dmaBuf, DEMOD_DMA_BUFFER_SIZE);
#include "mifareutil.h"
static uint32_t iso14a_timeout;
-uint8_t *trace = (uint8_t *) BigBuf+TRACE_OFFSET;
int rsamples = 0;
-int traceLen = 0;
-int tracing = TRUE;
uint8_t trigger = 0;
// the block number for the ISO14443-4 PCB
static uint8_t iso14_pcb_blocknum = 0;
#include "string.h"
#include "apps.h"
+uint8_t *trace = (uint8_t *) BigBuf+TRACE_OFFSET;
+int traceLen = 0;
+int tracing = TRUE;
void print_result(char *name, uint8_t *buf, size_t len) {
tracing = FALSE; // don't trace any more
return FALSE;
}
-
// Traceformat:
// 32 bits timestamp (little endian)
// 16 bits duration (little endian)
}
traceLen += num_paritybytes;
+ if(traceLen +4 < TRACE_SIZE)
+ { //If it hadn't been cleared, for whatever reason..
+ memset(trace+traceLen,0x44, 4);
+ }
+
return TRUE;
}
if (tracepos + data_len + parity_len >= TRACE_SIZE) {
return TRACE_SIZE;
}
-
uint8_t *frame = trace + tracepos;
tracepos += data_len;
uint8_t *parityBytes = trace + tracepos;
tracepos += parity_len;
+
//--- Draw the data column
+ //char line[16][110];
char line[16][110];
- for (int j = 0; j < data_len; j++) {
+
+ for (int j = 0; j < data_len && j/16 < 16; j++) {
+
int oddparity = 0x01;
int k;
}
uint8_t parityBits = parityBytes[j>>3];
-
if (isResponse && (oddparity != ((parityBits >> (7-(j&0x0007))) & 0x01))) {
- sprintf(line[j/16]+((j%16)*4), "%02x! ", frame[j]);
+ snprintf(line[j/16]+(( j % 16) * 4),110, "%02x! ", frame[j]);
+
} else {
- sprintf(line[j/16]+((j%16)*4), "%02x ", frame[j]);
+ snprintf(line[j/16]+(( j % 16) * 4),110, "%02x! ", frame[j]);
+ }
+ }
+ if(data_len == 0)
+ {
+ if(data_len == 0){
+ sprintf(line[0],"<empty trace - possible error>");
}
}
//--- Draw the CRC column
annotateIso14443b(explanation,sizeof(explanation),frame,data_len);
}
- int num_lines = (data_len - 1)/16 + 1;
- for (int j = 0; j < num_lines; j++) {
+ int num_lines = MIN((data_len - 1)/16 + 1, 16);
+ for (int j = 0; j < num_lines ; j++) {
if (j == 0) {
PrintAndLog(" %9d | %9d | %s | %-64s| %s| %s",
(timestamp - first_timestamp),
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");