jacopo-j / mcr12_serial

Python module for controlling the MCR12 barcode scanner module via serial port

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction

This is a Python 3 module for controlling the so called "MCR12" barcode scanner module via USB serial port emulation. The MCR12 is sold as standalone module, for example on Adafruit, and it is also the module on which some barcode scanner, such as this one, are based.

Usage

from mcr12_serial import BarcodeScanner

bcd = BarcodeScanner("/path/to/serial/device", baudrate=9600)

barcode1 = bcd.scan()  # Same as bcd.scan(0)
# The scanner will start scanning indefinitely until a barcode is
# scanned.

barcode2 = bcd.scan(5000)
# The scanner will start scanning. If after 5000 milliseconds no
# barcode has been scanned, a TimeoutError is raised.

bcd.stop()
# Stop scanning. Not really useful here as the scanner stops scanning
# automatically after a barcode has been scanned or after the timeout
# has expired. However it may be useful if you call the scan() method
# asynchronously or if you need to handle a KeyboardInterrupt to stop
# scanning after calling the scan() method.

bcd.config("013300")
# Edit the scanner configuration. "013300" must be replaced with a
# configuration code.

Configuration codes

You can find configuration codes on the MCR 12 Manual. They are written under each configuration barcode.

About

Python module for controlling the MCR12 barcode scanner module via serial port

License:MIT License


Languages

Language:Python 100.0%