Skip to content

Instantly share code, notes, and snippets.

@kkmonster
Created June 18, 2019 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkmonster/9da95770821f8ce217df8bc302919dbf to your computer and use it in GitHub Desktop.
Save kkmonster/9da95770821f8ce217df8bc302919dbf to your computer and use it in GitHub Desktop.
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