-
-
Save kkmonster/9da95770821f8ce217df8bc302919dbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8_t got_cmd = 0; | |
for (int tmp = 0; tmp < sizeof(command_tmp) - 7; tmp++) { | |
if (command_tmp[tmp] == 0xff && command_tmp[tmp + 1] == 0xfe) { | |
uint16_t sumcheck = 0; | |
uint16_t sumget = (uint16_t) command_tmp[tmp + 6] << 8 | (uint16_t) command_tmp[tmp + 7]; | |
for (int tmp_2 = 0; tmp_2 < 6; tmp_2++) { | |
sumcheck += command_tmp[tmp + tmp_2]; | |
} | |
if (sumget == sumcheck) { | |
got_cmd = 1; | |
command.steer = ((int16_t) command_tmp[tmp + 2]) << 8 | (int16_t) command_tmp[tmp + 3]; | |
command.speed = ((int16_t) command_tmp[tmp + 4]) << 8 | (int16_t) command_tmp[tmp + 5]; | |
tmp = sizeof(command_tmp); //exit for loop | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment