From 9706a207b109d3f6216826a735455b8462bac201 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 Aug 2023 06:17:37 +1000 Subject: [PATCH] AP_Terrain: fixed build for periph needed for SITL periph rangefinder --- libraries/AP_Terrain/AP_Terrain.cpp | 2 +- libraries/AP_Terrain/TerrainGCS.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Terrain/AP_Terrain.cpp b/libraries/AP_Terrain/AP_Terrain.cpp index 736e0ec9ba..7e9e754036 100644 --- a/libraries/AP_Terrain/AP_Terrain.cpp +++ b/libraries/AP_Terrain/AP_Terrain.cpp @@ -487,7 +487,7 @@ bool AP_Terrain::allocate(void) } cache = (struct grid_cache *)calloc(TERRAIN_GRID_BLOCK_CACHE_SIZE, sizeof(cache[0])); if (cache == nullptr) { - gcs().send_text(MAV_SEVERITY_CRITICAL, "Terrain: Allocation failed"); + GCS_SEND_TEXT(MAV_SEVERITY_CRITICAL, "Terrain: Allocation failed"); memory_alloc_failed = true; return false; } diff --git a/libraries/AP_Terrain/TerrainGCS.cpp b/libraries/AP_Terrain/TerrainGCS.cpp index 921120a230..8ad7ae352e 100644 --- a/libraries/AP_Terrain/TerrainGCS.cpp +++ b/libraries/AP_Terrain/TerrainGCS.cpp @@ -37,6 +37,9 @@ extern const AP_HAL::HAL& hal; */ bool AP_Terrain::request_missing(mavlink_channel_t chan, struct grid_cache &gcache) { +#if !HAL_GCS_ENABLED + return false; +#else struct grid_block &grid = gcache.grid; if (options.get() & uint16_t(Options::DisableDownload)) { @@ -72,6 +75,7 @@ bool AP_Terrain::request_missing(mavlink_channel_t chan, struct grid_cache &gcac last_request_time_ms[chan] = AP_HAL::millis(); return true; +#endif } /* @@ -211,6 +215,7 @@ void AP_Terrain::handle_data(mavlink_channel_t chan, const mavlink_message_t &ms */ void AP_Terrain::send_terrain_report(mavlink_channel_t chan, const Location &loc, bool extrapolate) { +#if HAL_GCS_ENABLED float terrain_height = 0; uint16_t spacing = 0; if (height_amsl(loc, terrain_height)) { @@ -232,6 +237,7 @@ void AP_Terrain::send_terrain_report(mavlink_channel_t chan, const Location &loc terrain_height, current_height, pending, loaded); } +#endif } /*