From 8843c17f9d5c9fd2beed85876f4475156c92707d Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 9 Sep 2021 12:08:02 +1000 Subject: [PATCH] SITL: LightwareSerial: return 130m when out-of-range-high --- libraries/SITL/SIM_RF_LightWareSerial.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/SITL/SIM_RF_LightWareSerial.cpp b/libraries/SITL/SIM_RF_LightWareSerial.cpp index ef6299fcd8..bf44e40806 100644 --- a/libraries/SITL/SIM_RF_LightWareSerial.cpp +++ b/libraries/SITL/SIM_RF_LightWareSerial.cpp @@ -50,5 +50,10 @@ void RF_LightWareSerial::update(float range) uint32_t RF_LightWareSerial::packet_for_alt(uint16_t alt_cm, uint8_t *buffer, uint8_t buflen) { + if (alt_cm > 10000) { + // out-of-range-high + alt_cm = 13000; // from datasheet + } + return snprintf((char*)buffer, buflen, "%0.2f\r", alt_cm / 100.0f); // note tragic lack of snprintf return checking }