From 9fdb6d75f5a5ec0cd0f3c31bd5fd77b2135b4b54 Mon Sep 17 00:00:00 2001 From: EmanuelFeru Date: Sun, 1 Dec 2019 17:38:36 +0100 Subject: [PATCH] Fixed checksum Fixed a bug when requesting negative speed in the checksum calculation due to data type. --- Src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/main.c b/Src/main.c index 8c3b85a..368b7d5 100644 --- a/Src/main.c +++ b/Src/main.c @@ -322,7 +322,7 @@ int main(void) { #if defined CONTROL_SERIAL_USART2 || defined CONTROL_SERIAL_USART3 // Handle received data validity, timeout and fix out-of-sync if necessary - if (command.start == START_FRAME && command.checksum == (command.start ^ command.steer ^ command.speed)) { + if (command.start == START_FRAME && command.checksum == (uint16_t)(command.start ^ command.steer ^ command.speed)) { if (timeoutFlag) { // Check for previous timeout flag if (timeoutCnt-- <= 0) // Timeout de-qualification timeoutFlag = 0; // Timeout flag cleared