Comments (5)
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.
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 :
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.
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.
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.
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)
- Text size not working (width and height) HOT 11
- Image printing prints only garbage HOT 29
- Barcode not printed HOT 4
- Introduce IntEnum or similar for printer states
- Usb printer not working on web Application HOT 2
- Printer not found on web application HOT 1
- Font switching not working. HOT 3
- is_online() fails with raise NotImplementedError()
- Full cut not working on Epson TM-T20III HOT 2
- ImportError: cannot import name 'DeviceNotFoundError' from 'escpos.exceptions' HOT 2
- usb.core.USBError: [Errno 5] Input/Output Error` HOT 1
- EPSON TM-m30III randomly fails to print images HOT 1
- Arabic Text not printing correctly HOT 2
- Tabbed text HOT 8
- windows Invalid endpoint address HOT 1
- Printer Emulator Connection Issue HOT 6
- How to print big5 charcode HOT 1
- CLI not working for CupsPrinter, LP and Win32Raw connectors
- Print to a bluetooth device via rfcomm and printer.File() HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-escpos.