Graceful sleep between failed serial read attempts

This commit is contained in:
Fabio Manganiello 2018-07-17 23:51:30 +02:00
parent 5bc7319933
commit c4d3e6b467
1 changed files with 2 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import json
import serial
import time
from platypush.plugins import Plugin, action
from platypush.plugins.gpio.sensor import GpioSensorPlugin
@ -88,6 +89,7 @@ class SerialPlugin(GpioSensorPlugin):
try:
ser = self._get_serial()
except:
time.sleep(1)
ser = self._get_serial(reset=True)
data = self._read_json(ser)