wiegand decode - added binary param to decode
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user