wiegand decode - added binary param to decode

This commit is contained in:
iceman1001
2021-03-29 17:38:20 +02:00
parent 48b9ec1e7b
commit 8278c733fe
3 changed files with 48 additions and 7 deletions

View File

@@ -1041,6 +1041,27 @@ int binstring_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, const char *str)
return i;
}
/**
* Converts a binary array to component "hi2", "hi" and "lo" 32-bit integers,
* one bit at a time.
*
* Returns the number of bits entered.
*/
int binarray_to_u96(uint32_t *hi2, uint32_t *hi, uint32_t *lo, uint8_t *arr, int arrlen) {
int i = 0;
for(; i < arrlen; i++) {
uint8_t n = arr[i];
if (n > 1)
break;
*hi2 = (*hi2 << 1) | (*hi >> 31);
*hi = (*hi << 1) | (*lo >> 31);
*lo = (*lo << 1) | (n & 0x1);
}
return i;
}
inline uint32_t bitcount32(uint32_t a) {
#if defined __GNUC__
return __builtin_popcountl(a);