Keep measurements in a loop until we get a valid data point

This commit is contained in:
Fabio Manganiello 2019-09-24 10:00:56 +02:00
parent 0fe255436e
commit 876a07d2c8

View file

@ -94,12 +94,12 @@ class GpioSensorMotionPwm3901Plugin(GpioSensorPlugin):
sensor = self._get_sensor() sensor = self._get_sensor()
while True:
try: try:
x, y = sensor.get_motion() x, y = sensor.get_motion()
break
except RuntimeError as e: except RuntimeError as e:
self.logger.warning('Unable to retrieve sensor data: {}'.format(e)) time.sleep(0.01)
self._sensor = None
return {}, str(e)
secs = int(time.time()) secs = int(time.time())
if (x, y) != (self.x, self.y): if (x, y) != (self.x, self.y):