New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No barcode printing with WinBond/Zjiang 5890 #58

Closed
matiasw opened this Issue Aug 25, 2015 · 18 comments

Comments

Projects
None yet
7 participants
@matiasw

matiasw commented Aug 25, 2015

Hi,
I'm having trouble with getting barcode printing to work: only the code gets printed, not the bars. My printer is this one: http://www.aliexpress.com/item/Free-shipping-New-mini-58mm-thermal-receipt-printer-ticket-pos-58-thermal-printer-USB-black-white/856027185.html
It is identified as ATTRS{idVendor}=="0416", ATTRS{idProduct}=="aabb" and text/image printing work.
Where should I look for the problem? I can see two ways around it: find and fix the issue where barcode is handled, or work around it by rendering the barcode to an image and printing that. I think the first one is simpler, would you agree?

@patkan

This comment has been minimized.

Show comment
Hide comment
@patkan

patkan Jan 8, 2016

Member

Hi @matiasw. Do you know whether the printer speaks "real" esc/pos?
Have you already solved the problem?

Member

patkan commented Jan 8, 2016

Hi @matiasw. Do you know whether the printer speaks "real" esc/pos?
Have you already solved the problem?

@patkan patkan added this to the barcodes milestone Feb 3, 2016

@bmjbmj

This comment has been minimized.

Show comment
Hide comment
@bmjbmj

bmjbmj Mar 7, 2016

It took me a while to find the problem. My 5802LD from the same manufacture demands a NUL last in the data field. Python-escpos only sends 'self._raw(code)' NOT self._raw(code+'\0'). A work around is to use a line like: Zjiang.barcode('1324354657687\0','EAN13',64,2,'','') OBS! the '\0'.

From manual:
GS k m d1...dk NUL 0<=m<=6
or
GS k m n d1...dk 65<=m<=73

By the way the Zjiang manual is a typographical disaster with many errors!

bmjbmj commented Mar 7, 2016

It took me a while to find the problem. My 5802LD from the same manufacture demands a NUL last in the data field. Python-escpos only sends 'self._raw(code)' NOT self._raw(code+'\0'). A work around is to use a line like: Zjiang.barcode('1324354657687\0','EAN13',64,2,'','') OBS! the '\0'.

From manual:
GS k m d1...dk NUL 0<=m<=6
or
GS k m n d1...dk 65<=m<=73

By the way the Zjiang manual is a typographical disaster with many errors!

@patkan

This comment has been minimized.

Show comment
Hide comment
@patkan

patkan Mar 7, 2016

Member

You are right. Function type A detects the end of the code with a NUL. Function type B via a supplied length.
So, @DavisGoglin: could you maybe add this to #98 while you're at it? I think we only have to add a \x00 in A-mode.

Member

patkan commented Mar 7, 2016

You are right. Function type A detects the end of the code with a NUL. Function type B via a supplied length.
So, @DavisGoglin: could you maybe add this to #98 while you're at it? I think we only have to add a \x00 in A-mode.

@patkan

This comment has been minimized.

Show comment
Hide comment
@patkan

patkan Mar 8, 2016

Member

OK, I suspect this should be fixed in #98. If no one opposes I will close this issue at the latest after merging into master.

Member

patkan commented Mar 8, 2016

OK, I suspect this should be fixed in #98. If no one opposes I will close this issue at the latest after merging into master.

@patkan patkan added the fixed-in-dev label Mar 8, 2016

@patkan patkan referenced this issue Mar 30, 2016

Merged

version 2.0.0 #117

6 of 6 tasks complete
@bondzo

This comment has been minimized.

Show comment
Hide comment
@bondzo

bondzo May 13, 2016

I have this printer http://www.amazon.de/gp/product/B00LUIST7W/ref=ask_ql_qh_dp_hza
which is also Zjiang ZJ-5890T, ID 0416:5011
Everything works except barcode. I tried both master and development branch. The description says that JAN13 (EAN 13) / JAN8 (EAN8) / CODE39 is supported. The programmer manual even says that all usual barcode types and function type A and B are supported.
I tested the demo-code from #98.
This is what it looks like:
barcode
Looks like something is wrong.

