+ if (config.Q5) {\r
+ uint32_t hdr = PackBits(si, 9, DemodBuffer); si += 9;\r
+ \r
+ if (hdr != 0x1FF) {\r
+ PrintAndLog("Invalid Q5 Trace data header (expected 0x1FF, found %X)", hdr);\r
+ return 0;\r
+ }\r
+ \r
+ t5555_tracedata_t data = {.bl1 = bl1, .bl2 = bl2, .icr = 0, .lotidc = '?', .lotid = 0, .wafer = 0, .dw =0};\r
+ \r
+ data.icr = PackBits(si, 2, DemodBuffer); si += 2;\r
+ data.lotidc = 'Z' - PackBits(si, 2, DemodBuffer); si += 3;\r
+ \r
+ data.lotid = PackBits(si, 4, DemodBuffer); si += 5;\r
+ data.lotid <<= 4;\r
+ data.lotid |= PackBits(si, 4, DemodBuffer); si += 5;\r
+ data.lotid <<= 4;\r
+ data.lotid |= PackBits(si, 4, DemodBuffer); si += 5;\r
+ data.lotid <<= 4;\r
+ data.lotid |= PackBits(si, 4, DemodBuffer); si += 5;\r
+ data.lotid <<= 1;\r
+ data.lotid |= PackBits(si, 1, DemodBuffer); si += 1;\r
+ \r
+ data.wafer = PackBits(si, 3, DemodBuffer); si += 4;\r
+ data.wafer <<= 2;\r
+ data.wafer |= PackBits(si, 2, DemodBuffer); si += 2;\r
+ \r
+ data.dw = PackBits(si, 2, DemodBuffer); si += 3;\r
+ data.dw <<= 4;\r
+ data.dw |= PackBits(si, 4, DemodBuffer); si += 5;\r
+ data.dw <<= 4;\r
+ data.dw |= PackBits(si, 4, DemodBuffer); si += 5;\r
+ data.dw <<= 4;\r
+ data.dw |= PackBits(si, 4, DemodBuffer); si += 5;\r
+ \r
+ printT5555Trace(data, repeat);\r
+ \r
+ } else {\r
+ \r
+ t55x7_tracedata_t data = {.bl1 = bl1, .bl2 = bl2, .acl = 0, .mfc = 0, .cid = 0, .year = 0, .quarter = 0, .icr = 0, .lotid = 0, .wafer = 0, .dw = 0};\r
+ \r
+ data.acl = PackBits(si, 8, DemodBuffer); si += 8;\r
+ if ( data.acl != 0xE0 ) {\r
+ PrintAndLog("The modulation is most likely wrong since the ACL is not 0xE0. ");\r
+ return 0;\r
+ }\r
+\r
+ data.mfc = PackBits(si, 8, DemodBuffer); si += 8;\r
+ data.cid = PackBits(si, 5, DemodBuffer); si += 5;\r
+ data.icr = PackBits(si, 3, DemodBuffer); si += 3;\r
+ data.year = PackBits(si, 4, DemodBuffer); si += 4;\r
+ data.quarter = PackBits(si, 2, DemodBuffer); si += 2;\r
+ data.lotid = PackBits(si, 14, DemodBuffer); si += 14;\r
+ data.wafer = PackBits(si, 5, DemodBuffer); si += 5;\r
+ data.dw = PackBits(si, 15, DemodBuffer); \r
+\r
+ time_t t = time(NULL);\r
+ struct tm tm = *localtime(&t);\r
+ if ( data.year > tm.tm_year-110)\r
+ data.year += 2000;\r
+ else\r
+ data.year += 2010;\r
+\r
+ printT55x7Trace(data, repeat);\r