// is the order in which they go out on the wire.\r
//=============================================================================\r
\r
-BYTE ToSend[256];\r
+BYTE ToSend[512];\r
int ToSendMax;\r
static int ToSendBit;\r
struct common_area common_area __attribute__((section(".commonarea")));\r
void BufferClear(void)\r
{\r
memset(BigBuf,0,sizeof(BigBuf));\r
- DbpString("Buffer cleared");\r
+ Dbprintf("Buffer cleared (%i bytes)",sizeof(BigBuf));\r
}\r
\r
void ToSendReset(void)\r
case CMD_DOWNLOADED_SIM_SAMPLES_125K: {\r
BYTE *b = (BYTE *)BigBuf;\r
memcpy(b+c->arg[0], c->d.asBytes, 48);\r
+ //Dbprintf("copied 48 bytes to %i",b+c->arg[0]);\r
break;\r
}\r
\r
#ifdef WITH_LF\r
case CMD_SIMULATE_TAG_125K:\r
LED_A_ON();\r
- SimulateTagLowFrequency(c->arg[0], 1);\r
+ SimulateTagLowFrequency(c->arg[0], c->arg[1], 1);\r
LED_A_OFF();\r
break;\r
#endif\r
}\r
break;\r
default:\r
- DbpString("unknown command");\r
+ Dbprintf("%s: 0x%04x","unknown command:",c->cmd);\r
break;\r
}\r
}\r
void WriteTItag(DWORD idhi, DWORD idlo, WORD crc);\r
void AcquireTiType(void);\r
void AcquireRawBitsTI(void);\r
-void SimulateTagLowFrequency(int period, int ledcontrol);\r
+void SimulateTagLowFrequency(int period, int gap, int ledcontrol);\r
void CmdHIDsimTAG(int hi, int lo, int ledcontrol);\r
void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol);\r
void SimulateTagLowFrequencyBidir(int divisor, int max_bitlen);\r
static void CmdEM410xsim(char *str)\r
{\r
int i, n, j, h, binary[4], parity[4];\r
- char *s = "0";\r
\r
/* clock is 64 in EM410x tags */\r
int clock = 64;\r
}\r
\r
/* modulate that biatch */\r
- Cmdmanchestermod(s);\r
+ Cmdmanchestermod("");\r
\r
/* booyah! */\r
RepaintGraphWindow();\r
+ \r
+ CmdLosim("");\r
+}\r
+\r
+/* simulate an LF Manchester encoded tag with specified bitstream, clock rate and inter-id gap */\r
+static void CmdLosimManchester(char *str)\r
+{\r
+ static int clock, gap;\r
+ static char data[1024], gapstring[8];\r
+ int i;\r
\r
- CmdLosim(s);\r
+ /* get settings/bits */\r
+ sscanf(str, "%i %s %i", &clock, &data[0], &gap);\r
+\r
+ /* clear our graph */\r
+ CmdClearGraph(0);\r
+\r
+ /* fill it with our bitstream */\r
+ for (i= 0; i < strlen(data) ; ++i)\r
+ CmdAppendGraph(0, clock, data[i]- '0');\r
+\r
+ /* modulate */\r
+ Cmdmanchestermod("");\r
+\r
+ /* show what we've done */\r
+ RepaintGraphWindow();\r
+\r
+ /* simulate */\r
+ sprintf(&gapstring[0], "%i", gap);\r
+ CmdLosim(gapstring);\r
}\r
\r
static void ChkBitstream(char *str)\r
static void CmdLosim(char *str)\r
{\r
int i;\r
+ static int gap;\r
+\r
+ sscanf(str,"%i",&gap);\r
\r
/* convert to bitstream if necessary */\r
ChkBitstream(str);\r
SendCommand(&c);\r
}\r
\r
- UsbCommand c={CMD_SIMULATE_TAG_125K, {GraphTraceLen, 0, 0}};\r
+ UsbCommand c={CMD_SIMULATE_TAG_125K, {GraphTraceLen, gap, 0}};\r
SendCommand(&c);\r
}\r
\r
{"hi15sim", CmdHi15tag, 0, "Fake an ISO15693 tag"},\r
{"hidsimtag", CmdHIDsimTAG, 0, "<ID> -- HID tag simulator"},\r
{"hisimlisten", CmdHisimlisten, 0, "Get HF samples as fake tag"},\r
- {"losim", CmdLosim, 0, "Simulate LF tag"},\r
+ {"losim", CmdLosim, 0, "[GAP] -- Simulate LF tag from buffer with optional GAP (in microseconds)"},\r
+ {"losimman", CmdLosimManchester, 0, "<Clock> <Bitstream> [GAP] Simulate arbitrary Manchester LF tag"},\r
{"losimbidir", CmdLosimBidir, 0, "Simulate LF tag (with bidirectional data transmission between reader and tag)"},\r
\r
/* card reading functions */\r
void CommandReceived(char *cmd)\r
{\r
int i;\r
- char line[256];\r
+ char line[512];\r
\r
PrintToScrollback("> %s", cmd);\r
\r