Implement an Always Idle Cashless Terminal - Python
This code sample is a basic Python example that communicates with the MDB USB or Pi Hat with our API to implement a Cashless Terminal in Selection First (Always Idle) Mode.
Please check the definition of Selection First Mode in the MDB Cheat Sheet.
Some Remarks
- This example has a hard coded device descriptor (ttyACM0), on a system where multiple devices are connected via USB, find the device descriptor with Vendor Id=16d0 and Device ID=0bd7
- This example is very simplistic, provided free of charge as a guideline for our products, other implementations are of course possible (like using threads, for instance)
- This example assumes that the vending machine is capable of doing Always Idle Mode, which is not something that is not supported on every machine, but should be in most recent machines.
x
import serial
import os
import time
STATUS = {
}
AUTHORIZE_VEND = "C,VEND," # Prefix to send to authorize a vend request in VEND state (e.g. C,VEND,<requested_amount>)
DENY_VEND = "C,STOP" #Message to send to deny a vend request from the vending machine
#### Serial Port functions to interact with MDB USB/Pi Hat
def openSerial():
def write2Serial(msg):
def readSerial():
#### Utilities ###########################
#Function to print to console
def print2Console(msg):
#Function to clear the console to wipe previous messages
def clearConsole():
#### Cashless API Related Functions ######
def initCashlessDevice():
if __name__ == '__main__':