Fixed checksum

Fixed a bug when requesting negative speed in the checksum calculation due to data type.
This commit is contained in:
EmanuelFeru 2019-12-01 17:38:36 +01:00
parent 1841257078
commit 9fdb6d75f5
1 changed files with 1 additions and 1 deletions

View File

@ -322,7 +322,7 @@ int main(void) {
#if defined CONTROL_SERIAL_USART2 || defined CONTROL_SERIAL_USART3 #if defined CONTROL_SERIAL_USART2 || defined CONTROL_SERIAL_USART3
// Handle received data validity, timeout and fix out-of-sync if necessary // 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 (timeoutFlag) { // Check for previous timeout flag
if (timeoutCnt-- <= 0) // Timeout de-qualification if (timeoutCnt-- <= 0) // Timeout de-qualification
timeoutFlag = 0; // Timeout flag cleared timeoutFlag = 0; // Timeout flag cleared