From 0f5dd400527c682aad1d4837f946afd66acd8812 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 25 Mar 2021 12:48:59 +1100 Subject: [PATCH] AP_Compass: removed assert calls these waste flash space and do not do us any good --- libraries/AP_Compass/AP_Compass_AK09916.cpp | 4 +++- libraries/AP_Compass/AP_Compass_AK8963.cpp | 4 +++- libraries/AP_Compass/AP_Compass_HMC5843.cpp | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/AP_Compass/AP_Compass_AK09916.cpp b/libraries/AP_Compass/AP_Compass_AK09916.cpp index 7cddd0a3d1..542f48869b 100644 --- a/libraries/AP_Compass/AP_Compass_AK09916.cpp +++ b/libraries/AP_Compass/AP_Compass_AK09916.cpp @@ -391,7 +391,9 @@ bool AP_AK09916_BusDriver_Auxiliary::block_read(uint8_t reg, uint8_t *buf, uint3 * We can only read a block when reading the block of sample values - * calling with any other value is a mistake */ - assert(reg == REG_ST1); + if (reg != REG_ST1) { + return false; + } int n = _slave->read(buf); return n == static_cast(size); diff --git a/libraries/AP_Compass/AP_Compass_AK8963.cpp b/libraries/AP_Compass/AP_Compass_AK8963.cpp index 6aff89c3b6..f6d88ef885 100644 --- a/libraries/AP_Compass/AP_Compass_AK8963.cpp +++ b/libraries/AP_Compass/AP_Compass_AK8963.cpp @@ -328,7 +328,9 @@ bool AP_AK8963_BusDriver_Auxiliary::block_read(uint8_t reg, uint8_t *buf, uint32 * We can only read a block when reading the block of sample values - * calling with any other value is a mistake */ - assert(reg == AK8963_HXL); + if (reg != AK8963_HXL) { + return false; + } int n = _slave->read(buf); return n == static_cast(size); diff --git a/libraries/AP_Compass/AP_Compass_HMC5843.cpp b/libraries/AP_Compass/AP_Compass_HMC5843.cpp index 6ec621bf32..189453122e 100644 --- a/libraries/AP_Compass/AP_Compass_HMC5843.cpp +++ b/libraries/AP_Compass/AP_Compass_HMC5843.cpp @@ -521,7 +521,9 @@ bool AP_HMC5843_BusDriver_Auxiliary::block_read(uint8_t reg, uint8_t *buf, uint3 * We can only read a block when reading the block of sample values - * calling with any other value is a mistake */ - assert(reg == HMC5843_REG_DATA_OUTPUT_X_MSB); + if (reg != HMC5843_REG_DATA_OUTPUT_X_MSB) { + return false; + } int n = _slave->read(buf); return n == static_cast(size);