commit f99a94f5e048e7ff52a717f1c6bf32743e989ddd
parent ed1467af7d077592c807918a63209e8fc548d648
Author: amin <dev@aminmesbah.com>
Date: Sat, 15 Jan 2022 20:31:26 +0000
Fix checksum calculation
I had missed that the specification says to use only the lower byte of
the sum.
FossilOrigin-Name: f2d76256e5783f52033ee4eab1974ce3df25c7ca54d1f8e0cb5d1e8bc473cb99
Diffstat:
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/main.c b/main.c
@@ -92,9 +92,8 @@ int main(void)
if (bytes_read == sizeof(data)
&& end == 0x0d
&& (item == 0x42 || item == 0x50)
- && item + msb + lsb == checksum)
+ && ((item + msb + lsb) & 0xFF) == checksum)
{
-
uint16_t value = (((uint16_t)msb) << 8) | lsb;
char buf[1024] = {0};
int str_len = 0;