Skip to content

Commit

Permalink
mavlink-mission: use mavlink_mission_item for crc calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasDebrunner committed Nov 23, 2021
1 parent 4e85014 commit 46f0132
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/modules/mavlink/mavlink_mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 46f0132

Please sign in to comment.