From 3f6528da077618facdc102b473c42956b5e65165 Mon Sep 17 00:00:00 2001 From: Joel Lehtonen Date: Sun, 1 Feb 2015 01:46:15 +0200 Subject: [PATCH 1/4] Support for images vertically longer than 256 pixels --- escpos/escpos.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/escpos/escpos.py b/escpos/escpos.py index 2263458..045a4fd 100644 --- a/escpos/escpos.py +++ b/escpos/escpos.py @@ -41,7 +41,7 @@ class Escpos: buffer = "" self._raw(S_RASTER_N) - buffer = "%02X%02X%02X%02X" % (((size[0]/size[1])/8), 0, size[1], 0) + buffer = "%02X%02X%02X%02X" % (((size[0]/size[1])/8), 0, size[1]&0xff, size[1]>>8) self._raw(buffer.decode('hex')) buffer = "" @@ -68,7 +68,7 @@ class Escpos: if im.size[0] > 512: print ("WARNING: Image is wider than 512 and could be truncated at print time ") - if im.size[1] > 255: + if im.size[1] > 0xffff: raise ImageSizeError() im_border = self._check_image_size(im.size[0]) From cd5969e843822e63473ac36a2e5570f634a17b85 Mon Sep 17 00:00:00 2001 From: Hark Date: Fri, 4 Sep 2015 22:48:58 +0100 Subject: [PATCH 2/4] Prevent crash when using libusb0 printers --- escpos/printer.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/escpos/printer.py b/escpos/printer.py index 738d7ca..3a3bc84 100644 --- a/escpos/printer.py +++ b/escpos/printer.py @@ -40,11 +40,19 @@ class Usb(Escpos): if self.device is None: print "Cable isn't plugged in" - if self.device.is_kernel_driver_active(0): + check_driver = None + + try: + check_driver = self.device.is_kernel_driver_active(0) + except NotImplementedError: + pass + + if check_driver is None or check_driver: try: self.device.detach_kernel_driver(0) except usb.core.USBError as e: - print "Could not detatch kernel driver: %s" % str(e) + if check_driver is not None: + print "Could not detatch kernel driver: %s" % str(e) try: self.device.set_configuration() From 7e3b6ce586a56eaddba2884e033f66d88e928c19 Mon Sep 17 00:00:00 2001 From: Manuel F Martinez Date: Tue, 27 Oct 2015 13:45:15 -0700 Subject: [PATCH 3/4] Updated README and documentation --- CHANGELOG | 10 +++++++-- README | 62 +++---------------------------------------------------- setup.py | 2 +- 3 files changed, 12 insertions(+), 62 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f93f909..6af31fc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,12 +26,18 @@ CHANGELOG * 2015-04-21 - Version 1.0.5 - Merge pull request #45 from Krispy2009/master . Raising the right error when wrong charcode is used - . Sent by Krispy2009@gmail.com + . Sent by Kristi * 2015-07-06 - Version 1.0.6 - Merge pull request #53 from ldos/master . Extended params for serial printers - . Sent by cafeteria.ldosalzira@gmail.com + . Sent by ldos * 2015-08-22 - Version 1.0.7 - Issue #57: Fixed transparent images + +* 2015-10-27 - Version 1.0.8 +- Merge pull request #59 from zouppen/master + . Support for images vertically longer than 256 pixels + . Sent by Joel Lehtonen +- Updated README diff --git a/README b/README index aa08b13..2c2a41a 100644 --- a/README +++ b/README @@ -4,16 +4,7 @@ ESCPOS Python library to manipulate ESC/POS Printers. ------------------------------------------------------------------ -1. Dependencies - -In order to start getting access to your printer, you must ensure -you have previously installed the following python modules: - - * pyusb (python-usb) - * PIL (Python Image Library) - ------------------------------------------------------------------- -2. Description +1. Description Python ESC/POS is a library which lets the user have access to all those printers handled by ESC/POS commands, as defined by Epson, @@ -33,60 +24,13 @@ paper, carrier return, printer reset and others concerned to the carriage alignment. ------------------------------------------------------------------ -3. Define your printer - -Before start create your Python ESC/POS printer instance, you must -see at your system for the printer parameters. This is done with -the 'lsusb' command. - -First run the command to look for the "Vendor ID" and "Product ID", -then write down the values, these values are displayed just before -the name of the device with the following format: - - xxxx:xxxx - -Example: - Bus 002 Device 001: ID 1a2b:1a2b Device name - -Write down the the values in question, then issue the following -command so you can get the "Interface" number and "End Point" - - lsusb -vvv -d xxxx:xxxx | grep iInterface - lsusb -vvv -d xxxx:xxxx | grep bEndpointAddress | grep OUT - -The first command will yields the "Interface" number that must -be handy to have and the second yields the "Output Endpoint" -address. - -By default the "Interface" number is "0" and the "Output Endpoint" -address is "0x82", if you have other values then you can define -with your instance. - ------------------------------------------------------------------- -4. Define your instance - -The following example shows how to initialize the Epson TM-TI88IV -*** NOTE: Always finish the sequence with Epson.cut() otherwise - you will endup with weird chars being printed. - - from escpos import * - - """ Seiko Epson Corp. Receipt Printer M129 Definitions (EPSON TM-T88IV) """ - Epson = escpos.Escpos(0x04b8,0x0202) - Epson.text("Hello World") - Epson.image("logo.gif") - Epson.barcode - Epson.barcode('1324354657687','EAN13',64,2,'','') - Epson.cut() - ------------------------------------------------------------------- -5. Links +2. Documentation Please visit project documentation at: https://github.com/manpaz/python-escpos/wiki ------------------------------------------------------------------ -6. Donations +3. Donations There are some different prints I'd like to acquire, but unfortunately not all, even used, are cheaper and easy to get. diff --git a/setup.py b/setup.py index d29ad51..adbb97a 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from distutils.core import setup setup( name='escpos', - version='1.0.7', + version='1.0.8', url='https://github.com/manpaz/python-escpos', download_url='https://github.com/manpaz/python-escpos.git', description='Python library to manipulate ESC/POS Printers', From c1d985eeaf98d369388acabb952972ca0ad72dce Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Sat, 28 Nov 2015 14:22:54 +0100 Subject: [PATCH 4/4] FIX constant definition for PC1252 * fixes #40 * according to the table http://content.epson.de/fileadmin/content/files/RSD/downloads/escpos.pdf --- escpos/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/escpos/constants.py b/escpos/constants.py index 7511365..09a833a 100644 --- a/escpos/constants.py +++ b/escpos/constants.py @@ -42,7 +42,7 @@ CHARCODE_PC865 = '\x1b\x74\x05' # Nordic CHARCODE_WEU = '\x1b\x74\x06' # Simplified Kanji, Hirakana CHARCODE_GREEK = '\x1b\x74\x07' # Simplified Kanji CHARCODE_HEBREW = '\x1b\x74\x08' # Simplified Kanji -CHARCODE_PC1252 = '\x1b\x74\x11' # Western European Windows Code Set +CHARCODE_PC1252 = '\x1b\x74\x10' # Western European Windows Code Set CHARCODE_PC866 = '\x1b\x74\x12' # Cirillic #2 CHARCODE_PC852 = '\x1b\x74\x13' # Latin 2 CHARCODE_PC858 = '\x1b\x74\x14' # Euro