summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitvend/mdb.py1
-rw-r--r--mdb/backend.py7
-rw-r--r--mdb/device.py37
-rw-r--r--requirements.txt1
4 files changed, 27 insertions, 19 deletions
diff --git a/bitvend/mdb.py b/bitvend/mdb.py
index f44da87..d6d3b4b 100644
--- a/bitvend/mdb.py
+++ b/bitvend/mdb.py
@@ -23,6 +23,7 @@ class BitvendCashlessMDBDevice(CashlessMDBDevice):
# FIXME we report success here, because database write takes too much
# time to respond in 5ms.
self.send([0x05, 0x00, 0xff])
+ self.poll_queue.put([0x05])
self.current_request.processed = True
self.logger.info('got vend request: %r', self.current_tx_id)
diff --git a/mdb/backend.py b/mdb/backend.py
index 8e40da5..1fc686e 100644
--- a/mdb/backend.py
+++ b/mdb/backend.py
@@ -84,10 +84,15 @@ class RaspiBackend(Backend):
#
class SerialBackend(Backend):
def __init__(self, device='/dev/ttyACM0'):
+ import serial
self.ser = serial.Serial(device)
def read(self):
- return self.ser.read()
+ buf = b''
+ while len(buf) < 2:
+ buf += self.ser.read(1)
+ return buf
def write(self, data):
self.ser.write(data)
+ self.ser.flush()
diff --git a/mdb/device.py b/mdb/device.py
index 20ea546..6c27270 100644
--- a/mdb/device.py
+++ b/mdb/device.py
@@ -9,7 +9,7 @@ except ImportError:
from mdb.utils import compute_checksum, compute_chk, bcd_decode
from mdb.constants import *
-from mdb.backend import RaspiBackend, DummyBackend, pigpio
+from mdb.backend import RaspiBackend, DummyBackend, SerialBackend, pigpio
class MDBRequest(object):
timestamp = None
@@ -64,7 +64,7 @@ class MDBDevice(object):
self.backend = RaspiBackend()
else:
self.logger.warning('Running with dummy backend device')
- self.backend = DummyBackend()
+ self.backend = SerialBackend()
def initialize(self):
self.logger.info('Initializing...')
@@ -79,7 +79,8 @@ class MDBDevice(object):
for b in range(0, len(data), 2):
if data[b+1]:
if self.current_request: # and not self.current_request.processed:
- self.logger.debug(self.current_request)
+ if self.current_request.command not in [0xf2]:
+ self.logger.debug(self.current_request)
if self.current_request.processed and self.current_request.ack:
self.logger.info('Got response: %d',self.current_request.data[-1])
self.poll_msg = []
@@ -150,21 +151,21 @@ class CashlessMDBDevice(MDBDevice):
def process_request(self, req):
# FIXME this shouldn't be required...
- if req.command == 0x30 and req.validate_checksum():
- self.lockup_counter += 1
-
- if self.lockup_counter % 50 == 0:
- self.logger.info('YOLO')
- return []
- return
- if req.command == 0x31 and req.validate_checksum():
- return []
- if req.command == 0x37 and req.validate_checksum():
- return []
- if req.command == 0x36 and req.validate_checksum():
- return []
- if req.command == 0x34 and req.validate_checksum():
- return []
+ #if req.command == 0x30 and req.validate_checksum():
+ # self.lockup_counter += 1
+
+ # if self.lockup_counter % 50 == 0:
+ # self.logger.info('YOLO')
+ # return []
+ # return
+ #if req.command == 0x31 and req.validate_checksum():
+ # return []
+ #if req.command == 0x37 and req.validate_checksum():
+ # return []
+ #if req.command == 0x36 and req.validate_checksum():
+ # return []
+ #if req.command == 0x34 and req.validate_checksum():
+ # return []
if (req.command & self.base_address) != self.base_address:
# Target mismatch
diff --git a/requirements.txt b/requirements.txt
index aa7d3bd..c4d1399 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,6 +5,7 @@ Flask-Login==0.4.0
Flask-QRcode==0.10.0
Flask-SQLAlchemy==2.1
Flask-WTF==0.14.2
+Flask-OAuthlib==0.9.4
itsdangerous==0.24
Jinja2==2.9.4
MarkupSafe==0.23