#include #include #include "crc7.h" #include "decode.h" int main(int argc, char** argv) { int i, j; int temp, e, m; char ch; unsigned long resp[4]; if (argc != 2) return -1; if (strlen(argv[1]) != 8 * 4) return -1; for (i = 0;i < 4;i++) { resp[i] = 0; for (j = 0;j < 8;j++) { resp[i] <<= 4; ch = tolower(argv[1][i * 8 + j]); if (isdigit(ch)) resp[i] |= ch - '0'; else if (isxdigit(ch)) resp[i] |= ch - 'a' + 0xA; else return -1; } } printf("Manufacturer ID: %d\n", UNSTUFF_BITS(resp, 120, 8)); printf("OEM/Application ID: %d\n", UNSTUFF_BITS(resp, 104, 16)); printf("Product name: %c%c%c%c%c%c\n", (char)UNSTUFF_BITS(resp, 96, 8), (char)UNSTUFF_BITS(resp, 88, 8), (char)UNSTUFF_BITS(resp, 80, 8), (char)UNSTUFF_BITS(resp, 72, 8), (char)UNSTUFF_BITS(resp, 64, 8), (char)UNSTUFF_BITS(resp, 56, 8)); printf("Product revision: %d:%d\n", UNSTUFF_BITS(resp, 52, 4), UNSTUFF_BITS(resp, 48, 4)); printf("Serial: %08x\n", UNSTUFF_BITS(resp, 16, 32)); printf("Manufacturing date: %d/%d\n", UNSTUFF_BITS(resp, 12, 4) + 1997, UNSTUFF_BITS(resp, 8, 4)); gen_crc7_syndrome_table(); printf("CRC: "); if (UNSTUFF_BITS(resp, 1, 7) == calc_crc7(resp)) printf("OK"); else printf("Fail"); printf("\n"); return 0; }