summaryrefslogtreecommitdiffstats
path: root/mdb/device.py
diff options
context:
space:
mode:
authorPiotr Dobrowolski <admin@tastycode.pl>2020-06-21 23:20:14 +0200
committerPiotr Dobrowolski <admin@tastycode.pl>2020-06-21 23:20:14 +0200
commit494f5ef2bcd3480d036a96399bfe875ba32e4a4d (patch)
tree4248758a79a97752765f8fe8147166d021b33f92 /mdb/device.py
parentcce3ff52376adb8a8cb127f70f62043fddae609f (diff)
downloadbitvend-494f5ef2bcd3480d036a96399bfe875ba32e4a4d.tar.gz
bitvend-494f5ef2bcd3480d036a96399bfe875ba32e4a4d.tar.bz2
bitvend-494f5ef2bcd3480d036a96399bfe875ba32e4a4d.tar.xz
bitvend-494f5ef2bcd3480d036a96399bfe875ba32e4a4d.zip
WIP vending v2 with serial backend
Diffstat (limited to 'mdb/device.py')
-rw-r--r--mdb/device.py37
1 files changed, 19 insertions, 18 deletions
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