AP_Scripting: add new mavlink binding to block commands

This commit is contained in:
Iampete1 authored and Andrew Tridgell committed 2023-07-04 10:20:42 +10:00
1 parent 5cefff6455
commit 1c5f3c708a
6 files changed
+75

No files matched your search

+26
View File
@@ -259,6 +259,16 @@ void AP_Scripting::thread(void) {
}
num_pwm_source = 0;
// Clear blocked commands
{
WITH_SEMAPHORE(mavlink_command_block_list_sem);
while (mavlink_command_block_list != nullptr) {
command_block_list *next_item = mavlink_command_block_list->next;
delete mavlink_command_block_list;
mavlink_command_block_list = next_item;
}
}
bool cleared = false;
while(true) {
// 1hz check if we should restart
@@ -361,6 +371,22 @@ void AP_Scripting::handle_message(const mavlink_message_t &msg, const mavlink_ch
}
}
bool AP_Scripting::is_handling_command(uint16_t cmd_id)
{
WITH_SEMAPHORE(mavlink_command_block_list_sem);
// Look in linked list to see if id is registered
if (mavlink_command_block_list != nullptr) {
for (command_block_list *item = mavlink_command_block_list; item; item = item->next) {
if (item->id == cmd_id) {
return true;
}
}
}
return false;
}
AP_Scripting *AP_Scripting::_singleton = nullptr;
namespace AP {