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