mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-18 06:38:29 -04:00
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_NWPMU.h"
|
||||||
#include "AP_EFI_DroneCAN.h"
|
#include "AP_EFI_DroneCAN.h"
|
||||||
#include "AP_EFI_Currawong_ECU.h"
|
#include "AP_EFI_Currawong_ECU.h"
|
||||||
|
#include "AP_EFI_Scripting.h"
|
||||||
|
|
||||||
#include <AP_Logger/AP_Logger.h>
|
#include <AP_Logger/AP_Logger.h>
|
||||||
#include <GCS_MAVLink/GCS.h>
|
#include <GCS_MAVLink/GCS.h>
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ const AP_Param::GroupInfo AP_EFI::var_info[] = {
|
|||||||
// @Param: _TYPE
|
// @Param: _TYPE
|
||||||
// @DisplayName: EFI communication type
|
// @DisplayName: EFI communication type
|
||||||
// @Description: What method of communication is used for EFI #1
|
// @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
|
// @User: Advanced
|
||||||
// @RebootRequired: True
|
// @RebootRequired: True
|
||||||
AP_GROUPINFO_FLAGS("_TYPE", 1, AP_EFI, type, 0, AP_PARAM_FLAG_ENABLE),
|
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:
|
case Type::CurrawongECU:
|
||||||
#if HAL_EFI_CURRAWONG_ECU_ENABLED
|
#if HAL_EFI_CURRAWONG_ECU_ENABLED
|
||||||
backend = new AP_EFI_Currawong_ECU(*this);
|
backend = new AP_EFI_Currawong_ECU(*this);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case Type::SCRIPTING:
|
||||||
|
#if AP_EFI_SCRIPTING_ENABLED
|
||||||
|
backend = new AP_EFI_Scripting(*this);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -272,6 +279,19 @@ void AP_EFI::get_state(EFI_State &_state)
|
|||||||
_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 {
|
namespace AP {
|
||||||
AP_EFI *EFI()
|
AP_EFI *EFI()
|
||||||
{
|
{
|
||||||
|
@ -78,11 +78,12 @@ public:
|
|||||||
enum class Type : uint8_t {
|
enum class Type : uint8_t {
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
MegaSquirt = 1,
|
MegaSquirt = 1,
|
||||||
NWPMU = 2,
|
NWPMU = 2,
|
||||||
Lutan = 3,
|
Lutan = 3,
|
||||||
// LOWEHEISER = 4,
|
// LOWEHEISER = 4,
|
||||||
DroneCAN = 5,
|
DroneCAN = 5,
|
||||||
CurrawongECU = 6,
|
CurrawongECU = 6,
|
||||||
|
SCRIPTING = 7,
|
||||||
};
|
};
|
||||||
|
|
||||||
static AP_EFI *get_singleton(void) {
|
static AP_EFI *get_singleton(void) {
|
||||||
@ -92,6 +93,11 @@ public:
|
|||||||
// send EFI_STATUS
|
// send EFI_STATUS
|
||||||
void send_mavlink_status(mavlink_channel_t chan);
|
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:
|
protected:
|
||||||
|
|
||||||
// Back end Parameters
|
// Back end Parameters
|
||||||
|
@ -31,6 +31,10 @@ public:
|
|||||||
// Update the state structure
|
// Update the state structure
|
||||||
virtual void update() = 0;
|
virtual void update() = 0;
|
||||||
|
|
||||||
|
#if AP_SCRIPTING_ENABLED
|
||||||
|
virtual void handle_scripting(const EFI_State &efi_state) { return; }
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Copies internal state to the frontend state
|
// Copies internal state to the frontend state
|
||||||
void copy_to_frontend();
|
void copy_to_frontend();
|
||||||
|
18
libraries/AP_EFI/AP_EFI_Scripting.cpp
Normal file
18
libraries/AP_EFI/AP_EFI_Scripting.cpp
Normal file
@ -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
|
20
libraries/AP_EFI/AP_EFI_Scripting.h
Normal file
20
libraries/AP_EFI/AP_EFI_Scripting.h
Normal file
@ -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
Block a user