]> cvs.zerfleddert.de Git - proxmark3-svn/blame - client/cmdlft55xx.c
Merge branch 'master' of https://github.com/Proxmark/proxmark3
[proxmark3-svn] / client / cmdlft55xx.c
CommitLineData
54a942b0 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
54a942b0 13#include "proxmark3.h"\r
14#include "ui.h"\r
15#include "graph.h"\r
f38a1528 16#include "cmdmain.h"\r
54a942b0 17#include "cmdparser.h"\r
18#include "cmddata.h"\r
19#include "cmdlf.h"\r
20#include "cmdlft55xx.h"\r
f38a1528 21#include "util.h"\r
22#include "data.h"\r
c4e3b1b6 23#include "lfdemod.h"\r
54a942b0 24\r
8d0a3e87 25#define LF_TRACE_BUFF_SIZE 20000 // 32 x 32 x 10 (32 bit times numofblock (7), times clock skip..)\r
c6be64da 26#define LF_BITSSTREAM_LEN 1000 // more then 1000 bits shouldn't happend.. 8block * 4 bytes * 8bits = \r
54a942b0 27\r
4ecde0e1 28int 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
38int 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
49int 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
58int 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
54a942b0 67\r
4ecde0e1 68int 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
77static int CmdHelp(const char *Cmd);\r
c4e3b1b6 78\r
54a942b0 79int CmdReadBlk(const char *Cmd)\r
80{\r
c4e3b1b6 81 int invert = 0;\r
82 int clk = 0;\r
c6be64da 83 int block = -1;\r
4ecde0e1 84 int password = 0xFFFFFFFF; //default to blank Block 7\r
385f3987 85 int errCnt;\r
86 size_t bitlen;\r
4ecde0e1 87 int maxErr = 100;\r
88 uint8_t askAmp = 0;\r
385f3987 89 uint32_t blockData;\r
c4e3b1b6 90 uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0x00};\r
385f3987 91 \r
c4e3b1b6 92 \r
4ecde0e1 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
54a942b0 98\r
4ecde0e1 99 int res = sscanf(Cmd, "%d %x", &block, &password);\r
54a942b0 100\r
4ecde0e1 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
b44e5233 107 PrintAndLog("Block must be between 0 and 7");\r
108 return 1;\r
4ecde0e1 109 } \r
54a942b0 110\r
4ecde0e1 111 UsbCommand c = {CMD_T55XX_READ_BLOCK, {0, block, 0}};\r
112 c.d.asBytes[0] = 0x0; \r
54a942b0 113\r
4ecde0e1 114 //Password mode\r
115 if ( res == 2 ) {\r
116 c.arg[2] = password;\r
117 c.d.asBytes[0] = 0x1; \r
c4e3b1b6 118 }\r
54a942b0 119\r
b44e5233 120 SendCommand(&c);\r
c4e3b1b6 121 if ( !WaitForResponseTimeout(CMD_ACK,NULL,1500) ) {\r
122 PrintAndLog("command execution time out");\r
385f3987 123 return 2;\r
c4e3b1b6 124 }\r
f38a1528 125 \r
385f3987 126 CmdSamples("12000");\r
a501c82b 127\r
385f3987 128 bitlen = getFromGraphBuf(bits);\r
c4e3b1b6 129 \r
4ecde0e1 130 errCnt = askrawdemod(bits, &bitlen, &clk, &invert, maxErr, askAmp);\r
c4e3b1b6 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
385f3987 137 return 3;\r
a501c82b 138 }\r
c4e3b1b6 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
385f3987 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
c4e3b1b6 162 return 0;\r
54a942b0 163}\r
164\r
54a942b0 165int CmdWriteBlk(const char *Cmd)\r
54a942b0 166{\r
4ecde0e1 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
54a942b0 183\r
4ecde0e1 184 if (block > 7) {\r
b44e5233 185 PrintAndLog("Block must be between 0 and 7");\r
186 return 1;\r
f38a1528 187 }\r
4ecde0e1 188 \r
189 UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}};\r
190 c.d.asBytes[0] = 0x0; \r
54a942b0 191\r
4ecde0e1 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
54a942b0 203}\r
204\r
205int CmdReadTrace(const char *Cmd)\r
206{\r
fbceacc5 207 char cmdp = param_getchar(Cmd, 0);\r
f38a1528 208\r
fbceacc5 209 if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') {\r
4ecde0e1 210 usage_t55xx_trace();\r
fbceacc5 211 return 0;\r
212 }\r
f38a1528 213\r
fbceacc5 214 if ( strlen(Cmd)==0){\r
c4e3b1b6 215 \r
fbceacc5 216 UsbCommand c = {CMD_T55XX_READ_TRACE, {0, 0, 0}};\r
217 SendCommand(&c);\r
218 WaitForResponse(CMD_ACK, NULL);\r
f38a1528 219\r
fbceacc5 220 uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00};\r
221\r
8d0a3e87 222 GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,0); //3560 -- should be offset..\r
fbceacc5 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
f38a1528 229 }\r
f38a1528 230 \r
c6be64da 231 uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};\r
f6c18637 232 uint8_t * bitstream = bits;\r
f38a1528 233 \r
c6be64da 234 manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream, LF_BITSSTREAM_LEN);\r
f6c18637 235 RepaintGraphWindow();\r
b44e5233 236\r
f6c18637 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
77376577 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
f6c18637 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
77376577 260 PrintAndLog(" Lot ID : %d", lotid );\r
f6c18637 261 PrintAndLog(" Wafer number : %d", wafer);\r
262 PrintAndLog(" Die Number : %d", dw);\r
263 PrintAndLog("-------------------------------------------------------------");\r
77376577 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
f6c18637 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
77376577 277 31-32 LOT ID\r
f6c18637 278 \r
279 TRACE - BLOCK 1\r
77376577 280 1-12 LOT ID \r
f6c18637 281 13-17 Wafer number\r
282 18-32 DW, die number sequential\r
283 */\r
284 \r
285 return 0;\r
286}\r
f38a1528 287\r
f6c18637 288int 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
fbceacc5 294 char cmdp = param_getchar(Cmd, 0);\r
295\r
296 if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') {\r
4ecde0e1 297 usage_t55xx_info();\r
fbceacc5 298 return 0;\r
4ecde0e1 299 } else {\r
fbceacc5 300 CmdReadBlk("0");\r
081151ea 301 } \r
fbceacc5 302\r
c6be64da 303 uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};\r
8d0a3e87 304\r
305 manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bits, LF_BITSSTREAM_LEN);\r
f6c18637 306 \r
307 uint8_t si = 5;\r
8d0a3e87 308 uint32_t bl0 = PackBits(si, 32, bits);\r
f6c18637 309 \r
8d0a3e87 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
b44e5233 324 \r
f6c18637 325 PrintAndLog("");\r
99a71418 326 PrintAndLog("-- T55xx Configuration & Tag Information --------------------");\r
f6c18637 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
77376577 343 PrintAndLog(" Raw Data - Page 0");\r
8d0a3e87 344 PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(bits+5,32) );\r
f6c18637 345 PrintAndLog("-------------------------------------------------------------");\r
346 \r
347 return 0;\r
348}\r
349\r
77376577 350int CmdDump(const char *Cmd){\r
351\r
4ecde0e1 352 char s[20] = {0x00};\r
77376577 353 uint8_t pwd[4] = {0x00};\r
54a942b0 354\r
4ecde0e1 355 char cmdp = param_getchar(Cmd, 0);\r
149aeada 356 if ( cmdp == 'h' || cmdp == 'H') {\r
4ecde0e1 357 usage_t55xx_dump();\r
77376577 358 return 0;\r
359 }\r
4ecde0e1 360\r
361 bool hasPwd = ( strlen(Cmd) > 0); \r
77376577 362 if ( hasPwd ){\r
2ae8a312 363 if (param_gethex(Cmd, 0, pwd, 8)) {\r
364 PrintAndLog("password must include 8 HEX symbols");\r
c4e3b1b6 365 return 1;\r
77376577 366 }\r
367 }\r
a501c82b 368 \r
77376577 369 for ( int i = 0; i <8; ++i){\r
149aeada 370 memset(s,0,sizeof(s));\r
77376577 371 if ( hasPwd ) {\r
c6be64da 372 sprintf(s,"%d %02x%02x%02x%02x", i, pwd[0],pwd[1],pwd[2],pwd[3]);\r
77376577 373 } else {\r
374 sprintf(s,"%d", i);\r
77376577 375 }\r
4ecde0e1 376 CmdReadBlk(s);\r
77376577 377 }\r
378 return 0;\r
379}\r
380\r
7bd30f12 381int CmdIceFsk(const char *Cmd){\r
c6be64da 382\r
383 if (!HasGraphData()) return 0;\r
384\r
7bd30f12 385 iceFsk3(GraphBuffer, LF_TRACE_BUFF_SIZE);\r
7bd30f12 386 RepaintGraphWindow();\r
387 return 0;\r
388}\r
fbceacc5 389int CmdIceManchester(const char *Cmd){\r
72e930ef 390 ManchesterDemod( -1);\r
391 return 0;\r
392}\r
c6be64da 393int ManchesterDemod(int blockNum){\r
fbceacc5 394\r
c6be64da 395 if (!HasGraphData()) return 0;\r
396 \r
081151ea 397 uint8_t sizebyte = 32;\r
a501c82b 398 // the value 5 was selected during empirical studies of the decoded data. Some signal noise to skip.\r
081151ea 399 uint8_t offset = 5;\r
fbceacc5 400 uint32_t blockData;\r
c6be64da 401 uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};\r
fbceacc5 402 uint8_t * bitstream = bits;\r
403 \r
8d0a3e87 404 manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bits, LF_BITSSTREAM_LEN); \r
8d0a3e87 405 blockData = PackBits(offset, sizebyte, bits);\r
72e930ef 406\r
081151ea 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
fbceacc5 412 return 0;\r
413} \r
7bd30f12 414\r
f6c18637 415char * 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
f6c18637 451char * 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
465char * 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
7bd30f12 471 sprintf(retStr,"%d - DIRECT (ASK/NRZ)",id);\r
f6c18637 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
511uint32_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
3bc3598e 515 if (len > 32) {\r
516 return 0;\r
517 }\r
f6c18637 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
54a942b0 523}\r
524\r
525static command_t CommandTable[] =\r
526{\r
b44e5233 527 {"help", CmdHelp, 1, "This help"},\r
4ecde0e1 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
a61b4976 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
4ecde0e1 532 {"dump", CmdDump, 0, "[password] Dump T55xx card block 0-7. [optional password]"},\r
72e930ef 533 {"man", CmdIceManchester, 0, "Manchester demod (with SST)"},\r
54a942b0 534 {NULL, NULL, 0, NULL}\r
535};\r
536\r
537int CmdLFT55XX(const char *Cmd)\r
538{\r
539 CmdsParse(CommandTable, Cmd);\r
540 return 0;\r
541}\r
542\r
543int CmdHelp(const char *Cmd)\r
544{\r
545 CmdsHelp(CommandTable);\r
546 return 0;\r
547}\r
Impressum, Datenschutz