diff options
author | Gregory Fong <gregory.fong@virginorbit.com> | 2018-07-29 17:21:24 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2018-07-29 17:21:24 -0700 |
commit | f41d577b6352e80919469ee1724a0b9ad4359e67 (patch) | |
tree | 7a96d9194937855ebaecc14bb254236d3ccc5940 /driver_greis_checksum.c | |
parent | d1f79455a50f92b3dbf68c2ad5196423d80ed78a (diff) | |
download | gpsd-f41d577b6352e80919469ee1724a0b9ad4359e67.tar.gz |
Add GREIS (Javad) GPS driver.
All functional changes inside "#ifdef GREIS_ENABLE"
Includes new regression tests. All regressions tests
pass.
Developed by Gregory Fong, with help and support from
Virgin Orbit.
Signed-off-by: Gary E. Miller <gem@rellim.com>
Diffstat (limited to 'driver_greis_checksum.c')
-rw-r--r-- | driver_greis_checksum.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/driver_greis_checksum.c b/driver_greis_checksum.c new file mode 100644 index 00000000..e7f69518 --- /dev/null +++ b/driver_greis_checksum.c @@ -0,0 +1,24 @@ +/* + * Checksum for the GNSS Receiver External Interface Specification (GREIS). + * + * This file is Copyright (c) 2017 Virgin Orbit + * SPDX-License-Identifier: BSD-2-clause + */ + +#include <limits.h> + +#include "driver_greis.h" + +static inline unsigned char greis_rotate_left(unsigned char val) +{ + /* left circular rotation by two bits */ + return (val << 2) | (val >> (CHAR_BIT - 2)); +} + +unsigned char greis_checksum(const unsigned char *src, int count) +{ + unsigned char res = 0; + while (count--) + res = greis_rotate_left(res) ^ *src++; + return greis_rotate_left(res); +} |