Line data Source code
1 : /* 2 : This program is free software: you can redistribute it and/or modify 3 : it under the terms of the GNU General Public License as published by 4 : the Free Software Foundation, either version 3 of the License, or 5 : (at your option) any later version. 6 : This program is distributed in the hope that it will be useful, 7 : but WITHOUT ANY WARRANTY; without even the implied warranty of 8 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 : GNU General Public License for more details. 10 : You should have received a copy of the GNU General Public License 11 : along with this program. If not, see <http://www.gnu.org/licenses/>. 12 : */ 13 : 14 : #include "AP_EFI_config.h" 15 : 16 : #if AP_EFI_MAV_ENABLED 17 : 18 : #include "AP_EFI_MAV.h" 19 : #include <AP_Math/AP_Math.h> 20 : 21 : //Called from frontend to update with the readings received by handler 22 0 : void AP_EFI_MAV::update() 23 : { 24 0 : if (receivedNewData) { 25 0 : copy_to_frontend(); 26 0 : receivedNewData = false; 27 : } 28 0 : } 29 : 30 : //Decode MavLink message 31 0 : void AP_EFI_MAV::handle_EFI_message(const mavlink_message_t &msg) 32 : { 33 : mavlink_efi_status_t state; 34 0 : mavlink_msg_efi_status_decode(&msg, &state); 35 : 36 0 : internal_state.ecu_index = state.ecu_index; 37 0 : internal_state.engine_speed_rpm = state.rpm; 38 0 : internal_state.estimated_consumed_fuel_volume_cm3 = state.fuel_consumed; 39 0 : internal_state.fuel_consumption_rate_cm3pm = state.fuel_flow; 40 0 : internal_state.engine_load_percent = state.engine_load; 41 0 : internal_state.throttle_position_percent = state.throttle_position; 42 0 : internal_state.spark_dwell_time_ms = state.spark_dwell_time; 43 0 : internal_state.atmospheric_pressure_kpa = state.barometric_pressure; 44 0 : internal_state.intake_manifold_pressure_kpa = state.intake_manifold_pressure; 45 0 : internal_state.intake_manifold_temperature = C_TO_KELVIN(state.intake_manifold_temperature); 46 0 : internal_state.cylinder_status.cylinder_head_temperature = C_TO_KELVIN(state.cylinder_head_temperature); 47 0 : internal_state.cylinder_status.ignition_timing_deg = state.ignition_timing; 48 0 : internal_state.cylinder_status.injection_time_ms = state.injection_time; 49 0 : internal_state.cylinder_status.exhaust_gas_temperature = C_TO_KELVIN(state.exhaust_gas_temperature); 50 0 : internal_state.throttle_out = state.throttle_out; 51 0 : internal_state.pt_compensation = state.pt_compensation; 52 : //internal_state.??? = state.health; 53 0 : internal_state.ignition_voltage = state.ignition_voltage; 54 : 55 0 : receivedNewData = true; 56 0 : } 57 : 58 : #endif // AP_EFI_MAV_ENABLED