diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_JRE_Serial.cpp b/libraries/AP_RangeFinder/AP_RangeFinder_JRE_Serial.cpp index 1fb9375fd7a23..b360aa4d65f67 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_JRE_Serial.cpp +++ b/libraries/AP_RangeFinder/AP_RangeFinder_JRE_Serial.cpp @@ -31,7 +31,7 @@ void AP_RangeFinder_JRE_Serial::move_preamble_in_buffer(uint8_t search_start_pos) { uint8_t i; - for (i=search_start_pos; i 0) { // fill buffer - const auto num_bytes_to_read = MIN(bytes_available, ARRAY_SIZE(data_buff) - data_buff_idx); - const auto num_bytes_read = uart->read(&data_buff[data_buff_idx], num_bytes_to_read); + const auto num_bytes_to_read = MIN(bytes_available, ARRAY_SIZE(data_buff) - data_buff_ofs); + const auto num_bytes_read = uart->read(&data_buff[data_buff_ofs], num_bytes_to_read); if (num_bytes_read == 0) { break; } @@ -71,13 +71,13 @@ bool AP_RangeFinder_JRE_Serial::get_reading(float &reading_m) break; } bytes_available -= num_bytes_read; - data_buff_idx += num_bytes_read; + data_buff_ofs += num_bytes_read; // move header frame header in buffer move_preamble_in_buffer(0); // ensure we have a packet type: - if (data_buff_idx < 2) { + if (data_buff_ofs < 2) { continue; } @@ -99,7 +99,7 @@ bool AP_RangeFinder_JRE_Serial::get_reading(float &reading_m) } // check there are enough bytes for message type - if (data_buff_idx < packet_length) { + if (data_buff_ofs < packet_length) { continue; } diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_JRE_Serial.h b/libraries/AP_RangeFinder/AP_RangeFinder_JRE_Serial.h index 9415b50e19808..df9fd1b00cc64 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_JRE_Serial.h +++ b/libraries/AP_RangeFinder/AP_RangeFinder_JRE_Serial.h @@ -95,7 +95,7 @@ class AP_RangeFinder_JRE_Serial : public AP_RangeFinder_Backend_Serial void move_preamble_in_buffer(uint8_t search_start_pos); uint8_t data_buff[48 * 3]; // 48 is longest possible packet - uint8_t data_buff_idx; + uint8_t data_buff_ofs; // index where next item will be added in data_buff bool no_signal; // true if the latest read attempt found no valid distances };