- //loop through 10 or 22 sets of 5 bits (50-10p = 40 bits or 88 bits)
- for (i=0; i < fmtlen; i++){
- parityBits = bytebits_to_byte(BitStream + (i*5) + idx, 5);
- //check even parity
- if (parityTest(parityBits, 5, 0) == 0) return 0;
- //set uint64 with ID from BitStream
- for (uint8_t j = 0; j < 4; j++){
- *hi = (*hi << 1) | (*lo >> 63);
- *lo = (*lo << 1) | (BitStream[(i*5) + j + idx]);
- }
+ switch (*size) {
+ case 40: {
+ // std em410x format
+ *hi = 0;
+ *lo = ((uint64_t)(bytebits_to_byte(BitStream, 8)) << 32) | (bytebits_to_byte(BitStream + 8, 32));
+ break;
+ }
+ case 88: {
+ // long em format
+ *hi = (bytebits_to_byte(BitStream, 24));
+ *lo = ((uint64_t)(bytebits_to_byte(BitStream + 24, 32)) << 32) | (bytebits_to_byte(BitStream + 24 + 32, 32));
+ break;
+ }
+ default: return -4;