summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dobrowolski <admin@tastycode.pl>2017-12-08 20:42:22 +0100
committerPiotr Dobrowolski <admin@tastycode.pl>2017-12-08 20:42:22 +0100
commit615293aba8758cf0b632c4cfedcc2b3869c360b1 (patch)
treef7cd5945172f872e5ff1de9a14da820258ce6a4c
parent37b3b9d5fe5de14c9d6bf324e60bf3597249796a (diff)
downloadbitvend-615293aba8758cf0b632c4cfedcc2b3869c360b1.tar.gz
bitvend-615293aba8758cf0b632c4cfedcc2b3869c360b1.tar.bz2
bitvend-615293aba8758cf0b632c4cfedcc2b3869c360b1.tar.xz
bitvend-615293aba8758cf0b632c4cfedcc2b3869c360b1.zip
mdb: Make raspi backend blocking
-rw-r--r--mdb/backend.py10
-rw-r--r--requirements.txt2
2 files changed, 8 insertions, 4 deletions
diff --git a/mdb/backend.py b/mdb/backend.py
index 2b806b9..8e40da5 100644
--- a/mdb/backend.py
+++ b/mdb/backend.py
@@ -58,8 +58,12 @@ class RaspiBackend(Backend):
raise Exception('Port open failed: %d', status)
def read(self):
- _, data = self.pi.bb_serial_read(self.rx_pin)
- return data
+ while True:
+ cnt, data = self.pi.bb_serial_read(self.rx_pin)
+ if cnt <= 0:
+ time.sleep(0.001)
+ else:
+ return data
def write(self, data):
self.pi.wave_add_serial(self.tx_pin, 9600, data, bb_bits=9, bb_stop=6)
@@ -69,7 +73,7 @@ class RaspiBackend(Backend):
self.pi.wave_send_once(wid) # transmit serial data
while self.pi.wave_tx_busy(): # wait until all data sent
- pass
+ time.sleep(0.001)
self.pi.wave_delete(wid)
self.pi.set_mode(self.tx_pin, pigpio.INPUT)
diff --git a/requirements.txt b/requirements.txt
index 1c74264..aa7d3bd 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -18,4 +18,4 @@ websocket-client==0.40.0
Werkzeug==0.11.15
WTForms==2.1
blinker>=1.3
--e git+https://code.hackerspace.pl/informatic/flask-spaceauth#egg=Flask-SpaceAuth
+git+https://code.hackerspace.pl/informatic/flask-spaceauth#egg=Flask-SpaceAuth