iljabauer / python-escpos

Automatically exported from code.google.com/p/python-escpos
GNU General Public License v3.0
0 stars 0 forks source link

Printing - Operation timed out error #17

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. My python app uses a USB thermal printer (TM-T20) to print a long text. 
2. I put the long stream of text (12k characters) on the Epson.text("long 
text..") method. 
3. The appl prints some of the text and then the printing stops and produce an 
error "usb.core.USBError: [Errno 110] Operation timed out" and then exits the 
app.
4. I even tried to split the text into 6k characters for each Epson.text call 
but still getting the timeout on the 2nd Epson.text call.

What is the expected output? What do you see instead?
- Expected result is to print the completed text without error. Instead I'm 
getting a timeout error. "usb.core.USBError: [Errno 110] Operation timed out" 

What version of the product are you using? On what operating system?
-Raspbian OS, Python 2.7 and python-escpos-1.0-1 

Please provide any additional information below.
Below is the sample code.

#!/usr/bin/python
from escpos import *
    """ Seiko Epson Corp. Receipt Printer Definitions (EPSON TM-T20) """
    Epson = printer.Usb(0x04b8,0x0e03)
    Epson.set(font='B',type='NORMAL',width=1,height=1)
    Epson.control("FF")
    Epson.text("some very very long receipt text...")   #this would be a text with 12K characters
    Epson.cut()

==========================================
Error received

Traceback (most recent call last):
  File "sertest.py", line 40, in <module>
     File "sertest.py", line 11, 
    Epson.text(printdata)
  File "/usr/local/lib/python2.7/dist-packages/escpos/escpos.py", line 177, in text
    self._raw(txt)
  File "/usr/local/lib/python2.7/dist-packages/escpos/printer.py", line 58, in _raw
    self.device.write(self.out_ep, msg, self.interface)
  File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 619, in write
    self.__get_timeout(timeout)
  File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb10.py", line 532, in bulk_write
    timeout)
  File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb10.py", line 628, in __write
    timeout))
  File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb10.py", line 403, in _check
    raise USBError(_str_error[ret], ret, _libusb_errno[ret])
usb.core.USBError: [Errno 110] Operation timed out

Original issue reported on code.google.com by junr...@gmail.com on 26 Nov 2013 at 7:33

GoogleCodeExporter commented 9 years ago
Hello junrapz,

Unfortunately I have not enough paper to run tests for 12k lines.
What I can suggest is to run a binary search until you can find the
optimal buffer size. ie. [DOWN] 3000, 1500, 750 [UP] 1000 [DOWN]875 and so on.

Thank you

Original comment by manpaz on 2 Jan 2014 at 8:37