sensor/vehicle_magnetometer: sensor update loop limit iterations

- place upper bound to prevent looping indefinitely (high publish rate, etc)
This commit is contained in:
Daniel Agar 2024-03-04 12:55:38 -05:00
parent c5835a48de
commit d96970a2b9
1 changed files with 3 additions and 1 deletions

View File

@ -461,9 +461,11 @@ void VehicleMagnetometer::Run()
}
if (_advertised[uorb_index]) {
int sensor_mag_updates = 0;
sensor_mag_s report;
while (_sensor_sub[uorb_index].update(&report)) {
while ((sensor_mag_updates < sensor_mag_s::ORB_QUEUE_LENGTH) && _sensor_sub[uorb_index].update(&report)) {
sensor_mag_updates++;
if (_calibration[uorb_index].device_id() != report.device_id) {
_calibration[uorb_index].set_device_id(report.device_id);