bondzo commented May 13, 2016

I have this printer http://www.amazon.de/gp/product/B00LUIST7W/ref=ask_ql_qh_dp_hza
which is also Zjiang ZJ-5890T, ID 0416:5011
Everything works except barcode. I tried both master and development branch. The description says that JAN13 (EAN 13) / JAN8 (EAN8) / CODE39 is supported. The programmer manual even says that all usual barcode types and function type A and B are supported.
I tested the demo-code from #98.
This is what it looks like:
barcode
Looks like something is wrong.

@patkan

This comment has been minimized.

Show comment
Hide comment
@patkan

patkan May 14, 2016

Member

Hi @bondzo, the Text with a leading @ should go into a Barcode. So it looks like there is a fault somewhere.
Have you already tried to construct a raw control sequence from the manual and pass it directly to the printer with _raw()?
Just one mor thing to be sure: Have you tried this one? http://python-escpos.readthedocs.io/en/development/user/usage.html#advanced-usage-print-from-binary-blob
The "binary" does definitely print on Epson devices. (If this fails we can narrow it down to the printer being awkward.)

Member

patkan commented May 14, 2016

Hi @bondzo, the Text with a leading @ should go into a Barcode. So it looks like there is a fault somewhere.
Have you already tried to construct a raw control sequence from the manual and pass it directly to the printer with _raw()?
Just one mor thing to be sure: Have you tried this one? http://python-escpos.readthedocs.io/en/development/user/usage.html#advanced-usage-print-from-binary-blob
The "binary" does definitely print on Epson devices. (If this fails we can narrow it down to the printer being awkward.)

@bondzo

This comment has been minimized.

Show comment
Hide comment
@bondzo

bondzo May 18, 2016

Yes, I tried several _raw sequences - no success.
Thanks for pointing out the barcode.bin file. Not a single barcode is printed. I tried both p.Usb(...) and p.File(/dev/usb/lp0) - same result. The programming manual looks equal.
I'm not dependent on bar codes. Just wanted to fix this. I'll tell you as soon as I found out.

bondzo commented May 18, 2016

Yes, I tried several _raw sequences - no success.
Thanks for pointing out the barcode.bin file. Not a single barcode is printed. I tried both p.Usb(...) and p.File(/dev/usb/lp0) - same result. The programming manual looks equal.
I'm not dependent on bar codes. Just wanted to fix this. I'll tell you as soon as I found out.

@patkan

This comment has been minimized.

Show comment
Hide comment
@patkan

patkan May 18, 2016

Member

Thank you for testing this! It seems to me that these printers do something very different or simply can't print barcodes :-(
A last resort for someone who really needs that feature could be creating pictures and printing them.

Member

patkan commented May 18, 2016

Thank you for testing this! It seems to me that these printers do something very different or simply can't print barcodes :-(
A last resort for someone who really needs that feature could be creating pictures and printing them.

@patkan patkan removed the fixed-in-dev label May 18, 2016

@mike42

This comment has been minimized.

Show comment
Hide comment
@mike42

mike42 May 20, 2016

Contributor

Based on my own tests on this printer, I can basically confirm the above: the ZJ5890T does not speak standard ESC/POS, despite what the manual says. It's likely to be software-based rendering or no-barcodes on this model I'm afraid.

Screen capture below of the PDF shipped with the printer.


image

Contributor

mike42 commented May 20, 2016

Based on my own tests on this printer, I can basically confirm the above: the ZJ5890T does not speak standard ESC/POS, despite what the manual says. It's likely to be software-based rendering or no-barcodes on this model I'm afraid.

Screen capture below of the PDF shipped with the printer.


image

@mike42

This comment has been minimized.

Show comment
Hide comment
@mike42

mike42 Sep 23, 2016

Contributor

I've tried using the pyBarcode library to generate barcode images for python-escpos

Printing "1234" in CODE39 showed a few bugs and missing features. Most of it's in the bug tracker, see bitbucket.

Example

Dependencies for this snippet:

