Fixed CRC problem

This commit is contained in:
Your Name
2026-08-05 16:18:51 +03:00
parent 738982ba0e
commit 4a479e46ad
+3 -1
View File
@@ -35,8 +35,10 @@ uint8_t command_calculate_crc(struct command_message_t *msg) {
uint8_t crc = 0; uint8_t crc = 0;
uint8_t *byte_ptr = (uint8_t *)msg; uint8_t *byte_ptr = (uint8_t *)msg;
int loop_length = (sizeof(struct command_message_t) - sizeof(msg->data) + msg->length);
for (int i = 0; i < (sizeof(struct command_message_t) - sizeof(msg->data) + msg->length) - 1; i++) { for (int i = 0; i < loop_length; i++) {
if (i == 4) { continue; }
sum += byte_ptr[i]; sum += byte_ptr[i];
} }