+ if (g_debugMode) {
+ char *bin = sprint_bin_break(BitStream,size,16);
+ PrintAndLog("DEBUG BinStream:\n%s",bin);
+ }
+ PrintAndLog("\nFDX-B / ISO 11784/5 Animal Tag ID Found:");
+ if (g_debugMode) PrintAndLog("startmarker %d; Size %d", preambleIndex, size);
+
+ //got a good demod
+
+ //marshmellows
+ uint64_t NationalCode = ((uint64_t)(bytebits_to_byteLSBF(BitStream+32,6)) << 32) | bytebits_to_byteLSBF(BitStream,32);
+ uint32_t countryCode = bytebits_to_byteLSBF(BitStream+38,10);
+ uint8_t dataBlockBit = BitStream[48];
+ uint32_t reservedCode = bytebits_to_byteLSBF(BitStream+49,14);
+ uint8_t animalBit = BitStream[63];
+
+ uint16_t crc16 = bytebits_to_byteLSBF(BitStream+64,16);
+ uint32_t extended = bytebits_to_byteLSBF(BitStream+80,24);
+
+ uint64_t rawid = ((uint64_t)bytebits_to_byte(BitStream+32,32) << 32) | bytebits_to_byte(BitStream,32);
+ uint8_t raw[8];
+ num_to_bytes(rawid, 8, raw);
+ PrintAndLog("%s", sprint_hex(raw,8));
+ uint16_t crcCalc = crc16_ccitt_rev( raw ,8);
+
+ PrintAndLog("Animal ID: %u-%012llu", countryCode, NationalCode);
+ PrintAndLog("National Code: %012llu", NationalCode);
+ PrintAndLog("CountryCode: %u", countryCode);
+ PrintAndLog("Extended Data: %s", dataBlockBit ? "True" : "False");
+ PrintAndLog("reserved Code: %u", reservedCode);
+ PrintAndLog("Animal Tag: %s", animalBit ? "True" : "False");
+ PrintAndLog("CRC: 0x%02X", crc16);
+ PrintAndLog("CRC : %X == %X %s", crc16, crcCalc, ( crcCalc == crc16 )?"ok":"!" );
+ PrintAndLog("Extended: 0x%X", extended);
+
+/*
+ //uint16_t crcCalc = crc16_ccitt( ByteStream, 8);
+ PrintAndLog("Application ID: %04X", applicationid);
+ */