pip install python-escpos pyBarcode

Hacky setup to get a PIL object out without writing to disk:

import barcode
from barcode.writer import ImageWriter

def get_barcode_image(codetype, content):
    """
    Get a PIL image object from a given barcode type and content.

    Note that barcode.PROVIDED_BARCODES contains the list of
    valid barcode types.
    """
    barcode_class=barcode.get_barcode_class(codetype)
    my_code=barcode_class(content, writer=ImageWriter())
    my_code.write("/dev/null")
    return my_code.writer._image

The idea being that you could print it:

from escpos.printer import File
myPrinter =  File("/dev/usb/lp0")
img = get_barcode_image("code39", "1234")
myPrinter.image(img, impl='bitImageColumn')

Unfortunately, no chance to set the size, and the output is buggy as anything. Debug time:

img.save(open("aa.png", "wb"), format="png")

aa

Next up

In the absence of any other suggestions for getting barcodes on the ZJ5890, I think we can close this issue off.

For anyone dealing with a printer which does not support GS k correctly, your choices are basically to try a different printer, or to take this snippet as a starting point, looking up issues in the python-barcode issue tracker as you go.

Contributor

mike42 commented Sep 23, 2016

I've tried using the pyBarcode library to generate barcode images for python-escpos

Printing "1234" in CODE39 showed a few bugs and missing features. Most of it's in the bug tracker, see bitbucket.

Example

Dependencies for this snippet:

pip install python-escpos pyBarcode

Hacky setup to get a PIL object out without writing to disk:

import barcode
from barcode.writer import ImageWriter

def get_barcode_image(codetype, content):
    """
    Get a PIL image object from a given barcode type and content.

    Note that barcode.PROVIDED_BARCODES contains the list of
    valid barcode types.
    """
    barcode_class=barcode.get_barcode_class(codetype)
    my_code=barcode_class(content, writer=ImageWriter())
    my_code.write("/dev/null")
    return my_code.writer._image

The idea being that you could print it:

from escpos.printer import File
myPrinter =  File("/dev/usb/lp0")
img = get_barcode_image("code39", "1234")
myPrinter.image(img, impl='bitImageColumn')

Unfortunately, no chance to set the size, and the output is buggy as anything. Debug time:

img.save(open("aa.png", "wb"), format="png")

aa

Next up

In the absence of any other suggestions for getting barcodes on the ZJ5890, I think we can close this issue off.

For anyone dealing with a printer which does not support GS k correctly, your choices are basically to try a different printer, or to take this snippet as a starting point, looking up issues in the python-barcode issue tracker as you go.

@thijstriemstra

This comment has been minimized.

Show comment
Hide comment
@thijstriemstra

thijstriemstra Oct 18, 2016

Contributor

Unfortunately, no chance to set the size, and the output is buggy as anything.

@mike42, I tried your example with pyBarcode 0.8beta1 from their hg repository with a USB Mini 58mm POS Thermal Dot Receipt Bill Printer POS Z-5890C but nothing was printed (on /dev/usb/lp1). Is there anything missing from your example? Fortunately I don't need barcodes right now, but just fyi.

Contributor

thijstriemstra commented Oct 18, 2016

Unfortunately, no chance to set the size, and the output is buggy as anything.

@mike42, I tried your example with pyBarcode 0.8beta1 from their hg repository with a USB Mini 58mm POS Thermal Dot Receipt Bill Printer POS Z-5890C but nothing was printed (on /dev/usb/lp1). Is there anything missing from your example? Fortunately I don't need barcodes right now, but just fyi.

@mike42

This comment has been minimized.

Show comment
Hide comment
@mike42

mike42 Oct 18, 2016

Contributor

Please read the comment in detail: I'm pointing out that the generated barcode is un-usable!

In any case, edited the comment above, I forgot to include the call to image() that actually does the printing.

Contributor

mike42 commented Oct 18, 2016

Please read the comment in detail: I'm pointing out that the generated barcode is un-usable!

In any case, edited the comment above, I forgot to include the call to image() that actually does the printing.

@thijstriemstra

