Browse Source

SITL: cap digits in LightWareSerial measurements

this was hitting the buffer-length limit in the ArduPilot rangefinder
driver as soon as we hit the 100m mark
gps-1.3.1
Peter Barker 3 years ago committed by Peter Barker
parent
commit
2dd3263650
  1. 2
      libraries/SITL/SIM_RF_LightWareSerial.cpp

2
libraries/SITL/SIM_RF_LightWareSerial.cpp

@ -50,5 +50,5 @@ void RF_LightWareSerial::update(float range) @@ -50,5 +50,5 @@ void RF_LightWareSerial::update(float range)
uint32_t RF_LightWareSerial::packet_for_alt(uint16_t alt_cm, uint8_t *buffer, uint8_t buflen)
{
return snprintf((char*)buffer, buflen, "%f\r", alt_cm / 100.0f); // note tragic lack of snprintf return checking
return snprintf((char*)buffer, buflen, "%0.2f\r", alt_cm / 100.0f); // note tragic lack of snprintf return checking
}

Loading…
Cancel
Save