mdb: Make raspi backend blocking

feature/cython
informatic 2017-12-08 20:42:22 +01:00
parent 37b3b9d5fe
commit 615293aba8
2 changed files with 8 additions and 4 deletions

View File

@ -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)

View File

@ -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