MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / lua_mavlink_block_command

Function lua_mavlink_block_command

libraries/AP_Scripting/lua_bindings.cpp:196–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196int lua_mavlink_block_command(lua_State *L) {
197
198 // Allow : and . access
199 const int arg_offset = (luaL_testudata(L, 1, "mavlink") != NULL) ? 1 : 0;
200
201 binding_argcheck(L, 1+arg_offset);
202
203 const uint16_t id = get_uint16_t(L, 1+arg_offset);
204
205 // Check if ID is already registered
206 if (AP::scripting()->is_handling_command(id)) {
207 lua_pushboolean(L, true);
208 return 1;
209 }
210
211 // Add new list item
212 AP_Scripting::command_block_list *new_item = NEW_NOTHROW AP_Scripting::command_block_list;
213 if (new_item == nullptr) {
214 lua_pushboolean(L, false);
215 return 1;
216 }
217 new_item->id = id;
218
219 {
220 WITH_SEMAPHORE(AP::scripting()->mavlink_command_block_list_sem);
221 new_item->next = AP::scripting()->mavlink_command_block_list;
222 AP::scripting()->mavlink_command_block_list = new_item;
223 }
224
225 lua_pushboolean(L, true);
226 return 1;
227}
228#endif // HAL_GCS_ENABLED
229
230#if AP_MISSION_ENABLED

Callers

nothing calls this directly

Calls 4

luaL_testudataFunction · 0.85
scriptingFunction · 0.85
lua_pushbooleanFunction · 0.85
is_handling_commandMethod · 0.80

Tested by

no test coverage detected