Giter Club home page Giter Club logo

Comments (5)

belono avatar belono commented on May 28, 2024

Hello @BimBim134 and welcome to python-escpos.

We hope we can help you with your first issue submission 🥇 .

Before we start it is preferable that we are sure that your environment is correctly set up, so please, follow the installation guide to assert you are using the latest (v.3.0) python-escpos version and all the required dependencies. Also remember that to print via the USB bus in python on Linux you need to setup an udev rule to give access permission to the python scrips to the USB device.

After the environment is correctly set up:
Please, try printing some single text.
Then, if all goes well, try to send an small image to the printer. That's an image that fits the paper width.

What's the output?

from python-escpos.

BimBim134 avatar BimBim134 commented on May 28, 2024

Hi Belono ! thanks for your help 😁

I somehow missed the installation guide so I followed every step described.

I tested with a little text (just a few lines) and it went allright so I sent an image but then again, I got the timeout error and the garbage printed :

note : I used my script (easyprint) to send a text, an image, another text and another image

❯ easyprint 00.txt resized-0_sierra.png 01.txt resized-1_sierra.png
usb printer loaded

text:
	Un jour normal comme un autre,
	ordinaire, fait pareil que
	d'habitude et tout, elle me
	tombe dessus. Il parait que ça
	faisait 6 ans. Je me souvenais
	bien, alors on a papotté.
image:
- resized-0_sierra.png

The media.width.pixel field of the printer profile is not set. The center flag will have no effect.
text:
	Vraiment, on rigolait bien.
image:
- resized-1_sierra.png

The media.width.pixel field of the printer profile is not set. The center flag will have no effect.
Traceback (most recent call last):
  File "/home/bimbim/codes/printer/main.py", line 55, in <module>
    main()
  File "/home/bimbim/codes/printer/main.py", line 52, in main
    p._raw(d.output)
  File "/home/bimbim/codes/printer/.venv/lib/python3.11/site-packages/escpos/printer/usb.py", line 190, in _raw
    self.device.write(self.out_ep, msg, self.timeout)
  File "/home/bimbim/codes/printer/.venv/lib/python3.11/site-packages/usb/core.py", line 989, in write
    return fn(
           ^^^
  File "/home/bimbim/codes/printer/.venv/lib/python3.11/site-packages/usb/backend/libusb1.py", line 837, in bulk_write
    return self.__write(self.lib.libusb_bulk_transfer,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bimbim/codes/printer/.venv/lib/python3.11/site-packages/usb/backend/libusb1.py", line 938, in __write
    _check(retval)
  File "/home/bimbim/codes/printer/.venv/lib/python3.11/site-packages/usb/backend/libusb1.py", line 602, in _check
    raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 110] Operation timed out

here's a picture of what it printed if that helps :
IMG_20240223_233940

so as you can see, it began to print correctly and then proceed to not print what it's suppose to as if it overflow a buffer inside the printer or something like that.
if that make sense...

Also, I shutdown manually the printer when it goes like this, because it continues for ever and waste a lot of paper..

from python-escpos.

belono avatar belono commented on May 28, 2024

Ok, so the problem lays on the image printing.

Usually this kind of errors are related to an image implementation mode not being compatible with the printer model.
As your printer's image implementation compatibility is unknown, the driver is defaulting to the bitImageRaster mode. You can force the use of a different implementation.
Please try calling the image method specifying a different impl mode value:

import escpos.printer as printer

# impl allowed values:
GRAPHICS = "graphics"
COLUMN = "bitImageColumn"
RASTER = "bitImageRaster"

# Your image source:
IMG_SOURCE = "resized-0_sierra.png"

p = printer.Usb(
    idVendor=0x456,
    idProduct=0x0808,
    in_ep=0x81,
    out_ep=0x03,
    timeout=800,
    profile='POS-5890'
)
p.image(
    img_source=IMG_SOURCE,
    impl=#  Switch between GRAPHICS, COLUMN, RASTER to find the compatible modes.
)
p.close()

I'm crossing my fingers 🤞

from python-escpos.

BimBim134 avatar BimBim134 commented on May 28, 2024

Hi Benolo !

bitImageColumn was the one !

I'm SO glad it works you made my day !!

note : you need to push the timeout parameter in the printer configuration way higher (like 5000 or 10000 ms) to be able to print for longer time in one go. Also, you need to push the fragment_height in the p.image() function also higher (like 5000px) so it don't split the image (because it crash the printer...).

Thank you so much Benolo and happy coding 😁

from python-escpos.

belono avatar belono commented on May 28, 2024

Great!!!

Thanks to you too for sharing the tip on timeout and fragment_height. I'm sure it will be helpful to other users.

Feel free to open a new issue if you encounter any other problems.

Cheers! 🍺

from python-escpos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.