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 }