From 46f013214703df8e7845670cc0182c0ea7fe0581 Mon Sep 17 00:00:00 2001 From: Thomas Debrunner Date: Thu, 18 Nov 2021 12:21:46 +0100 Subject: [PATCH] mavlink-mission: use mavlink_mission_item for crc calculation --- src/modules/mavlink/mavlink_mission.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/modules/mavlink/mavlink_mission.cpp b/src/modules/mavlink/mavlink_mission.cpp index 557141cfccd0..692ffb52f349 100644 --- a/src/modules/mavlink/mavlink_mission.cpp +++ b/src/modules/mavlink/mavlink_mission.cpp @@ -75,7 +75,7 @@ static constexpr int MISSION_ITEM_CRC_SIZE = 32; (_msg.target_component == MAV_COMP_ID_ALL))) -static uint32_t crc32_for_mission_item(const mission_item_s &mission_item, uint32_t prev_crc32) +static uint32_t crc32_for_mission_item(const mavlink_mission_item_t &mission_item, uint32_t prev_crc32) { union { struct __attribute__((packed)) { @@ -88,12 +88,15 @@ static uint32_t crc32_for_mission_item(const mission_item_s &mission_item, uint3 } u; u.item.frame = mission_item.frame; - u.item.command = mission_item.nav_cmd; + u.item.command = mission_item.command; u.item.autocontinue = mission_item.autocontinue; - - for (int i = 0; i < 7; i++) { - u.item.params[i] = mission_item.params[i]; - } + u.item.params[0] = mission_item.param1; + u.item.params[1] = mission_item.param2; + u.item.params[2] = mission_item.param3; + u.item.params[3] = mission_item.param4; + u.item.params[4] = mission_item.x; + u.item.params[5] = mission_item.y; + u.item.params[6] = mission_item.z; return crc32part(u.raw, sizeof(u), prev_crc32); } @@ -679,7 +682,6 @@ MavlinkMissionManager::handle_message(const mavlink_message_t *msg) break; case MAVLINK_MSG_ID_COMMAND_INT: - printf("GOT A COMMAND\n"); break; default: @@ -1192,7 +1194,7 @@ MavlinkMissionManager::handle_mission_item_both(const mavlink_message_t *msg) return; } - _transfer_current_crc32 = crc32_for_mission_item(mission_item, _transfer_current_crc32); + _transfer_current_crc32 = crc32_for_mission_item(wp, _transfer_current_crc32); bool write_failed = false; bool check_failed = false;