diff --git a/libraries/AP_Proximity/AP_Proximity_LightWareSF40C.cpp b/libraries/AP_Proximity/AP_Proximity_LightWareSF40C.cpp index 82076d17f9..9f44882b4e 100644 --- a/libraries/AP_Proximity/AP_Proximity_LightWareSF40C.cpp +++ b/libraries/AP_Proximity/AP_Proximity_LightWareSF40C.cpp @@ -383,8 +383,8 @@ bool AP_Proximity_LightWareSF40C::process_reply() case RequestType_Health: // expect result in the form "0xhhhh" if (element_len[0] > 0) { - int result; - if (sscanf(element_buf[0], "%x", &result) > 0) { + long int result = strtol(element_buf[0], nullptr, 16); + if (result > 0) { _sensor_status.value = result; success = true; }