Skip to content
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

Support for StarPRNT (e.g. mc-Print 2/3)? #489

Open
1 task done
chrisv2 opened this issue Aug 18, 2022 · 2 comments
Open
1 task done

Support for StarPRNT (e.g. mc-Print 2/3)? #489

chrisv2 opened this issue Aug 18, 2022 · 2 comments

Comments

@chrisv2
Copy link

chrisv2 commented Aug 18, 2022

I have:

  • searched open and closed issues for duplicates

Bug description

When using a Star mcPrint 2 or 3, the printer won't cut, but instead print a V. That is because as laid down in the StarPRNT spec these printers use <ESC> d x for cutting instead of <GS> V x (see page 45 of the linked document). They also use <ESC> <GS> t x for codepage selection (instead of <ESC> t x).

Unfortunately both of those commands are hardcoded in python-escpos and there is no way to override that via capabilities.

I'm principally interested to work on this, but wanted to ask first if

a.) you consider this to be inside the scope of this project and
b.) if so, what would be the best way to implement it?

Basically one would need to override _CUT_PAPER and CODEPAGE_CHANGE, therefore it would be necessary to mark the printer (possibly in the profile) to support StarPRNT instead of regular ESCPOS. There is a starCommands flag in the profiles but it doesn't seem to be used anywhere?

Device info

Printer: Star mcPrint 3
python-escpos version: HEAD
python version: 3.8
operating system: Ubuntu

chrisv2 added a commit to tap4drink/python-escpos that referenced this issue Aug 19, 2022
chrisv2 added a commit to tap4drink/python-escpos that referenced this issue Aug 19, 2022
@yujingr
Copy link

yujingr commented Aug 24, 2022

Try sending binary data to the printer instead of cut command; it's in the docs, but you may have to find which binary command corresponds to what you are looking for.

Alternatively, try using the StarTSPImage library; I am not sure if the model is applicable, but it worked on my TSP100/TSP143 printers.
`import StarTSPImage
from PIL import Image, ImageDraw
import socket
import time

image = Image.new('RGB', (500, 500), color='White')
draw = ImageDraw.Draw(image)
draw.ellipse((0, 0, 500, 500), fill='Black')
draw.ellipse((10, 10, 490, 490), fill='White')

raster = StarTSPImage.imageFileToRaster('a.png', cut=True)
raster = StarTSPImage.imageToRaster(image, cut=True)

host = "192.168.12.241"
host = "10.1.10.113"
port = 9100
mysocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)

mysocket.connect((host, port))
mysocket.send(raster)

mysocket.close()

time.sleep(2)`

@AChangXD
Copy link

AChangXD commented Mar 2, 2023

For those wondering on what raw command it is to cut, you can do:
printer._raw(b'\x1b' + b'd' + b'\x00')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants