Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PyESCPOS sandbox script
# -*- coding: utf-8 -*-
# Requires https://github.com/base4sistemas/pyescpos
# Have a look at https://github.com/base4sistemas/pyescpos/wiki
from __future__ import unicode_literals
from __future__ import print_function
import logging.config
from escpos import showcase
from escpos.conn.usb import USBConnection
from escpos.conn import SerialConnection
from escpos.impl.bematech import MP2800TH
from escpos.impl.daruma import DR700
logging.config.dictConfig({
"version": 1,
"disable_existing_loggers": False,
"root": {
"level": "WARNING",
"handlers": [
"console"
]
},
"handlers": {
"null": {
"class": "logging.NullHandler",
"level": "DEBUG"
},
"console": {
"formatter": "simple",
"class": "logging.StreamHandler",
"level": "DEBUG",
"stream": "ext://sys.stdout"
},
},
"formatters": {
"simple": {
"format": "%(levelname)-8s [%(name)s] %(message)s"
},
},
"loggers": {
"escpos": {
"level": "DEBUG"
},
}
})
def dr700():
device = SerialConnection.create('/dev/ttyS5:9600,8,1,N,RTSCTS')
printer = DR700(device, encoding='cp850')
return printer
def mp2800th_usb():
# /etc/udev/rules.d/99-bematech-mp2800th.rules
# SUBSYSTEM=="usb", ATTR{idVendor}=="0b1b", ATTR{idProduct}=="0008", MODE="666"
device = USBConnection.create('0b1b:0008,ep_out=2,ep_in=83')
printer = MP2800TH(device, encoding='cp850')
return printer
if __name__ == '__main__':
printer = mp2800th_usb()
showcase.showcase(printer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment