From 53997a284b22d158445c9e4b1d9fac08c894a48c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 21 Jul 2022 11:19:55 +1000 Subject: [PATCH] AP_HAL_SITL: fixes from --ubsan autotest --- libraries/AP_HAL_SITL/SITL_State.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/AP_HAL_SITL/SITL_State.cpp b/libraries/AP_HAL_SITL/SITL_State.cpp index 33c9433041..e728ab2204 100644 --- a/libraries/AP_HAL_SITL/SITL_State.cpp +++ b/libraries/AP_HAL_SITL/SITL_State.cpp @@ -880,11 +880,11 @@ void SITL_State::_simulator_servos(struct sitl_input &input) } // assume 3DR power brick - voltage_pin_value = ((voltage / 10.1f) / 5.0f) * 1024; - current_pin_value = ((_current / 17.0f) / 5.0f) * 1024; + voltage_pin_value = float_to_uint16(((voltage / 10.1f) / 5.0f) * 1024); + current_pin_value = float_to_uint16(((_current / 17.0f) / 5.0f) * 1024); // fake battery2 as just a 25% gain on the first one - voltage2_pin_value = ((voltage * 0.25f / 10.1f) / 5.0f) * 1024; - current2_pin_value = ((_current * 0.25f / 17.0f) / 5.0f) * 1024; + voltage2_pin_value = float_to_uint16(((voltage * 0.25f / 10.1f) / 5.0f) * 1024); + current2_pin_value = float_to_uint16(((_current * 0.25f / 17.0f) / 5.0f) * 1024); } void SITL_State::init(int argc, char * const argv[])