Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_EFI/AP_EFI.h
Views: 1798
/*1This program is free software: you can redistribute it and/or modify2it under the terms of the GNU General Public License as published by3the Free Software Foundation, either version 3 of the License, or4(at your option) any later version.56This program is distributed in the hope that it will be useful,7but WITHOUT ANY WARRANTY; without even the implied warranty of8MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9GNU General Public License for more details.1011You should have received a copy of the GNU General Public License12along with this program. If not, see <http://www.gnu.org/licenses/>.13*/1415#pragma once1617#include "AP_EFI_config.h"1819#if HAL_EFI_ENABLED2021#include <AP_Common/AP_Common.h>22#include <AP_Param/AP_Param.h>23#include <GCS_MAVLink/GCS_MAVLink.h>24#include "AP_EFI_ThrottleLinearisation.h"2526#include "AP_EFI_Backend.h"27#include "AP_EFI_State.h"282930/*31* This library aims to read data from Electronic Fuel Injection32* or Engine Control units. It is focused around the generic33* internal combustion engine state message provided by the34* UAVCAN protocol due to its comprehensiveness, but is extensible35* to use other forms of data transfer besides UAVCAN.36*37*38*39* Authors: Sriram Sami and David Ingraham40* With direction from Andrew Tridgell, Robert Lefebvre, Francisco Ferreira and41* Pavel Kirienko.42* Thanks to Yonah, SpektreWorks Inc, and HFE International.43*/4445class AP_EFI {46public:47friend class AP_EFI_Backend;4849// For parameter initialization50AP_EFI();5152// Initializes backend53void init(void);5455// Requests backend to update the frontend. Should be called at 10Hz.56void update();5758// Returns the RPM59uint32_t get_rpm() const { return state.engine_speed_rpm; }6061// returns enabled state of EFI62bool enabled() const { return type != Type::NONE; }6364bool is_healthy() const;6566// return timestamp of last update67uint32_t get_last_update_ms(void) const {68return state.last_updated_ms;69}7071// get a copy of state structure72void get_state(EFI_State &state);7374// Parameter info75static const struct AP_Param::GroupInfo var_info[];7677// Backend driver types78enum class Type : uint8_t {79NONE = 0,80#if AP_EFI_SERIAL_MS_ENABLED81MegaSquirt = 1,82#endif83#if AP_EFI_NWPWU_ENABLED84NWPMU = 2,85#endif86#if AP_EFI_SERIAL_LUTAN_ENABLED87Lutan = 3,88#endif89// LOWEHEISER = 4,90#if AP_EFI_DRONECAN_ENABLED91DroneCAN = 5,92#endif93#if AP_EFI_CURRAWONG_ECU_ENABLED94CurrawongECU = 6,95#endif96#if AP_EFI_SCRIPTING_ENABLED97SCRIPTING = 7,98#endif99#if AP_EFI_SERIAL_HIRTH_ENABLED100Hirth = 8,101#endif102MAV = 9,103};104105static AP_EFI *get_singleton(void) {106return singleton;107}108109// send EFI_STATUS110void send_mavlink_status(mavlink_channel_t chan);111112#if AP_SCRIPTING_ENABLED113AP_EFI_Backend* get_backend(uint8_t idx) { return idx==0?backend:nullptr; }114#endif115116void handle_EFI_message(const mavlink_message_t &msg);117118protected:119120// Back end Parameters121AP_Float coef1;122AP_Float coef2;123124AP_Float ecu_fuel_density;125126EFI_State state;127128#if AP_EFI_THROTTLE_LINEARISATION_ENABLED129AP_EFI_ThrLin throttle_linearisation;130#endif131132private:133// Front End Parameters134AP_Enum<Type> type;135136// Tracking backends137AP_EFI_Backend *backend;138static AP_EFI *singleton;139140// Semaphore for access to shared frontend data141HAL_Semaphore sem;142143// write to log144void log_status();145};146147namespace AP {148AP_EFI *EFI();149};150151#endif // HAL_EFI_ENABLED152153154