mirror of https://github.com/ArduPilot/ardupilot
AP_EFI: add EFI scripting driver
This commit is contained in:
parent
d3c014ca35
commit
f74ad276a9
|
@ -22,6 +22,8 @@
|
|||
#include "AP_EFI_NWPMU.h"
|
||||
#include "AP_EFI_DroneCAN.h"
|
||||
#include "AP_EFI_Currawong_ECU.h"
|
||||
#include "AP_EFI_Scripting.h"
|
||||
|
||||
#include <AP_Logger/AP_Logger.h>
|
||||
#include <GCS_MAVLink/GCS.h>
|
||||
|
||||
|
@ -36,7 +38,7 @@ const AP_Param::GroupInfo AP_EFI::var_info[] = {
|
|||
// @Param: _TYPE
|
||||
// @DisplayName: EFI communication type
|
||||
// @Description: What method of communication is used for EFI #1
|
||||
// @Values: 0:None,1:Serial-MS,2:NWPMU,3:Serial-Lutan,5:DroneCAN,6:Currawong-ECU
|
||||
// @Values: 0:None,1:Serial-MS,2:NWPMU,3:Serial-Lutan,5:DroneCAN,6:Currawong-ECU,7:Scripting
|
||||
// @User: Advanced
|
||||
// @RebootRequired: True
|
||||
AP_GROUPINFO_FLAGS("_TYPE", 1, AP_EFI, type, 0, AP_PARAM_FLAG_ENABLE),
|
||||
|
@ -104,6 +106,11 @@ void AP_EFI::init(void)
|
|||
case Type::CurrawongECU:
|
||||
#if HAL_EFI_CURRAWONG_ECU_ENABLED
|
||||
backend = new AP_EFI_Currawong_ECU(*this);
|
||||
#endif
|
||||
break;
|
||||
case Type::SCRIPTING:
|
||||
#if AP_EFI_SCRIPTING_ENABLED
|
||||
backend = new AP_EFI_Scripting(*this);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
|
@ -272,6 +279,19 @@ 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()
|
||||
{
|
||||
|
|
|
@ -78,11 +78,12 @@ public:
|
|||
enum class Type : uint8_t {
|
||||
NONE = 0,
|
||||
MegaSquirt = 1,
|
||||
NWPMU = 2,
|
||||
Lutan = 3,
|
||||
NWPMU = 2,
|
||||
Lutan = 3,
|
||||
// LOWEHEISER = 4,
|
||||
DroneCAN = 5,
|
||||
CurrawongECU = 6,
|
||||
SCRIPTING = 7,
|
||||
};
|
||||
|
||||
static AP_EFI *get_singleton(void) {
|
||||
|
@ -92,6 +93,11 @@ public:
|
|||
// send EFI_STATUS
|
||||
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);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
// Back end Parameters
|
||||
|
|
|
@ -31,6 +31,10 @@ public:
|
|||
// Update the state structure
|
||||
virtual void update() = 0;
|
||||
|
||||
#if AP_SCRIPTING_ENABLED
|
||||
virtual void handle_scripting(const EFI_State &efi_state) { return; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// Copies internal state to the frontend state
|
||||
void copy_to_frontend();
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#include "AP_EFI_Scripting.h"
|
||||
|
||||
#if AP_EFI_SCRIPTING_ENABLED
|
||||
|
||||
// Called from frontend to update with the readings received by handler
|
||||
void AP_EFI_Scripting::update()
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
// handle EFI message from scripting
|
||||
void AP_EFI_Scripting::handle_scripting(const EFI_State &efi_state)
|
||||
{
|
||||
internal_state = efi_state;
|
||||
copy_to_frontend();
|
||||
}
|
||||
|
||||
#endif // AP_EFI_SCRIPTING_ENABLED
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#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 {
|
||||
public:
|
||||
using AP_EFI_Backend::AP_EFI_Backend;
|
||||
|
||||
void update() override;
|
||||
|
||||
void handle_scripting(const EFI_State &efi_state) override;
|
||||
};
|
||||
#endif // AP_EFI_SCRIPTING_ENABLED
|
Loading…
Reference in New Issue