]>
Commit | Line | Data |
---|---|---|
1 | //-----------------------------------------------------------------------------\r | |
2 | //\r | |
3 | // This code is licensed to you under the terms of the GNU GPL, version 2 or,\r | |
4 | // at your option, any later version. See the LICENSE.txt file for the text of\r | |
5 | // the license.\r | |
6 | //-----------------------------------------------------------------------------\r | |
7 | // Low frequency T55xx commands\r | |
8 | //-----------------------------------------------------------------------------\r | |
9 | \r | |
10 | #include <stdio.h>\r | |
11 | #include <string.h>\r | |
12 | #include <inttypes.h>\r | |
13 | #include "proxmark3.h"\r | |
14 | #include "ui.h"\r | |
15 | #include "graph.h"\r | |
16 | #include "cmdmain.h"\r | |
17 | #include "cmdparser.h"\r | |
18 | #include "cmddata.h"\r | |
19 | #include "cmdlf.h"\r | |
20 | #include "cmdlft55xx.h"\r | |
21 | #include "util.h"\r | |
22 | #include "data.h"\r | |
23 | #include "lfdemod.h"\r | |
24 | \r | |
25 | #define LF_TRACE_BUFF_SIZE 20000 // 32 x 32 x 10 (32 bit times numofblock (7), times clock skip..)\r | |
26 | #define LF_BITSSTREAM_LEN 1000 // more then 1000 bits shouldn't happend.. 8block * 4 bytes * 8bits = \r | |
27 | \r | |
28 | int usage_t55xx_rd(){\r | |
29 | PrintAndLog("Usage: lf t55xx rd <block> <password>");\r | |
30 | PrintAndLog(" <block>, block number to read. Between 0-7");\r | |
31 | PrintAndLog(" <password>, OPTIONAL password (8 hex characters)");\r | |
32 | PrintAndLog("");\r | |
33 | PrintAndLog(" sample: lf t55xx rd 0 = try reading data from block 0");\r | |
34 | PrintAndLog(" : lf t55xx rd 0 feedbeef = try reading data from block 0 using password");\r | |
35 | PrintAndLog("");\r | |
36 | return 0;\r | |
37 | }\r | |
38 | int usage_t55xx_wr(){\r | |
39 | PrintAndLog("Usage: lf t55xx wr <block> <data> [password]");\r | |
40 | PrintAndLog(" <block>, block number to read. Between 0-7");\r | |
41 | PrintAndLog(" <data>, 4 bytes of data to write (8 hex characters)");\r | |
42 | PrintAndLog(" [password], OPTIONAL password 4bytes (8 hex characters)");\r | |
43 | PrintAndLog("");\r | |
44 | PrintAndLog(" sample: lf t55xx wd 3 11223344 = try writing data 11223344 to block 3");\r | |
45 | PrintAndLog(" : lf t55xx wd 3 11223344 feedbeef = try writing data 11223344 to block 3 using password feedbeef");\r | |
46 | PrintAndLog("");\r | |
47 | return 0;\r | |
48 | }\r | |
49 | int usage_t55xx_trace() {\r | |
50 | PrintAndLog("Usage: lf t55xx trace [graph buffer data]");\r | |
51 | PrintAndLog(" [graph buffer data], if set, use Graphbuffer otherwise read data from tag.");\r | |
52 | PrintAndLog("");\r | |
53 | PrintAndLog(" sample: lf t55xx trace");\r | |
54 | PrintAndLog(" : lf t55xx trace 1");\r | |
55 | PrintAndLog("");\r | |
56 | return 0;\r | |
57 | }\r | |
58 | int usage_t55xx_info() {\r | |
59 | PrintAndLog("Usage: lf t55xx info [graph buffer data]");\r | |
60 | PrintAndLog(" [graph buffer data], if set, use Graphbuffer otherwise read data from tag.");\r | |
61 | PrintAndLog("");\r | |
62 | PrintAndLog(" sample: lf t55xx info");\r | |
63 | PrintAndLog(" : lf t55xx info 1");\r | |
64 | PrintAndLog("");\r | |
65 | return 0;\r | |
66 | }\r | |
67 | \r | |
68 | int usage_t55xx_dump(){\r | |
69 | PrintAndLog("Usage: lf t55xx dump <password>");\r | |
70 | PrintAndLog(" <password>, OPTIONAL password 4bytes (8 hex characters)");\r | |
71 | PrintAndLog("");\r | |
72 | PrintAndLog(" sample: lf t55xx dump");\r | |
73 | PrintAndLog(" : lf t55xx dump feedbeef");\r | |
74 | PrintAndLog("");\r | |
75 | return 0;\r | |
76 | }\r | |
77 | static int CmdHelp(const char *Cmd);\r | |
78 | \r | |
79 | int CmdReadBlk(const char *Cmd)\r | |
80 | {\r | |
81 | int invert = 0;\r | |
82 | int clk = 0;\r | |
83 | int block = -1;\r | |
84 | int password = 0xFFFFFFFF; //default to blank Block 7\r | |
85 | int errCnt;\r | |
86 | size_t bitlen;\r | |
87 | int maxErr = 100;\r | |
88 | uint8_t askAmp = 0;\r | |
89 | uint32_t blockData;\r | |
90 | uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0x00};\r | |
91 | \r | |
92 | \r | |
93 | char cmdp = param_getchar(Cmd, 0);\r | |
94 | if (cmdp == 'h' || cmdp == 'H') {\r | |
95 | usage_t55xx_rd();\r | |
96 | return 0;\r | |
97 | }\r | |
98 | \r | |
99 | int res = sscanf(Cmd, "%d %x", &block, &password);\r | |
100 | \r | |
101 | if ( res < 1 || res > 2 ){\r | |
102 | usage_t55xx_rd();\r | |
103 | return 1;\r | |
104 | }\r | |
105 | \r | |
106 | if ((block < 0) | (block > 7)) {\r | |
107 | PrintAndLog("Block must be between 0 and 7");\r | |
108 | return 1;\r | |
109 | } \r | |
110 | \r | |
111 | UsbCommand c = {CMD_T55XX_READ_BLOCK, {0, block, 0}};\r | |
112 | c.d.asBytes[0] = 0x0; \r | |
113 | \r | |
114 | //Password mode\r | |
115 | if ( res == 2 ) {\r | |
116 | c.arg[2] = password;\r | |
117 | c.d.asBytes[0] = 0x1; \r | |
118 | }\r | |
119 | \r | |
120 | SendCommand(&c);\r | |
121 | if ( !WaitForResponseTimeout(CMD_ACK,NULL,1500) ) {\r | |
122 | PrintAndLog("command execution time out");\r | |
123 | return 2;\r | |
124 | }\r | |
125 | \r | |
126 | CmdSamples("12000");\r | |
127 | \r | |
128 | bitlen = getFromGraphBuf(bits);\r | |
129 | \r | |
130 | errCnt = askrawdemod(bits, &bitlen, &clk, &invert, maxErr, askAmp);\r | |
131 | \r | |
132 | //throw away static - allow 1 and -1 (in case of threshold command first)\r | |
133 | if ( errCnt == -1 || bitlen < 16 ){ \r | |
134 | PrintAndLog("no data found");\r | |
135 | if (g_debugMode) \r | |
136 | PrintAndLog("errCnt: %d, bitlen: %d, clk: %d, invert: %d", errCnt, bitlen, clk, invert);\r | |
137 | return 3;\r | |
138 | }\r | |
139 | if (g_debugMode) \r | |
140 | PrintAndLog("Using Clock: %d - invert: %d - Bits Found: %d", clk, invert, bitlen);\r | |
141 | \r | |
142 | //move bits back to DemodBuffer\r | |
143 | setDemodBuf(bits, bitlen, 0);\r | |
144 | printBitStream(bits,bitlen);\r | |
145 | \r | |
146 | // bits has the manchester encoded data.\r | |
147 | errCnt = manrawdecode(bits, &bitlen); \r | |
148 | if ( errCnt == -1 || bitlen < 16 ){ \r | |
149 | PrintAndLog("no data found");\r | |
150 | if (g_debugMode) \r | |
151 | PrintAndLog("errCnt: %d, bitlen: %d, clk: %d, invert: %d", errCnt, bitlen, clk, invert);\r | |
152 | return 4;\r | |
153 | }\r | |
154 | \r | |
155 | blockData = PackBits(0, 32, bits);\r | |
156 | \r | |
157 | if ( block < 0)\r | |
158 | PrintAndLog(" Decoded : 0x%08X %s", blockData, sprint_bin(bits,32) );\r | |
159 | else\r | |
160 | PrintAndLog(" Block %d : 0x%08X %s", block, blockData, sprint_bin(bits,32) );\r | |
161 | \r | |
162 | return 0;\r | |
163 | }\r | |
164 | \r | |
165 | int CmdWriteBlk(const char *Cmd)\r | |
166 | {\r | |
167 | int block = 8; //default to invalid block\r | |
168 | int data = 0xFFFFFFFF; //default to blank Block \r | |
169 | int password = 0xFFFFFFFF; //default to blank Block 7\r | |
170 | \r | |
171 | char cmdp = param_getchar(Cmd, 0);\r | |
172 | if (cmdp == 'h' || cmdp == 'H') {\r | |
173 | usage_t55xx_wr();\r | |
174 | return 0;\r | |
175 | }\r | |
176 | \r | |
177 | int res = sscanf(Cmd, "%d %x %x",&block, &data, &password);\r | |
178 | \r | |
179 | if ( res < 2 || res > 3) {\r | |
180 | usage_t55xx_wr();\r | |
181 | return 1;\r | |
182 | }\r | |
183 | \r | |
184 | if (block > 7) {\r | |
185 | PrintAndLog("Block must be between 0 and 7");\r | |
186 | return 1;\r | |
187 | }\r | |
188 | \r | |
189 | UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}};\r | |
190 | c.d.asBytes[0] = 0x0; \r | |
191 | \r | |
192 | if (res == 2) {\r | |
193 | PrintAndLog("Writing block %d data %08X", block, data);\r | |
194 | } else {\r | |
195 | //Password mode\r | |
196 | c.arg[2] = password;\r | |
197 | c.d.asBytes[0] = 0x1; \r | |
198 | PrintAndLog("Writing block %d data %08X password %08X", block, data, password);\r | |
199 | }\r | |
200 | \r | |
201 | SendCommand(&c);\r | |
202 | return 0;\r | |
203 | }\r | |
204 | \r | |
205 | int CmdReadTrace(const char *Cmd)\r | |
206 | {\r | |
207 | char cmdp = param_getchar(Cmd, 0);\r | |
208 | \r | |
209 | if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') {\r | |
210 | usage_t55xx_trace();\r | |
211 | return 0;\r | |
212 | }\r | |
213 | \r | |
214 | if ( strlen(Cmd)==0){\r | |
215 | \r | |
216 | UsbCommand c = {CMD_T55XX_READ_TRACE, {0, 0, 0}};\r | |
217 | SendCommand(&c);\r | |
218 | WaitForResponse(CMD_ACK, NULL);\r | |
219 | \r | |
220 | uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00};\r | |
221 | \r | |
222 | GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,0); //3560 -- should be offset..\r | |
223 | WaitForResponseTimeout(CMD_ACK,NULL, 1500);\r | |
224 | \r | |
225 | for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) {\r | |
226 | GraphBuffer[j] = ((int)data[j]);\r | |
227 | }\r | |
228 | GraphTraceLen = LF_TRACE_BUFF_SIZE;\r | |
229 | }\r | |
230 | \r | |
231 | uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};\r | |
232 | uint8_t * bitstream = bits;\r | |
233 | \r | |
234 | manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream, LF_BITSSTREAM_LEN);\r | |
235 | RepaintGraphWindow();\r | |
236 | \r | |
237 | uint8_t si = 5;\r | |
238 | uint32_t bl0 = PackBits(si, 32, bitstream);\r | |
239 | uint32_t bl1 = PackBits(si+32, 32, bitstream);\r | |
240 | \r | |
241 | uint32_t acl = PackBits(si, 8, bitstream); si += 8;\r | |
242 | uint32_t mfc = PackBits(si, 8, bitstream); si += 8;\r | |
243 | uint32_t cid = PackBits(si, 5, bitstream); si += 5;\r | |
244 | uint32_t icr = PackBits(si, 3, bitstream); si += 3;\r | |
245 | uint32_t year = PackBits(si, 4, bitstream); si += 4;\r | |
246 | uint32_t quarter = PackBits(si, 2, bitstream); si += 2;\r | |
247 | uint32_t lotid = PackBits(si, 12, bitstream); si += 12;\r | |
248 | uint32_t wafer = PackBits(si, 5, bitstream); si += 5;\r | |
249 | uint32_t dw = PackBits(si, 15, bitstream); \r | |
250 | \r | |
251 | PrintAndLog("");\r | |
252 | PrintAndLog("-- T55xx Trace Information ----------------------------------");\r | |
253 | PrintAndLog("-------------------------------------------------------------");\r | |
254 | PrintAndLog(" ACL Allocation class (ISO/IEC 15963-1) : 0x%02X (%d)", acl, acl);\r | |
255 | PrintAndLog(" MFC Manufacturer ID (ISO/IEC 7816-6) : 0x%02X (%d)", mfc, mfc);\r | |
256 | PrintAndLog(" CID : 0x%02X (%d)", cid, cid);\r | |
257 | PrintAndLog(" ICR IC Revision : %d",icr );\r | |
258 | PrintAndLog(" Manufactured");\r | |
259 | PrintAndLog(" Year/Quarter : %d/%d",2000+year, quarter );\r | |
260 | PrintAndLog(" Lot ID : %d", lotid );\r | |
261 | PrintAndLog(" Wafer number : %d", wafer);\r | |
262 | PrintAndLog(" Die Number : %d", dw);\r | |
263 | PrintAndLog("-------------------------------------------------------------");\r | |
264 | PrintAndLog(" Raw Data - Page 1");\r | |
265 | PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(bitstream+5,32) );\r | |
266 | PrintAndLog(" Block 0 : 0x%08X %s", bl1, sprint_bin(bitstream+37,32) );\r | |
267 | PrintAndLog("-------------------------------------------------------------");\r | |
268 | /*\r | |
269 | TRACE - BLOCK O\r | |
270 | Bits Definition HEX\r | |
271 | 1-8 ACL Allocation class (ISO/IEC 15963-1) 0xE0 \r | |
272 | 9-16 MFC Manufacturer ID (ISO/IEC 7816-6) 0x15 Atmel Corporation\r | |
273 | 17-21 CID 0x1 = Atmel ATA5577M1 0x2 = Atmel ATA5577M2 \r | |
274 | 22-24 ICR IC revision\r | |
275 | 25-28 YEAR (BCD encoded) 9 (= 2009)\r | |
276 | 29-30 QUARTER 1,2,3,4 \r | |
277 | 31-32 LOT ID\r | |
278 | \r | |
279 | TRACE - BLOCK 1\r | |
280 | 1-12 LOT ID \r | |
281 | 13-17 Wafer number\r | |
282 | 18-32 DW, die number sequential\r | |
283 | */\r | |
284 | \r | |
285 | return 0;\r | |
286 | }\r | |
287 | \r | |
288 | int CmdInfo(const char *Cmd){\r | |
289 | /*\r | |
290 | Page 0 Block 0 Configuration data.\r | |
291 | Normal mode\r | |
292 | Extended mode\r | |
293 | */\r | |
294 | char cmdp = param_getchar(Cmd, 0);\r | |
295 | \r | |
296 | if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') {\r | |
297 | usage_t55xx_info();\r | |
298 | return 0;\r | |
299 | } else {\r | |
300 | CmdReadBlk("0");\r | |
301 | } \r | |
302 | \r | |
303 | uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};\r | |
304 | \r | |
305 | manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bits, LF_BITSSTREAM_LEN);\r | |
306 | \r | |
307 | uint8_t si = 5;\r | |
308 | uint32_t bl0 = PackBits(si, 32, bits);\r | |
309 | \r | |
310 | uint32_t safer = PackBits(si, 4, bits); si += 4; \r | |
311 | uint32_t resv = PackBits(si, 7, bits); si += 7;\r | |
312 | uint32_t dbr = PackBits(si, 3, bits); si += 3;\r | |
313 | uint32_t extend = PackBits(si, 1, bits); si += 1;\r | |
314 | uint32_t datamodulation = PackBits(si, 5, bits); si += 5;\r | |
315 | uint32_t pskcf = PackBits(si, 2, bits); si += 2;\r | |
316 | uint32_t aor = PackBits(si, 1, bits); si += 1; \r | |
317 | uint32_t otp = PackBits(si, 1, bits); si += 1; \r | |
318 | uint32_t maxblk = PackBits(si, 3, bits); si += 3;\r | |
319 | uint32_t pwd = PackBits(si, 1, bits); si += 1; \r | |
320 | uint32_t sst = PackBits(si, 1, bits); si += 1; \r | |
321 | uint32_t fw = PackBits(si, 1, bits); si += 1;\r | |
322 | uint32_t inv = PackBits(si, 1, bits); si += 1; \r | |
323 | uint32_t por = PackBits(si, 1, bits); si += 1;\r | |
324 | \r | |
325 | PrintAndLog("");\r | |
326 | PrintAndLog("-- T55xx Configuration & Tag Information --------------------");\r | |
327 | PrintAndLog("-------------------------------------------------------------");\r | |
328 | PrintAndLog(" Safer key : %s", GetSaferStr(safer));\r | |
329 | PrintAndLog(" reserved : %d", resv);\r | |
330 | PrintAndLog(" Data bit rate : %s", GetBitRateStr(dbr));\r | |
331 | PrintAndLog(" eXtended mode : %s", (extend) ? "Yes - Warning":"No");\r | |
332 | PrintAndLog(" Modulation : %s", GetModulationStr(datamodulation) );\r | |
333 | PrintAndLog(" PSK clock freq : %d", pskcf);\r | |
334 | PrintAndLog(" AOR - Answer on Request : %s", (aor) ? "Yes":"No");\r | |
335 | PrintAndLog(" OTP - One Time Pad : %s", (otp) ? "Yes - Warning":"No" );\r | |
336 | PrintAndLog(" Max block : %d", maxblk);\r | |
337 | PrintAndLog(" Password mode : %s", (pwd) ? "Yes":"No");\r | |
338 | PrintAndLog(" Sequence Start Terminator : %s", (sst) ? "Yes":"No");\r | |
339 | PrintAndLog(" Fast Write : %s", (fw) ? "Yes":"No");\r | |
340 | PrintAndLog(" Inverse data : %s", (inv) ? "Yes":"No");\r | |
341 | PrintAndLog(" POR-Delay : %s", (por) ? "Yes":"No");\r | |
342 | PrintAndLog("-------------------------------------------------------------");\r | |
343 | PrintAndLog(" Raw Data - Page 0");\r | |
344 | PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(bits+5,32) );\r | |
345 | PrintAndLog("-------------------------------------------------------------");\r | |
346 | \r | |
347 | return 0;\r | |
348 | }\r | |
349 | \r | |
350 | int CmdDump(const char *Cmd){\r | |
351 | \r | |
352 | char s[20] = {0x00};\r | |
353 | uint8_t pwd[4] = {0x00};\r | |
354 | \r | |
355 | char cmdp = param_getchar(Cmd, 0);\r | |
356 | if ( cmdp == 'h' || cmdp == 'H') {\r | |
357 | usage_t55xx_dump();\r | |
358 | return 0;\r | |
359 | }\r | |
360 | \r | |
361 | bool hasPwd = ( strlen(Cmd) > 0); \r | |
362 | if ( hasPwd ){\r | |
363 | if (param_gethex(Cmd, 0, pwd, 8)) {\r | |
364 | PrintAndLog("password must include 8 HEX symbols");\r | |
365 | return 1;\r | |
366 | }\r | |
367 | }\r | |
368 | \r | |
369 | for ( int i = 0; i <8; ++i){\r | |
370 | memset(s,0,sizeof(s));\r | |
371 | if ( hasPwd ) {\r | |
372 | sprintf(s,"%d %02x%02x%02x%02x", i, pwd[0],pwd[1],pwd[2],pwd[3]);\r | |
373 | } else {\r | |
374 | sprintf(s,"%d", i);\r | |
375 | }\r | |
376 | CmdReadBlk(s);\r | |
377 | }\r | |
378 | return 0;\r | |
379 | }\r | |
380 | \r | |
381 | int CmdIceFsk(const char *Cmd){\r | |
382 | \r | |
383 | if (!HasGraphData()) return 0;\r | |
384 | \r | |
385 | iceFsk3(GraphBuffer, LF_TRACE_BUFF_SIZE);\r | |
386 | RepaintGraphWindow();\r | |
387 | return 0;\r | |
388 | }\r | |
389 | int CmdIceManchester(const char *Cmd){\r | |
390 | ManchesterDemod( -1);\r | |
391 | return 0;\r | |
392 | }\r | |
393 | int ManchesterDemod(int blockNum){\r | |
394 | \r | |
395 | if (!HasGraphData()) return 0;\r | |
396 | \r | |
397 | uint8_t sizebyte = 32;\r | |
398 | // the value 5 was selected during empirical studies of the decoded data. Some signal noise to skip.\r | |
399 | uint8_t offset = 5;\r | |
400 | uint32_t blockData;\r | |
401 | uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};\r | |
402 | uint8_t * bitstream = bits;\r | |
403 | \r | |
404 | manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bits, LF_BITSSTREAM_LEN); \r | |
405 | blockData = PackBits(offset, sizebyte, bits);\r | |
406 | \r | |
407 | if ( blockNum < 0)\r | |
408 | PrintAndLog(" Decoded : 0x%08X %s", blockData, sprint_bin(bitstream+offset,sizebyte) );\r | |
409 | else\r | |
410 | PrintAndLog(" Block %d : 0x%08X %s", blockNum, blockData, sprint_bin(bitstream+offset,sizebyte) );\r | |
411 | \r | |
412 | return 0;\r | |
413 | } \r | |
414 | \r | |
415 | char * GetBitRateStr(uint32_t id){\r | |
416 | static char buf[40];\r | |
417 | char *retStr = buf;\r | |
418 | switch (id){\r | |
419 | case 0: \r | |
420 | sprintf(retStr,"%d - RF/8",id);\r | |
421 | break;\r | |
422 | case 1:\r | |
423 | sprintf(retStr,"%d - RF/16",id);\r | |
424 | break;\r | |
425 | case 2: \r | |
426 | sprintf(retStr,"%d - RF/32",id);\r | |
427 | break;\r | |
428 | case 3:\r | |
429 | sprintf(retStr,"%d - RF/40",id);\r | |
430 | break;\r | |
431 | case 4:\r | |
432 | sprintf(retStr,"%d - RF/50",id);\r | |
433 | break;\r | |
434 | case 5:\r | |
435 | sprintf(retStr,"%d - RF/64",id);\r | |
436 | break;\r | |
437 | case 6:\r | |
438 | sprintf(retStr,"%d - RF/100",id);\r | |
439 | break;\r | |
440 | case 7:\r | |
441 | sprintf(retStr,"%d - RF/128",id);\r | |
442 | break;\r | |
443 | default:\r | |
444 | sprintf(retStr,"%d - (Unknown)",id);\r | |
445 | break;\r | |
446 | }\r | |
447 | \r | |
448 | return buf;\r | |
449 | }\r | |
450 | \r | |
451 | char * GetSaferStr(uint32_t id){\r | |
452 | static char buf[40];\r | |
453 | char *retStr = buf;\r | |
454 | \r | |
455 | sprintf(retStr,"%d",id);\r | |
456 | if (id == 6) {\r | |
457 | sprintf(retStr,"%d - pasdwd",id);\r | |
458 | }\r | |
459 | if (id == 9 ){\r | |
460 | sprintf(retStr,"%d - testmode ",id);\r | |
461 | }\r | |
462 | \r | |
463 | return buf;\r | |
464 | }\r | |
465 | char * GetModulationStr( uint32_t id){\r | |
466 | static char buf[40];\r | |
467 | char *retStr = buf;\r | |
468 | \r | |
469 | switch (id){\r | |
470 | case 0: \r | |
471 | sprintf(retStr,"%d - DIRECT (ASK/NRZ)",id);\r | |
472 | break;\r | |
473 | case 1:\r | |
474 | sprintf(retStr,"%d - PSK 1 phase change when input changes",id);\r | |
475 | break;\r | |
476 | case 2: \r | |
477 | sprintf(retStr,"%d - PSK 2 phase change on bitclk if input high",id);\r | |
478 | break;\r | |
479 | case 3:\r | |
480 | sprintf(retStr,"%d - PSK 3 phase change on rising edge of input",id);\r | |
481 | break;\r | |
482 | case 4:\r | |
483 | sprintf(retStr,"%d - FSK 1 RF/8 RF/5",id);\r | |
484 | break;\r | |
485 | case 5:\r | |
486 | sprintf(retStr,"%d - FSK 2 RF/8 RF/10",id);\r | |
487 | break;\r | |
488 | case 6:\r | |
489 | sprintf(retStr,"%d - FSK 1a RF/5 RF/8",id);\r | |
490 | break;\r | |
491 | case 7:\r | |
492 | sprintf(retStr,"%d - FSK 2a RF/10 RF/8",id);\r | |
493 | break;\r | |
494 | case 8:\r | |
495 | sprintf(retStr,"%d - Manschester",id);\r | |
496 | break;\r | |
497 | case 16:\r | |
498 | sprintf(retStr,"%d - Biphase",id);\r | |
499 | break;\r | |
500 | case 17:\r | |
501 | sprintf(retStr,"%d - Reserved",id);\r | |
502 | break;\r | |
503 | default:\r | |
504 | sprintf(retStr,"0x%02X (Unknown)",id);\r | |
505 | break;\r | |
506 | }\r | |
507 | return buf;\r | |
508 | }\r | |
509 | \r | |
510 | \r | |
511 | uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bits){\r | |
512 | \r | |
513 | int i = start;\r | |
514 | int j = len-1;\r | |
515 | if (len > 32) {\r | |
516 | return 0;\r | |
517 | }\r | |
518 | uint32_t tmp = 0;\r | |
519 | for (; j >= 0; --j, ++i){\r | |
520 | tmp |= bits[i] << j;\r | |
521 | }\r | |
522 | return tmp;\r | |
523 | }\r | |
524 | \r | |
525 | static command_t CommandTable[] =\r | |
526 | {\r | |
527 | {"help", CmdHelp, 1, "This help"},\r | |
528 | {"rd", CmdReadBlk, 0, "<block> [password] -- Read T55xx block data (page 0) [optional password]"},\r | |
529 | {"wr", CmdWriteBlk, 0, "<block> <data> [password] -- Write T55xx block data (page 0) [optional password]"},\r | |
530 | {"trace", CmdReadTrace, 0, "[1] Read T55xx traceability data (page 1/ blk 0-1)"},\r | |
531 | {"info", CmdInfo, 0, "[1] Read T55xx configuration data (page 0/ blk 0)"},\r | |
532 | {"dump", CmdDump, 0, "[password] Dump T55xx card block 0-7. [optional password]"},\r | |
533 | {"man", CmdIceManchester, 0, "Manchester demod (with SST)"},\r | |
534 | {NULL, NULL, 0, NULL}\r | |
535 | };\r | |
536 | \r | |
537 | int CmdLFT55XX(const char *Cmd)\r | |
538 | {\r | |
539 | CmdsParse(CommandTable, Cmd);\r | |
540 | return 0;\r | |
541 | }\r | |
542 | \r | |
543 | int CmdHelp(const char *Cmd)\r | |
544 | {\r | |
545 | CmdsHelp(CommandTable);\r | |
546 | return 0;\r | |
547 | }\r |