This comment has been minimized.

Show comment
Hide comment
@thijstriemstra

thijstriemstra Oct 18, 2016

Contributor

Thanks for the feedback. There's also a cups filter for this printer it seems (https://github.com/klirichek/zj-58) and during my tests it printed images/text. Haven't checked barcodes yet.

Contributor

thijstriemstra commented Oct 18, 2016

Thanks for the feedback. There's also a cups filter for this printer it seems (https://github.com/klirichek/zj-58) and during my tests it printed images/text. Haven't checked barcodes yet.

@thijstriemstra

This comment has been minimized.

Show comment
Hide comment
@thijstriemstra

thijstriemstra Oct 18, 2016

Contributor

Thanks @mike42, with your new code it printed the barcode in your image (the 1234A was also printed, i just didn't rip the paper correctly in pic below):

barcode

That means it's working right?

Contributor

thijstriemstra commented Oct 18, 2016

Thanks @mike42, with your new code it printed the barcode in your image (the 1234A was also printed, i just didn't rip the paper correctly in pic below):

barcode

That means it's working right?

@mike42

This comment has been minimized.

Show comment
Hide comment
@mike42

mike42 Oct 18, 2016

Contributor

Get a copy of zxing/zxing for Android to test this.

Very few of the barcodes I generated could be scanned correctly. If you see those sorts of bugs, they should be replicated with a snippet that does not use python-escpos (write them to an image), and posted upstream to the pBarcode project.

I am also aware of the CUPS filter. The CUPS print pipeline makes an image out of an entire page for the filter to convert, so if you can print text/images, and you have barcodes in a HTML or PDF document, this may work for you.

Contributor

mike42 commented Oct 18, 2016

Get a copy of zxing/zxing for Android to test this.

Very few of the barcodes I generated could be scanned correctly. If you see those sorts of bugs, they should be replicated with a snippet that does not use python-escpos (write them to an image), and posted upstream to the pBarcode project.

I am also aware of the CUPS filter. The CUPS print pipeline makes an image out of an entire page for the filter to convert, so if you can print text/images, and you have barcodes in a HTML or PDF document, this may work for you.

@thijstriemstra

This comment has been minimized.

Show comment
Hide comment
@thijstriemstra

thijstriemstra Oct 18, 2016

Contributor

I see. I've ordered a USB Laser Barcode Scanner X-9100 and will report back whether it can scan this barcode or not. Update: it works! Barcode in pic above was scanned with the X-9100 without a problem. Magical.

Contributor

thijstriemstra commented Oct 18, 2016

I see. I've ordered a USB Laser Barcode Scanner X-9100 and will report back whether it can scan this barcode or not. Update: it works! Barcode in pic above was scanned with the X-9100 without a problem. Magical.

@MicroJoe

This comment has been minimized.

Show comment
Hide comment
@MicroJoe

MicroJoe May 14, 2017

Contributor

I have the same printer and was able to print legible bar codes using pyBarcode (last beta has code128). Beware that if the barcode is too long in length the printer with roll and roll a lot of paper. An image-too-large exception should be implemented too in order to not waste paper.

I propose a feature to add barcode software rendering in order to fix this problem. The issue should be created appart and this issue closed for simpler identification for contributors.

Contributor

MicroJoe commented May 14, 2017

I have the same printer and was able to print legible bar codes using pyBarcode (last beta has code128). Beware that if the barcode is too long in length the printer with roll and roll a lot of paper. An image-too-large exception should be implemented too in order to not waste paper.

I propose a feature to add barcode software rendering in order to fix this problem. The issue should be created appart and this issue closed for simpler identification for contributors.

This was referenced May 14, 2017

@patkan patkan added the wontfix label May 14, 2017

@patkan

This comment has been minimized.

Show comment
Hide comment
@patkan

patkan May 14, 2017

Member

Thank you for the feedback. So the actual issue seems to be non-fixable.
See #218 for a follow-up.

Member

patkan commented May 14, 2017

Thank you for the feedback. So the actual issue seems to be non-fixable.
See #218 for a follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment