Graceful sleep between failed serial read attempts
This commit is contained in:
parent
5bc7319933
commit
c4d3e6b467
1 changed files with 2 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
import json
|
import json
|
||||||
import serial
|
import serial
|
||||||
|
import time
|
||||||
|
|
||||||
from platypush.plugins import Plugin, action
|
from platypush.plugins import Plugin, action
|
||||||
from platypush.plugins.gpio.sensor import GpioSensorPlugin
|
from platypush.plugins.gpio.sensor import GpioSensorPlugin
|
||||||
|
@ -88,6 +89,7 @@ class SerialPlugin(GpioSensorPlugin):
|
||||||
try:
|
try:
|
||||||
ser = self._get_serial()
|
ser = self._get_serial()
|
||||||
except:
|
except:
|
||||||
|
time.sleep(1)
|
||||||
ser = self._get_serial(reset=True)
|
ser = self._get_serial(reset=True)
|
||||||
|
|
||||||
data = self._read_json(ser)
|
data = self._read_json(ser)
|
||||||
|
|
Loading…
Reference in a new issue