AP_Scripting: allow scripts to get modes

This commit is contained in:
Tatsuya Yamaguchi 2020-01-09 23:45:47 +09:00 committed by Andrew Tridgell
parent 1309101a4b
commit 2c9e56c4b2
3 changed files with 17 additions and 2 deletions

View File

@ -144,6 +144,7 @@ singleton GCS method set_message_interval MAV_RESULT'enum uint8_t 0 MAVLINK_COMM
include AP_Vehicle/AP_Vehicle.h
singleton AP_Vehicle alias vehicle
singleton AP_Vehicle method set_mode boolean uint8_t 0 UINT8_MAX ModeReason::SCRIPTING'literal
singleton AP_Vehicle method get_mode uint8_t
include AP_SerialLED/AP_SerialLED.h
singleton AP_SerialLED alias serialLED

View File

@ -1,4 +1,4 @@
// auto generated bindings, don't manually edit
// auto generated bindings, don't manually edit. See README.md for details.
#include "lua_generated_bindings.h"
#include "lua_boxed_numerics.h"
#include <RC_Channel/RC_Channel.h>
@ -625,6 +625,19 @@ static int AP_SerialLED_set_num_LEDs(lua_State *L) {
return 1;
}
static int AP_Vehicle_get_mode(lua_State *L) {
AP_Vehicle * ud = AP_Vehicle::get_singleton();
if (ud == nullptr) {
return luaL_argerror(L, 1, "vehicle not supported on this firmware");
}
binding_argcheck(L, 1);
const uint8_t data = ud->get_mode();
lua_pushinteger(L, data);
return 1;
}
static int AP_Vehicle_set_mode(lua_State *L) {
AP_Vehicle * ud = AP_Vehicle::get_singleton();
if (ud == nullptr) {
@ -1782,6 +1795,7 @@ const luaL_Reg AP_SerialLED_meta[] = {
};
const luaL_Reg AP_Vehicle_meta[] = {
{"get_mode", AP_Vehicle_get_mode},
{"set_mode", AP_Vehicle_set_mode},
{NULL, NULL}
};

View File

@ -1,5 +1,5 @@
#pragma once
// auto generated bindings, don't manually edit
// auto generated bindings, don't manually edit. See README.md for details.
#include <RC_Channel/RC_Channel.h>
#include <SRV_Channel/SRV_Channel.h>
#include <AP_SerialLED/AP_SerialLED.h>