From ee341bc4eb16ce89a15ad4828e2d765795dea1e9 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sat, 15 Jan 2022 13:47:15 +1100 Subject: [PATCH] SITL: add compilation option AP_SIM_CRSF_ENABLED --- libraries/AP_HAL_SITL/SITL_State.cpp | 4 ++++ libraries/AP_HAL_SITL/SITL_State.h | 2 ++ libraries/SITL/SIM_CRSF.cpp | 6 +++++- libraries/SITL/SIM_CRSF.h | 10 ++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_SITL/SITL_State.cpp b/libraries/AP_HAL_SITL/SITL_State.cpp index 842f039995..491b330a23 100644 --- a/libraries/AP_HAL_SITL/SITL_State.cpp +++ b/libraries/AP_HAL_SITL/SITL_State.cpp @@ -323,12 +323,14 @@ SITL::SerialDevice *SITL_State::create_serial_sim(const char *name, const char * // } // frsky_sport = new SITL::Frsky_SPortPassthrough(); // return frsky_sportpassthrough; +#if AP_SIM_CRSF_ENABLED } else if (streq(name, "crsf")) { if (crsf != nullptr) { AP_HAL::panic("Only one crsf at a time"); } crsf = new SITL::CRSF(); return crsf; +#endif #if HAL_SIM_PS_RPLIDARA2_ENABLED } else if (streq(name, "rplidara2")) { if (rplidara2 != nullptr) { @@ -615,9 +617,11 @@ void SITL_State::_fdm_input_local(void) // frsky_sportpassthrough->update(); // } +#if AP_SIM_CRSF_ENABLED if (crsf != nullptr) { crsf->update(); } +#endif #if HAL_SIM_PS_RPLIDARA2_ENABLED if (rplidara2 != nullptr) { diff --git a/libraries/AP_HAL_SITL/SITL_State.h b/libraries/AP_HAL_SITL/SITL_State.h index da77d0d5a5..337266f891 100644 --- a/libraries/AP_HAL_SITL/SITL_State.h +++ b/libraries/AP_HAL_SITL/SITL_State.h @@ -262,8 +262,10 @@ private: SITL::PS_TeraRangerTower *terarangertower; #endif +#if AP_SIM_CRSF_ENABLED // simulated CRSF devices SITL::CRSF *crsf; +#endif // simulated VectorNav system: SITL::VectorNav *vectornav; diff --git a/libraries/SITL/SIM_CRSF.cpp b/libraries/SITL/SIM_CRSF.cpp index c7999d0c76..535fda2269 100644 --- a/libraries/SITL/SIM_CRSF.cpp +++ b/libraries/SITL/SIM_CRSF.cpp @@ -18,6 +18,8 @@ #include "SIM_CRSF.h" +#if AP_SIM_CRSF_ENABLED + using namespace SITL; extern const AP_HAL::HAL& hal; @@ -79,4 +81,6 @@ void CRSF::update() if (_buflen == 0) { return; } -} \ No newline at end of file +} + +#endif // AP_SIM_CRSF_ENABLED diff --git a/libraries/SITL/SIM_CRSF.h b/libraries/SITL/SIM_CRSF.h index 854edad1e7..bd02e92dde 100644 --- a/libraries/SITL/SIM_CRSF.h +++ b/libraries/SITL/SIM_CRSF.h @@ -27,6 +27,14 @@ rc 3 1600 #pragma once +#include + +#ifndef AP_SIM_CRSF_ENABLED +#define AP_SIM_CRSF_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL) +#endif + +#if AP_SIM_CRSF_ENABLED + #include "SIM_Aircraft.h" #include #include "SIM_SerialDevice.h" @@ -58,3 +66,5 @@ protected: }; } + +#endif // AP_SIM_CRSF_ENABLED