MDB Products
Released
Getting Started
MDB Developers' Playground - Code Samples and Examples
Title
Message
Create new category
What is the title of your new category?
Edit page index title
What is the title of the page index?
Edit category
What is the new title of your category?
Edit link
What is the new title and URL of your link?
Implement an Always Idle Cashless Terminal - Python
Copy Markdown
Open in ChatGPT
Open in Claude
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.
Python
x
import serialimport osimport timeSTATUS = {...}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 Hatdef openSerial():...def write2Serial(msg):... def readSerial():... #### Utilities ############################Function to print to consoledef print2Console(msg):...#Function to clear the console to wipe previous messagesdef clearConsole():...#### Cashless API Related Functions ######def initCashlessDevice():...if __name__ == '__main__':...Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard
Last updated on
(C) 2024 Qibixx AG - contact us with any questions: info@qibixx.com
Discard Changes
Do you want to discard your current changes and overwrite with the template?
Archive Synced Block
Message
Create new Template
What is this template's title?
Delete Template
Message