Skip to content

Commit

Permalink
GCS_MAVLink: added lua_command_int_packet()
Browse files Browse the repository at this point in the history
for lua access to MAV_CMD_xxx
  • Loading branch information
tridge committed Jun 23, 2024
1 parent 9fdf52c commit dce6dcc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions libraries/GCS_MAVLink/GCS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,22 @@ bool GCS_MAVLINK::check_payload_size(uint16_t max_payload_len)
return true;
}

#if AP_SCRIPTING_ENABLED
/*
lua access to command_int
*/
MAV_RESULT GCS::lua_command_int_packet(const mavlink_command_int_t &packet)
{
// for now we assume channel 0. In the future we may create a dedicated channel
auto *ch = chan(0);
if (ch == nullptr) {
return MAV_RESULT_UNSUPPORTED;
}
// we need a dummy message for some calls
mavlink_message_t msg {};

return ch->handle_command_int_packet(packet, msg);
}
#endif // AP_SCRIPTING_ENABLED

#endif // HAL_GCS_ENABLED
5 changes: 5 additions & 0 deletions libraries/GCS_MAVLink/GCS.h
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,11 @@ class GCS

virtual uint8_t sysid_this_mav() const = 0;

#if AP_SCRIPTING_ENABLED
// lua access to command_int
MAV_RESULT lua_command_int_packet(const mavlink_command_int_t &packet);
#endif

protected:

virtual GCS_MAVLINK *new_gcs_mavlink_backend(GCS_MAVLINK_Parameters &params,
Expand Down

0 comments on commit dce6dcc

Please sign in to comment.