From 2abdb59d8e883783dc4d2432786d896b363c3674 Mon Sep 17 00:00:00 2001 From: gonzoveliki Date: Wed, 19 Jun 2024 01:23:25 +0300 Subject: [PATCH] Sending ign/start via Telemetry TX --- libraries/AP_EFI/AP_EFI_Serial_FH.cpp | 20 +++++++++++++++++--- libraries/AP_EFI/AP_EFI_Serial_FH.h | 3 +++ libraries/AP_ICEngine/AP_ICEngine.h | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/libraries/AP_EFI/AP_EFI_Serial_FH.cpp b/libraries/AP_EFI/AP_EFI_Serial_FH.cpp index 2d182dd5416a3..93c6e93750bb8 100644 --- a/libraries/AP_EFI/AP_EFI_Serial_FH.cpp +++ b/libraries/AP_EFI/AP_EFI_Serial_FH.cpp @@ -58,7 +58,7 @@ AP_EFI_Serial_FH::AP_EFI_Serial_FH(AP_EFI &_frontend): } static unsigned char boza = 0; - +#include "../AP_ICEngine/AP_ICEngine.h" void AP_EFI_Serial_FH::update() { const uint32_t now = AP_HAL::millis(); @@ -95,8 +95,22 @@ void AP_EFI_Serial_FH::update() void AP_EFI_Serial_FH::send_request(void) { - static uint8_t d[] = { 0, 'A', 'L', 'F', '!' }; - d[0]=boza; + static uint8_t d[] = { 0, 0, 'A', 'L', 'F' }; + + uint8_t kur=0; + switch (AP::ice()->state) { + + case AP_ICEngine::ICE_DISABLED: kur = 0xFF; break; + case AP_ICEngine::ICE_OFF: kur = 0; break; + case AP_ICEngine::ICE_START_HEIGHT_DELAY: + case AP_ICEngine::ICE_START_DELAY: kur = 1; break; + case AP_ICEngine::ICE_STARTING: kur = 2; break; + case AP_ICEngine::ICE_RUNNING: kur = 3; break; + default:break; + } + + d[0] = boza; + d[1] = kur; // const uint32_t crc = ~crc_crc32(~0U, &d[2], sizeof(d)-2); // const uint32_t crc2 = htobe32(crc); port->write(d, sizeof(d)); diff --git a/libraries/AP_EFI/AP_EFI_Serial_FH.h b/libraries/AP_EFI/AP_EFI_Serial_FH.h index a9eb31614cf12..8e50173a9f336 100644 --- a/libraries/AP_EFI/AP_EFI_Serial_FH.h +++ b/libraries/AP_EFI/AP_EFI_Serial_FH.h @@ -24,8 +24,11 @@ #include "AP_EFI.h" #include "AP_EFI_Backend.h" +#include "../AP_ICEngine/AP_ICEngine.h" + class AP_EFI_Serial_FH: public AP_EFI_Backend { + friend AP_ICEngine; public: // Constructor with initialization AP_EFI_Serial_FH(AP_EFI &_frontend); diff --git a/libraries/AP_ICEngine/AP_ICEngine.h b/libraries/AP_ICEngine/AP_ICEngine.h index 351302e7638f0..5441054fcf1db 100644 --- a/libraries/AP_ICEngine/AP_ICEngine.h +++ b/libraries/AP_ICEngine/AP_ICEngine.h @@ -73,7 +73,7 @@ class AP_ICEngine { static AP_ICEngine *get_singleton() { return _singleton; } -private: +//!!private: static AP_ICEngine *_singleton; void set_ignition(bool on);