-// static void calc37S(uint16_t fc, uint32_t cardno, uint32_t *hi, uint32_t *lo){
- // // FC 2 - 17 - 16 bit
- // // cardno 18 - 36 - 19 bit
- // // Even P1 1 - 19
- // // Odd P37 19 - 36
-
- // fc = fc & 0xFFFF;
- // *lo = ((fc << 20) | (cardno & 0x7FFFF) << 1);
- // *hi = (fc >> 12);
-// }
-// static void calc37H(uint64_t cardno, uint32_t *hi, uint32_t *lo){
- // // SC NONE
- // // cardno 1-35 34 bits
- // // Even Parity 0th bit 1-18
- // // Odd Parity 36th bit 19-35
- // cardno = (cardno & 0x00000003FFFFFFFF);
- // *lo = (cardno << 1);
- // *hi = (cardno >> 31);
-// }
+static void calc37S(uint16_t fc, uint32_t cardno, uint8_t *out){
+ // FC 2 - 17 - 16 bit
+ // cardno 18 - 36 - 19 bit
+ // Even P1 1 - 19
+ // Odd P37 19 - 36
+ uint8_t wiegand[35];
+ num_to_bytebits(fc, 16, wiegand);
+ num_to_bytebits(cardno, 19, wiegand + 16);
+ wiegand_add_parity(out, wiegand, sizeof(wiegand) );
+}
+static void calc37H(uint64_t cardno, uint8_t *out){
+ // SC NONE
+ // cardno 1-35 34 bits
+ // Even Parity 0th bit 1-18
+ // Odd Parity 36th bit 19-35
+ uint8_t wiegand[37];
+ num_to_bytebits( (uint32_t)(cardno >> 32), 2, wiegand);
+ num_to_bytebits( (uint32_t)(cardno >> 0), 32, wiegand + 2);
+ wiegand_add_parity(out, wiegand, sizeof(wiegand) );
+
+ printf("%x %x\n", (uint32_t)(cardno >> 32), (uint32_t)cardno );
+}