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