Skip to content

Commit 7b9a09b

Browse files
committed
Don't loop in a while when sensor data are available.
Ask the number of available sensors once per update. If the sample rate is higher than the frequency at which we poll the update, we will get stuck in that while loop.
1 parent 7fa51b5 commit 7b9a09b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Arduino_BHY2Host.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ void Arduino_BHY2Host::update()
4747
if (_passthrough){
4848
eslovHandler.update();
4949
} else {
50-
while (availableSensorData() > 0) {
50+
uint8_t available = availableSensorData();
51+
for (int i = 0; i < available; i++) {
5152
SensorDataPacket data;
5253
readSensorData(data);
5354
sensorManager.process(data);

0 commit comments

Comments
 (0)