diff --git a/libraries/AP_EFI/AP_EFI.cpp b/libraries/AP_EFI/AP_EFI.cpp index 4736b79dfd..4dd7b298b2 100644 --- a/libraries/AP_EFI/AP_EFI.cpp +++ b/libraries/AP_EFI/AP_EFI.cpp @@ -277,18 +277,6 @@ void AP_EFI::get_state(EFI_State &_state) _state = state; } -#if AP_EFI_SCRIPTING_ENABLED && AP_SCRIPTING_ENABLED - -void AP_EFI::handle_scripting(const EFI_State &efi_state) -{ - if (!backend || (Type(type.get()) != Type::SCRIPTING)) { - return; - } - backend->handle_scripting(efi_state); -} - -#endif - namespace AP { AP_EFI *EFI() { diff --git a/libraries/AP_EFI/AP_EFI.h b/libraries/AP_EFI/AP_EFI.h index b4e4ac5050..1fefdd5972 100644 --- a/libraries/AP_EFI/AP_EFI.h +++ b/libraries/AP_EFI/AP_EFI.h @@ -94,8 +94,7 @@ public: void send_mavlink_status(mavlink_channel_t chan); #if AP_SCRIPTING_ENABLED - // Ingest EFI_State from scripting driver - void handle_scripting(const EFI_State &efi_state); + AP_EFI_Backend* get_backend(uint8_t idx) { return idx==0?backend:nullptr; } #endif protected: diff --git a/libraries/AP_EFI/AP_EFI_Backend.h b/libraries/AP_EFI/AP_EFI_Backend.h index 3b3e631691..9506c7ff09 100644 --- a/libraries/AP_EFI/AP_EFI_Backend.h +++ b/libraries/AP_EFI/AP_EFI_Backend.h @@ -32,7 +32,7 @@ public: virtual void update() = 0; #if AP_SCRIPTING_ENABLED - virtual void handle_scripting(const EFI_State &efi_state) { return; } + virtual bool handle_scripting(const EFI_State &efi_state) { return false; } #endif protected: diff --git a/libraries/AP_EFI/AP_EFI_Scripting.cpp b/libraries/AP_EFI/AP_EFI_Scripting.cpp index 2467a3002b..8a4b2f73a0 100644 --- a/libraries/AP_EFI/AP_EFI_Scripting.cpp +++ b/libraries/AP_EFI/AP_EFI_Scripting.cpp @@ -9,10 +9,11 @@ void AP_EFI_Scripting::update() } // handle EFI message from scripting -void AP_EFI_Scripting::handle_scripting(const EFI_State &efi_state) +bool AP_EFI_Scripting::handle_scripting(const EFI_State &efi_state) { internal_state = efi_state; copy_to_frontend(); + return true; } #endif // AP_EFI_SCRIPTING_ENABLED diff --git a/libraries/AP_EFI/AP_EFI_Scripting.h b/libraries/AP_EFI/AP_EFI_Scripting.h index 78a542ed1b..4bd5ed1f90 100644 --- a/libraries/AP_EFI/AP_EFI_Scripting.h +++ b/libraries/AP_EFI/AP_EFI_Scripting.h @@ -3,10 +3,6 @@ #include "AP_EFI.h" #include "AP_EFI_Backend.h" -#ifndef AP_EFI_SCRIPTING_ENABLED -#define AP_EFI_SCRIPTING_ENABLED (HAL_EFI_ENABLED && AP_SCRIPTING_ENABLED) -#endif - #if AP_EFI_SCRIPTING_ENABLED class AP_EFI_Scripting : public AP_EFI_Backend { @@ -15,6 +11,6 @@ public: void update() override; - void handle_scripting(const EFI_State &efi_state) override; + bool handle_scripting(const EFI_State &efi_state) override; }; #endif // AP_EFI_SCRIPTING_ENABLED diff --git a/libraries/AP_EFI/AP_EFI_config.h b/libraries/AP_EFI/AP_EFI_config.h index 9cbc0a059e..37669582f6 100644 --- a/libraries/AP_EFI/AP_EFI_config.h +++ b/libraries/AP_EFI/AP_EFI_config.h @@ -5,3 +5,7 @@ #ifndef HAL_EFI_ENABLED #define HAL_EFI_ENABLED !HAL_MINIMIZE_FEATURES && BOARD_FLASH_SIZE > 1024 #endif + +#ifndef AP_EFI_SCRIPTING_ENABLED +#define AP_EFI_SCRIPTING_ENABLED (HAL_EFI_ENABLED && AP_SCRIPTING_ENABLED) +#endif