mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-02 14:08:45 -04:00
AP_Math: add method for generating hash
This commit is contained in:
parent
e266188963
commit
3c1e99cc6b
@ -338,6 +338,7 @@ bool rotation_equal(enum Rotation r1, enum Rotation r2)
|
||||
return (v1 - v2).length() < 0.001;
|
||||
}
|
||||
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
||||
// fill an array of float with NaN, used to invalidate memory in SITL
|
||||
void fill_nanf(float *f, uint16_t count)
|
||||
|
@ -281,3 +281,4 @@ bool rotation_equal(enum Rotation r1, enum Rotation r2) WARN_IF_UNUSED;
|
||||
// fill an array of float with NaN, used to invalidate memory in SITL
|
||||
void fill_nanf(float *f, uint16_t count);
|
||||
#endif
|
||||
|
||||
|
@ -255,3 +255,14 @@ uint16_t calc_crc_modbus(uint8_t *buf, uint16_t len)
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
// FNV-1a implementation
|
||||
#define FNV_1_PRIME_64 1099511628211UL
|
||||
void hash_fnv_1a(uint32_t len, const uint8_t* buf, uint64_t* hash)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i=0; i<len; i++) {
|
||||
*hash ^= (uint64_t)buf[i];
|
||||
*hash *= FNV_1_PRIME_64;
|
||||
}
|
||||
}
|
||||
|
@ -29,3 +29,7 @@ uint16_t crc16_ccitt(const uint8_t *buf, uint32_t len, uint16_t crc);
|
||||
|
||||
uint16_t calc_crc_modbus(uint8_t *buf, uint16_t len);
|
||||
|
||||
// generate 64bit FNV1a hash from buffer
|
||||
#define FNV_1_OFFSET_BASIS_64 14695981039346656037UL
|
||||
void hash_fnv_1a(uint32_t len, const uint8_t* buf, uint64_t* hash);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user