diff --git a/src/drivers/distance_sensor/ulanding/ulanding.cpp b/src/drivers/distance_sensor/ulanding/ulanding.cpp index 5f58560bcd96..7e88c4b6f3d4 100644 --- a/src/drivers/distance_sensor/ulanding/ulanding.cpp +++ b/src/drivers/distance_sensor/ulanding/ulanding.cpp @@ -360,8 +360,11 @@ bool Radar::read_and_parse(uint8_t *buf, int len, float *range) if (is_header_byte(_buf[index])) { if (no_header_counter >= BUF_LEN / 3 - 1) { if (ULANDING_VERSION == 1) { - if (((_buf[index + 1] + _buf[index + 2] + _buf[index + 3] + _buf[index + 4])) != (_buf[index + 5]) - || (_buf[index + 1] <= 0)) { + bool checksum_passed = (((_buf[index + 1] + _buf[index + 2] + _buf[index + 3] + _buf[index + 4]) & 0xFF) == _buf[index + + 5]); + + if (!checksum_passed) { + // checksum failed ret = false; break; }