Code Monkey home page Code Monkey logo

Comments (15)

hennedo avatar hennedo commented on June 20, 2024

Mhh. What kind of printer are you using? Could you provide me with a minimal (but complete) code snippet that causes this bug to appear?

from escpos.

AurumAustralis avatar AurumAustralis commented on June 20, 2024

I was also thinking that it could be the printer, is a "sol802" thermal printer
http://postektronics.com/productdetails/SOL802

The code:
package main

import (
"net"

"github.com/hennedo/escpos"

)

func main() {
socket, err := net.Dial("tcp", "192.168.7.90:9100")
if err != nil {
println(err.Error())
}
defer socket.Close()

p := escpos.New(socket)

p.Bold(true).Size(2, 2).Write("Hello World")
p.LineFeed()

p.PrintAndCut()

}

And the result:
Hello World0

from escpos.

AurumAustralis avatar AurumAustralis commented on June 20, 2024

Printer config

`Print Speed 250mm/s
Print Density Medium
Print Width 72mm
Print Direction Normal
Print Font 12*24
Auto Cut on
ChangePaperRePrint off
Buzzer Enable Error On

Command Set ESC/POS
Code Page ISO-8859-15`

from escpos.

hennedo avatar hennedo commented on June 20, 2024

Sadly there is not that much information available about the printe. Currently my best guess is that it has to do something with the cut command. In the ESC/POS manual there are 3 ways to perform a cut. Could you clone the library locally and replace it in your project with the local version?

Within your go mod, just before the require part

replace github.com/hennedo/escpos => /home/.../escpos

Then replace

func (e *Escpos) Cut() (int, error) {
	return e.WriteRaw([]byte{gs, 'V', 'A', '0'})
}

with

func (e *Escpos) Cut() (int, error) {
	return e.WriteRaw([]byte{esc, 'i'})
}
// or if that does not work
func (e *Escpos) Cut() (int, error) {
	return e.WriteRaw([]byte{esc, 'm'})
}

One of those could possibly work..

from escpos.

AurumAustralis avatar AurumAustralis commented on June 20, 2024

I'm going to test with that code.
Thank you very much for the reply and speed!

from escpos.

AurumAustralis avatar AurumAustralis commented on June 20, 2024

It did not work
I'm going to keep trying and I'll put any solution here .
Thanks again.

from escpos.

hennedo avatar hennedo commented on June 20, 2024

Sorry that I could not be of more help. If you do find any solution, even if it's another open source library that I can have a look at that works, I'm interested!

from escpos.

AurumAustralis avatar AurumAustralis commented on June 20, 2024

I am adapting the augustopimenta library with yours and so far it works: charset, image, barcode (qr, upca, ean8 and ean13) and I added tables with tablewriter

Links to libraries
"github.com/augustopimenta/escpos"
"github.com/olekukonko/tablewriter"

I am working with Code128 and a problem with the images

When I finish I upload it to github

Thanks again Hendrik!

from escpos.

pinpox avatar pinpox commented on June 20, 2024

I'm running into this issue aswell, with an EPSON TM-T88II printer. Did you ever find a solution to this?

Printing images works fine, but any text has a "0" appended

from escpos.

hennedo avatar hennedo commented on June 20, 2024

Dang. I if @AurumAustralis did not find a solution for this I might need to buy an EPSON TM-T88II off of ebay-kleinanzeigen to work on a solution :D

from escpos.

hennedo avatar hennedo commented on June 20, 2024

After some debugging on my "new" printer, it seems it does not support the upside down printing, so as the library always pushes the current state when you call write, it sends the codes for upside down printing. the printer then ignores the ESC+{ and prints the 0 which is intended to tell the printer "no upsidedown printing please".

I refresh every setting set in the library with each write because when using a networked printer it's quite possible that another user sets different settings. I need find a solution for this. Maybe some sort of feature enable / disable depending on the model.

from escpos.

pinpox avatar pinpox commented on June 20, 2024

Thanks for investigating! Let me know if you need help testing, I've got a printer sitting on my desk.

from escpos.

hennedo avatar hennedo commented on June 20, 2024

So I added a config struct to disable certain features that are called during the write process and added some Device configs. Could you replace your dependency with a local copy of the compatibility_fix branch and confirm that everything works fine when you are adding the SetConfig line right after the escpos.New call?

p := escpos.New(socket)
// add here:
p.SetConfig(escpos.ConfigEpsonTMT88II)

Also if @AurumAustralis is still interested, would be good to know if this works for you also...

from escpos.

pinpox avatar pinpox commented on June 20, 2024

@hennedo I can confirm this fixes the issue with the Epson TM T88II, no more zeros. I noticed though, the QRcodes are not printed, not sure if this is related to the fix or a different issue, the code I'm using is this:
https://gist.github.com/pinpox/c360111ede61f8f62aa0c6cd2a3fb284

from escpos.

hennedo avatar hennedo commented on June 20, 2024

As QR code printing is a printerfeature the qr code is not generated by the library. Therefore the printer needs to support qr code printing. I do not think the TM-T88II supports QR code printing.
I'll merge the fix in master then!

from escpos.

Related Issues (15)

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.